//funzione che mi permette di centrare la popup
function resizeWin(Larghezza,Altezza){
var sizeH= Altezza;
var sizeW= Larghezza;
var posH=0;
var posW=0;

if (sizeH<=screen.height)
sizeH=30+sizeH;
if (sizeW<=screen.width)
sizeW=30+sizeW
self.resizeTo(sizeW,sizeH);
if (((screen.height-sizeH)/2)>0)
posW=((screen.height-sizeH)/2);
if (((screen.width-sizeW)/2)>0)
posH=((screen.width-sizeW)/2);
self.moveTo(posW,posH);
}





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 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 !! Your departure date was more than 30 days after your arrival date !!";
}
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 !! La data di Partenza non può essere superiore di 30 giorni alla data di Arrivo !!";
}

var year = document.forms[0].checkin_year.value;
var month = document.forms[0].checkin_month.value - 1;
var day = document.forms[0].checkin_monthday.value;
var dt = new Date(year, month, day);

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;
}
else{
var ONE_DAY = 1000 * 60 * 60 * 24 
var difference_ms = Math.abs(dt - dt2) ;
var giorni = Math.round(difference_ms/ONE_DAY) ;
if (giorni>30){
alert(Advise_7);
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 che mi apre pop-up (vedi: 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);
}




//funzione per disabilitare e cambiare il testo sul tasto submit nel momento di invio dati
function disabilita(){
document.forms[0].submit.value = "Attendere..";
document.forms[0].submit.disabled = true;
}


//funzione per disabilitare e cambiare il testo sul tasto submit nel momento di invio dati
function disabilita1(){
document.forms[0].submit.value = "Wait please..";
document.forms[0].submit.disabled = true;
}


//funzione per disabilitare e cambiare il testo sul tasto submit nel momento di invio dati (modulo REGISTRA.ASP)
function disabilita2(){
document.forms[1].submit.value = "Attendere..";
document.forms[1].submit.disabled = true;
}


//funzione per disabilitare e cambiare il testo sul tasto submit nel momento di invio Commento (Schede Turistiche)
function disabilita3(){
document.forms[1].submit.value = "Wait please..";
document.forms[1].submit.disabled = true;
}


//funzione che mi permette di ridimensionare le immagini in Schede Turistiche se superano una determinata larghezza
function ridimensiona(){ 
for (imm in document.images){ 
img = document.images[imm] 
if (img.className=="b_illustration" || img.className=="image"){ 
if (img.width > 460){ 
img.width=460
} 
} 
} 
}
