$(function() {  
	$('.error').hide();
	$(".button").click(function() {  
	// validate and process form here  
	
		$('.error').hide();  
	
		var cognome = $("input#cognome").val();  
		if (cognome == "") {  
			$("label#cognome_error").show();  
			$("input#cognome").focus();  
			return false;  
		}	

		var nome = $("input#nome").val();  
		if (nome == "") {  
			$("label#nome_error").show();  
			$("input#nome").focus();  
			return false;  
		}	
		
		var azienda = $("input#azienda").val();  
		if (azienda == "") {  
			$("label#azienda_error").show();  
			$("input#azienda").focus();  
			return false;  
		}	

		var corso = $("input#corso").val();  
		if (corso == "") {  
			$("label#corso_error").show();  
			$("input#corso").focus();  
			return false;  
		}	
						
		var licenze = $("input#licenze").val();  
		if (licenze == "") {  
			$("label#licenze_error").show();  
			$("input#licenze").focus();  
			return false;  
		}	
		
		var email = $("input#email").val();  
		if (email == "") {  
			$("label#email_error").show();  
			$("input#email").focus();  
			return false;  
		}					

		var dataString = 'cognome='+ cognome + '&nome='+ nome + '&azienda=' + azienda + '&corso=' + corso + '&licenze=' + licenze + '&email=' + email;  
		//alert (dataString);return false;  
		$.ajax({  
			type: "POST",  
			url: "bin/mail.php",  
			data: dataString,  
			success: function() {  
				$('#contact_form').html("<div id='message'></div>");  
				$('#message').html("<p>La tua richiesta &egrave; stata inviata con successo.<br/>I nostri uffici ti contatteranno appena possibile.</p>")  
				.hide()  
				.fadeIn(1500, function() {  
				  $('#message').append("<img id='checkmark' src='images/check.png' />");  
				});
				/*setTimeout("location(http:\\www.versooo.com);",5000);*/
			}  
		});  
		
		return false;		


	
	});  
});
