function showAddTestimonialForm(){
    $("#testimonial-dialog").dialog({
		modal:true,
		draggable:false,
		width:547,
        buttons: {
            "Send": function(){
                   if ($('#testimonialForm').valid())
                   {
                       var name = $("#testimonial-name").val();
                       var email = $("#testimonial-email").val();
                       var message = $("#testimonial-message").val();
                       addTestimonial(name, email, message);
                       $(this).dialog("destroy");
                   }
            },
            "Close": function(){
                   $("#testimonial-name").val("");
                   $("#testimonial-email").val("");
                   $("#testimonial-message").val("");
                   $(this).dialog("destroy");
            }
        }
	}).dialog("open");
}


function addTestimonial(name, email, message){
    $("#testimonial-loading").dialog({
		modal:true,
		draggable:false,
		width:310,
		beforeclose:function() {
			return false;
		}
	}).dialog("open");
    $.ajax({type: "GET",
			url : "/ajax/testimonial/",
            data : "name="+name+"&email="+email+"&message="+message,
			success: handleAddTestimonialAJAXResponse
			});
}

function handleAddTestimonialAJAXResponse(msg)
{
    $("#testimonial-loading").dialog("destroy");
    var response = eval("("+msg+")");
    if (!response['error'])
    {
        $("#success-dialog").dialog({
		modal:true,
		draggable:false,
		//width:590,
        buttons: {
            "OK": function(){
                   $(this).dialog("destroy")
            }
        }
	}).dialog("open");

    }
    else
    {
        $("#error-dialog").dialog({
		modal:true,
		draggable:false,
		//width:590,
        buttons: {
            "OK": function(){
                   $(this).dialog("destroy")
            }
        }
	}).dialog("open");
    }
}