//funzione che mi controlla il form di BOOKING ONLINE
function checkForm(lang){

if (lang=="en"){
var Advise_1 = "The Arrival Date is wrong...please check !!";
var Advise_2 = "The Departure Date is wrong...please check !!";
var Advise_3 = "Attention !! The arrival date is inferior to today !!";
var Advise_4 = "Attention !! The daparture date is inferior to today !!";
var Advise_5 = "Attention !! The departure date is inferior to the arrival date !!";
var Advise_6 = "Attention !! Insert at least 3 characters in the field of Destination !!";
var Advise_7 = "Attention !! The Date format is wrong !! ";
}
else {
var Advise_1 = "Il Giorno di Arrivo è errato.. !!";
var Advise_2 = "Il Giorno di Partenza è errato... !!";
var Advise_3 = "Attenzione !! Il Giorno di Arrivo è inferiore alla data odierna !!";
var Advise_4 = "Attenzione !! Il Giorno di Partenza è inferiore alla data odierna !!";
var Advise_5 = "Attenzione !! Il Giorno di Partenza è inferiore al Giorno di Arrivo !!";
var Advise_6 = "Attenzione !! Inserire almeno 3 caratteri nel campo Destinazione !!";
var Advise_7 = "Attenzione !! Formato data non valida !! ";
}

var anno = document.forms[0].checkin_year_month.value;
var mese = document.forms[0].checkin_year_month.value;
var giorno = document.forms[0].checkin_monthday.value;
var mese2 = mese.substr(4,3).replace("-","")-1;
var anno2 = anno.substr(0,4);
var dt = new Date(anno2, mese2, giorno);
var now = new Date();
var today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
var confronta = giorno + "/" + mese2 + "/" + anno2;
if (dt < today){
alert(Advise_3);
document.forms[0].checkin_monthday.focus();
return false;
}

var date_array = confronta.split('/'); 
var day = date_array[0]; // Attention! Javascript consider months in the range 0 - 11
var month = date_array[1];
var year = date_array[2]; // This instruction will create a date object
source_date = new Date(year,month,day);
if (year != source_date.getFullYear()){
alert(Advise_7);
return false;
}
if (month != source_date.getMonth()){
alert(Advise_7);
return false;
}
if (day != source_date.getDate()){
alert(Advise_7);
return false;
}

//if (dt.getFullYear() != year || dt.getMonth() != month || dt.getDate() != day){
//alert(Advise_1);
//document.forms[0].checkin_monthday.focus();
//return false;
//}
//var year2 = document.forms[0].checkout_year.value;
//var month2 = document.forms[0].checkout_month.value - 1;
//var day2 = document.forms[0].checkout_monthday.value;
//var dt2 = new Date(year2, month2, day2);
//if (dt2.getFullYear() != year2 || dt2.getMonth() != month2 || dt2.getDate() != day2){
//alert(Advise_2);
//document.forms[0].checkout_monthday.focus();
//return false;
//}
//var now = new Date();
//var today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
//if (dt < today){
//alert(Advise_3);
//document.forms[0].checkin_monthday.focus();
//return false;
//}
//var now = new Date();
//var tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate());
//if (dt2 < tomorrow){
//alert(Advise_4);
//document.forms[0].checkout_monthday.focus();
//return false;
//}
//if (dt2 <= dt){
//alert(Advise_5);
//document.forms[0].checkout_monthday.focus();
//return false;
//}

var ss = document.forms[0].ss.value.length;
if (ss < 3){
alert(Advise_6);
document.forms[0].ss.focus();
return false;
}
return true;
}



//funzione per disabilitare e cambiare il testo sul tasto submit nel momento di invio dati
function disabilita(obj){
obj.submit.value = "Loading..";
obj.submit.disabled = true;
}



function nascondi(nome){
var stato = document.getElementById("tbl" + nome).style.display;
if (stato != "none"){
// Nascondo la riga
document.getElementById("tbl" + nome).style.display = "none";
}
}
function apri(nome){
var statoapri = document.getElementById("tbl" + nome).style.display;
if (statoapri == "none"){
// Visualizzo la riga
document.getElementById("tbl" + nome).style.display = "";
}
}


// funzione per far comparire il pop-up 
function apriFinestra(page){
var winOpenSquadra;
winOpened = window.open(page,"CF","directories=no,status=no,statusbar=no,resizable=no,menubar=no,noscrollbars,toolbar=no,width=370,height=265,left=100,top=100");
}


//funzione che mi permette di ridimensionare le immagini in Offerte ed Eventi se superano una determinata larghezza
function ridimensiona(){ 
for (imm in document.images){ 
img = document.images[imm] 
if (img.className=="image"){ 
if (img.width > 500){ 
img.width=500
} 
} 
} 
} 



//funzione che mi apre pop-up (vedi: POP PRIVACY)
function openwindow2(Url, Wid, Hei){
window.open (Url, '', 'toolbar=no,status=yes,menubar=no,scrollbars=yes,fullscreen=no,resizable=no,width='+Wid+',height='+Hei);
}

