//---------------------------------- INVIO FORM


$(function() {
//------------------------------------------------------------------- COMMENTI
$(".submitCommento").click(function() {
    var nome = $("#nomeComment").val();
	var nazione = $("#nazioneComment").val();
	var email = $("#emailComment").val();
	var commento = $("#commentoComment").val();
	var codice = $("#codiceComment").val();
	var lang = $("#langComment").val();
	var voto = $("#voto").val();
	$("#nomeErroreComment").hide();
	$("#nazioneErroreComment").hide();
	$("#emailErroreComment").hide();
	$("#commentoErroreComment").hide();
	if (nome=='') { $("#nomeComment").focus(); $("#nomeErroreComment").fadeIn(200).show(); }
	if (nazione=='') { $("#nazioneComment").focus(); $("#nazioneErroreComment").fadeIn(200).show();}	
	if (email=='') {$("#emailComment").focus();$("#emailErroreComment").fadeIn(200).show();}
	if (commento=='') {$("#commentoComment").focus();$("#commentoErroreComment").fadeIn(200).show();}
	var dataString = 'nome='+ nome + '&nazione=' + nazione + '&email=' + email + '&commento=' + commento+ '&lang=' +lang+ '&codice=' +codice+ '&voto=' +voto;	
	if(nome=='' || nazione=='' || email=='' || commento=='') { $('.success').fadeOut(200).hide(); $('.error').fadeIn(200).show(); }
	else
	{
	$.ajax({
	type: "POST",
    url: "ajax/postcomment.php",
    data: dataString,
    success: function(msg){
	$('#risultatoFormComment').html(msg);
	$('#risultatoFormComment').fadeIn(600).show();
	$('.submitCommento').fadeOut(400).hide();
   }
});
$('.error').fadeOut(200).hide(); $('.success').fadeIn(200).show();
}
return false;
});
//------------------------------------------------------------------- FINE COMMENTI

//------------------------------------------------------------------- DOMANDE GENERICHE
$(".submitDomanda").click(function() {
    var nome = $("#nome").val();
	var telefono = $("#telefono").val();
	var email = $("#email").val();
	var domanda = $("#domanda").val();
	var codice = $("#codice").val();
	var lang = $("#lang").val();
	$("#nomeErrore").hide();
	$("#nazioneErrore").hide();
	$("#emailErrore").hide();
	$("#commentoErrore").hide();
	if (nome=='') { $("#nome").focus(); $("#nomeErrore").fadeIn(200).show(); }
	if (telefono=='') { $("#telefono").focus(); $("#telefonoErrore").fadeIn(200).show();}	
	if (email=='') {$("#email").focus();$("#emailErrore").fadeIn(200).show();}
	if (domanda=='') {$("#domanda").focus();$("#domandaErrore").fadeIn(200).show();}
	var dataString = 'nome='+ nome + '&telefono=' + telefono + '&email=' + email + '&domanda=' + domanda+ '&lang=' +lang+ '&codice=' +codice;	
	if(nome=='' || telefono=='' || email=='' || domanda=='') { $('.success').fadeOut(200).hide(); $('.error').fadeIn(200).show(); }
	else
	{
	$.ajax({
	type: "POST",
    url: "ajax/postdomanda.php",
    data: dataString,
    success: function(msg){
	$('#risultatoForm').html(msg);
	$('#risultatoForm').fadeIn(600).show();
	$('.submitDomanda').fadeOut(400).hide();
   }
});
$('.error').fadeOut(200).hide(); $('.success').fadeIn(200).show();
}
return false;
});
//------------------------------------------------------------------- FINE DOMANDE GENERICHE



//------------------------------------------------------------------- NESLETTER
$("#registraNewsletter").click(function() {
    var nome = $("#nomeNewsletter").val();
	var email = $("#emailNewsletter").val();
	$("#erroreNomeNewsletter").hide();
	$("#erroreEmailNewsletter").hide();
	if (nome=='') { $("#nome").focus(); $("#erroreNomeNewsletter").fadeIn(200).show(); }
	if (email=='') {$("#email").focus();$("#erroreEmailNewsletter").fadeIn(200).show();}
	var dataString = 'nome='+ nome + '&email=' + email;	
	if(nome=='' || email=='') { $('#risultatoNewsletterPositivo').fadeOut(200).hide(); $('#risultatoNewsletterNegativo').fadeIn(200).show(); }
	else
	{
	$.ajax({
	type: "POST",
    url: "ajax/newsletter.php",
    data: dataString,
    success: function(msg){
	$('#risultatoNewsletterPositivo').html(msg);
	$('#risultatoNewsletterPositivo').fadeIn(600).show();
   }
});
$('#risultatoNewsletterPositivo').fadeOut(200).hide(); $('#risultatoNewsletterNegativo').fadeIn(200).show();
}
return false;
});
//------------------------------------------------------------------- FINE DOMANDE GENERICHE













//------------------------------------------------------------------- FORM NO PreZZO
$(".submitInfo20").click(function() {
    var npersone = $("#npersone").val();
	var nbambini = $("#nbambini").val();
	var titolo = $("#titolo").val();
	var nome = $("#nome").val();
	var cognome = $("#cognome").val();
	var indirizzo1 = $("#indirizzo1").val();
	var citta = $("#citta").val();
	var nazione = $("#nazione").val();
	var telefono1 = $("#telefono1").val();
	var telefono2 = $("#telefono2").val();
	var email = $("#email").val();
	var email2 = $("#email2").val();
	var casaID = $("#casaID").val();
	var dal = $("#from").val();
	var al = $("#to").val();
	var note = $("#note").val();
	
	
	$("#npersoneErrore").hide();
	$("#titoloErrore").hide();
	$("#nomeErrore").hide();
	$("#cognomeErrore").hide();
	$("#indirizzo1Errore").hide();
	$("#cittaErrore").hide();
	$("#telefono1Errore").hide();
	$("#emailErrore").hide();
	$("#emailErrore2").hide();
	$("#selezioneErrore").hide();
	$("#terminiErrore").hide();
	
	
	var nerrori=0;
	
	
	if (npersone=='0') { $("#npersone").focus(); $("#npersoneErrore").fadeIn(200).show(); nerrori++; }
	if (titolo=='--') { $("#titolo").focus(); $("#titoloErrore").fadeIn(200).show(); nerrori++;}	
	if (nome=='') {$("#nome").focus();$("#nomeErrore").fadeIn(200).show(); nerrori++;}
	if (cognome=='') {$("#cognome").focus();$("#cognomeErrore").fadeIn(200).show(); nerrori++;}
	if (indirizzo1=='') {$("#indirizzo1").focus();$("#indirizzo1Errore").fadeIn(200).show(); nerrori++;}
	if (citta=='') {$("#citta").focus();$("#cittaErrore").fadeIn(200).show(); nerrori++;}
	if (telefono1=='') {$("#telefono1").focus();$("#telefono1Errore").fadeIn(200).show(); nerrori++;}
	if (email=='') {$("#email").focus();$("#emailErrore").fadeIn(200).show(); nerrori++;}
	if (email2=='') {$("#email2").focus();$("#emailErrore2").fadeIn(200).show(); nerrori++;}
	if (email2!==email) {$("#email2").focus();$("#emailErrore2").fadeIn(200).show(); nerrori++;}
	if ($("#accettoTermini").is(":not(:checked)")) {$("#accettoTermini").focus();$("#terminiErrore").fadeIn(200).show(); nerrori++;}

	
	var selectedItems = new Array();
	$("input[@name='itemSelect[]']:checked").each(function() {selectedItems.push($(this).val());});
	
	if (selectedItems.join('|')=="on|on") { $("#itemSelect[]").focus();$("#selezioneErrore").fadeIn(200).show(); }
	
	
	var dataString = 'npersone='+ npersone + '&titolo=' + titolo + '&nome=' + nome + '&cognome=' + cognome+ '&indirizzo1=' +indirizzo1+ '&citta=' +citta+ '&nazione=' +nazione+ '&telefono1=' +telefono1+ '&telefono2=' +telefono2+ '&email=' +email+ '&dal=' +dal+ '&al=' +al+ '&casaID=' +casaID+ '&nbambini=' +nbambini+ '&note=' +note+ '&items=' + selectedItems.join('|');
	
	//alert(dataString);
	
	if(nerrori==0) {


	$.ajax({
	type: "POST",
    url: "ajax/noprice.php",
    data: dataString,
    success: function(msg){
	$('#payment_container').fadeOut(400).hide();
	$('#sum_container').html(msg);
	$('#sum_container').fadeIn(600).show();
	return false;

 }
});
//$('.error').fadeOut(200).hide(); $('.success').fadeIn(200).show();
}
return false;
});
//------------------------------------------------------------------- FINE FORM NO PREZZO






});

























