function loadContent(parameters, callback){

    // Création de l'URL d'envoie
 	var msg = '<DIV CLASS="msg">' + lng_loading + '</DIV>';

	$('#gb').slideUp("slow", function(){
	    $('#gb').html(msg).show("slow", function(){
		    $.ajax({type:'POST', url:'guestbook_elements.php', contentType:'application/x-www-form-urlencoded; charset=ISO-8859-1', data:parameters, success:function(html){
			    $('#gb').html(msg).hide("slow",function(){
				    $('#gb').html(html);
				    $('#gb').slideDown("slow", callback);
			    });
		    }, dataType:'html'});
	    });
    });
}

function changePage(no){
	loadContent('no=' + no, function(){});
} 

function submitForm(){
		$('#submit').attr("disabled","disabled");
	    var nom = $("#nom").val();
	    var commentaire = $("#commentaire").val();
	    var email = $("#email").val();
	    
	    var parameters = 'action=insert&nom=' + nom + '&commentaire=' + commentaire + '&email=' + email;
		    
		loadContent(parameters, function(){
			$("#nom").val('');
			$("#commentaire").val('');
			$("#email").val('');
			$('#submit').removeAttr("disabled");
		});
		
		return false;
} 

$(document).ready(function(){
	
	$("#frmGuestbook").validate({
		errorPlacement: function(error, element) {
	    	element.after(error).after('<BR>');
        },
        
        submitHandler: function(form) {
   			submitForm();
   		}
    });

	generateSprites(".nav", "current-", true, 250, "fade");
	$("#nom").focus();
	changePage(1);
	
});
	
