//	inizio funzioni di debug
debug_msg = true;
function toDebug(string)
{
	if (debug_msg)
	{
		if((typeof window.console=="undefined")) {alert(string);}
		else {}
	}
}
function toConsole(string)
{
	if((typeof window.console=="undefined")) {/* alert(string); */}
	else console.log(string);
}


jQuery(document).ready(function()
{
	
	
	jQuery("#form").validate({
 		submitHandler: function(form) {
		
			jQuery("#form").ajaxSubmit({ 
       		 dataType:  'json', 
        		success:   processJson 
    		});
 		}
	});

});

jQuery(window).load(function()
{

});




function processJson(data) { 
    // 'data' is the json object returned from the server 
    
    if(data.message == 1){
    	 jQuery('#form').fadeOut().delay(500,function(){
		jQuery('.load').fadeIn().delay(3000,function(){
			jQuery('.load').fadeOut().delay(500,function(){
				jQuery('.msg').fadeIn().delay(2000,function(){
					jQuery('.msg').fadeOut().delay(100,function(){
					location.href = "";
					return false;
					});
					
				})
			})
			
		})
		
		}) 
    }else{
   	 jQuery('.errore').fadeIn().delay(2000,function(){
   	 	jQuery('.errore').fadeOut();
   	 });
    }
    
    
}


