/*-----------------------------------------------*/
/*------------ INIZIALIZZO OGGETTO --------------*/
/*-----------------------------------------------*/

var xmlHttp;

function createXMLHttpRequest(){

	if (window.XMLHttpRequest) {
	   xmlHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
	   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
	   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest');
	}

}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*------------ IMMAGINE PRELOAD -----------------*/
/*-----------------------------------------------*/

Testo_Check_Av = "";
Testo_Check_Av = Testo_Check_Av + "<center><img src='BANNER/wait.gif' border='0' style='margin-top:4px;'></center>"

Testo_Check_Av_Gif = "";
Testo_Check_Av_Gif = Testo_Check_Av_Gif + "<center><img src='BANNER/wait.gif' border='0' style='margin-top:4px;'></center>"

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*------------ BookNow ---------------------*/
/*-----------------------------------------------*/

function BookNow(UrlPagina){

createXMLHttpRequest();

		location.href = "book_now.asp"+UrlPagina

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*------------ BookItTop ------------------------*/
/*-----------------------------------------------*/

function BookItTop(UrlPagina){

createXMLHttpRequest();

f = document.forms.form31;
b = document.form31;
		
		if (f.data_arrivo.value == ''   ){
			alert("Please insert Chek in!");
			f.data_arrivo.focus();
			return false;
		}
		
		if (f.n_notti.value == ''   ){
			alert("Please insert n. of nights!");
			f.n_notti.focus();
			return false;
		}
		
		if (f.n_notti.value < 1   ){
			alert("N. of nights must be > 0!");
			f.n_notti.focus();
			return false;
		}
		
				if (!IsNumber(f.n_notti.value)){
					alert("N. of nights is incorrect!");
					f.n_notti.focus();
					return false;
				}
		
		if (f.n_persone.value == ''   ){
			alert("Please insert n. of people!");
			f.n_notti.focus();
			return false;
		}
		
		if (f.n_persone.value < 1   ){
			alert("N. of people must be > 0!");
			f.n_persone.focus();
			return false;
		}
		
				if (!IsNumber(f.n_persone.value)){
					alert("N. of people is incorrect!");
					f.n_persone.focus();
					return false;
				}

		var	postData = "n_notti="+f.n_notti.value
		postData = postData + "&n_persone="+f.n_persone.value
		postData = postData + "&data_arrivo="+f.data_arrivo.value
		postData = postData + "&FunzioneAjax=VisualizzaTastoBookTop"
		
		xmlHttp.open("POST", "verifica_date_globale.asp"+UrlPagina, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", postData.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange = handleStateVerificaTop;
		xmlHttp.send(postData);
}

function VisualizzaTastoBookTop(UrlPagina){

createXMLHttpRequest();

f = document.forms.form31;
b = document.form31;

f.data_arrivo.value = "";
f.n_notti.value = "2";
f.n_persone.value = "1";

		var	postData = "visualizza_tasto=1"
		postData = postData + "&FunzioneAjax=BookItTop"

		xmlHttp.open("POST", "verifica_date_globale.asp"+UrlPagina, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", postData.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange = handleStateVerificaTop;
		xmlHttp.send(postData);
}

function handleStateVerificaTop(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td>"
Messaggio = Messaggio + "<center>Impossibile caricare il menu di navigazione ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

		if (xmlHttp.readyState==4){

			if (xmlHttp.status == 200){

				document.getElementById("Verifica_Date_Div_Top").innerHTML = xmlHttp.responseText;

				if ( document.getElementById("redir") != null ) {
					location.href = document.getElementById("redir").value;
				}

			}else{

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Verifica_Date_Div_Top").innerHTML = Messaggio;
			}
		
		}else{
				
			document.getElementById("Verifica_Date_Div_Top").innerHTML = Testo_Check_Av_Gif
			
		}


}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*------------ BookItMiddle ---------------------*/
/*-----------------------------------------------*/

function BookItMiddle(UrlPagina){

createXMLHttpRequest();

f = document.forms.form32;
b = document.form32;
		
		if (f.data_arrivo.value == ''   ){
			alert("Please insert Chek in!");
			f.data_arrivo.focus();
			return false;
		}
		
		if (f.n_notti.value == ''   ){
			alert("Please insert n. of nights!");
			f.n_notti.focus();
			return false;
		}
		
		if (f.n_notti.value < 1   ){
			alert("N. of nights must be > 0!");
			f.n_notti.focus();
			return false;
		}
		
				if (!IsNumber(f.n_notti.value)){
					alert("N. of nights is incorrect!");
					f.n_notti.focus();
					return false;
				}
		
		if (f.n_persone.value == ''   ){
			alert("Please insert n. of people!");
			f.n_notti.focus();
			return false;
		}
		
		if (f.n_persone.value < 1   ){
			alert("N. of people must be > 0!");
			f.n_persone.focus();
			return false;
		}
		
				if (!IsNumber(f.n_persone.value)){
					alert("N. of people is incorrect!");
					f.n_persone.focus();
					return false;
				}

		var	postData = "n_notti="+f.n_notti.value
		postData = postData + "&n_persone="+f.n_persone.value
		postData = postData + "&data_arrivo="+f.data_arrivo.value
		postData = postData + "&FunzioneAjax=VisualizzaTastoBookMiddle"
		
		xmlHttp.open("POST", "verifica_date.asp"+UrlPagina, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", postData.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange = handleStateVerificaMiddle;
		xmlHttp.send(postData);
}

function VisualizzaTastoBookMiddle(UrlPagina){

createXMLHttpRequest();

f = document.forms.form32;
b = document.form32;

f.data_arrivo.value = "";
//f.n_notti.value = "2";
f.n_persone.value = "1";

		var	postData = "visualizza_tasto=1"
		postData = postData + "&FunzioneAjax=BookItMiddle"

		xmlHttp.open("POST", "verifica_date.asp"+UrlPagina, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", postData.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange = handleStateVerificaMiddle;
		xmlHttp.send(postData);
}

function handleStateVerificaMiddle(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td>"
Messaggio = Messaggio + "<center>Impossibile caricare il menu di navigazione ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

		if (xmlHttp.readyState==4){

			if (xmlHttp.status == 200){

				document.getElementById("Verifica_Date_Div_Middle").innerHTML = xmlHttp.responseText;
				
				if ( document.getElementById("redir") != null ) {
					location.href = document.getElementById("redir").value;
				}
				
			}else{

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Verifica_Date_Div_Middle").innerHTML = Messaggio;
			}
		
		}else{
				
			document.getElementById("Verifica_Date_Div_Middle").innerHTML = Testo_Check_Av
			
		}


}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/




/*-----------------------------------------------*/
/*------------ BookItMiddleGlobale --------------*/
/*-----------------------------------------------*/

function BookItMiddleGlobale(UrlPagina){

createXMLHttpRequest();

f = document.forms.form32;
b = document.form32;
		
		if (f.data_arrivo.value == ''   ){
			alert("Please insert Chek in!");
			f.data_arrivo.focus();
			return false;
		}
		
		if (f.n_notti.value == ''   ){
			alert("Please insert n. of nights!");
			f.n_notti.focus();
			return false;
		}
		
		if (f.n_notti.value < 1   ){
			alert("N. of nights must be > 0!");
			f.n_notti.focus();
			return false;
		}
		
				if (!IsNumber(f.n_notti.value)){
					alert("N. of nights is incorrect!");
					f.n_notti.focus();
					return false;
				}
		
		if (f.n_persone.value == ''   ){
			alert("Please insert n. of people!");
			f.n_notti.focus();
			return false;
		}
		
		if (f.n_persone.value < 1   ){
			alert("N. of people must be > 0!");
			f.n_persone.focus();
			return false;
		}
		
				if (!IsNumber(f.n_persone.value)){
					alert("N. of people is incorrect!");
					f.n_persone.focus();
					return false;
				}

		var	postData = "n_notti="+f.n_notti.value
		postData = postData + "&n_persone="+f.n_persone.value
		postData = postData + "&data_arrivo="+f.data_arrivo.value
		postData = postData + "&FunzioneAjax=VisualizzaTastoBookMiddleGlobale"
				
		xmlHttp.open("POST", "verifica_date_globale_middle.asp"+UrlPagina, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", postData.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange = handleStateVerificaMiddleGlobale;
		xmlHttp.send(postData);
}

function VisualizzaTastoBookMiddleGlobale(UrlPagina){

createXMLHttpRequest();

f = document.forms.form32;
b = document.form32;

//f.data_arrivo.value = "";
//f.n_notti.value = "2";
//f.n_persone.value = "1";

		var	postData = "visualizza_tasto=1"
		postData = postData + "&FunzioneAjax=BookItMiddleGlobale"

		xmlHttp.open("POST", "verifica_date_globale_middle.asp"+UrlPagina, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", postData.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange = handleStateVerificaMiddleGlobale;
		xmlHttp.send(postData);
}

function handleStateVerificaMiddleGlobale(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td>"
Messaggio = Messaggio + "<center>Impossibile caricare il menu di navigazione ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

		if (xmlHttp.readyState==4){

			if (xmlHttp.status == 200){

				document.getElementById("Verifica_Date_Div_Middle").innerHTML = xmlHttp.responseText;
				
				if ( document.getElementById("redir") != null ) {
					location.href = document.getElementById("redir").value;
				}
				
			}else{

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Verifica_Date_Div_Middle").innerHTML = Messaggio;
			}
		
		}else{
				
			document.getElementById("Verifica_Date_Div_Middle").innerHTML = Testo_Check_Av
			
		}


}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/






/*-----------------------------------------------*/
/*------------ BookItBottom ---------------------*/
/*-----------------------------------------------*/

function BookItBottom(UrlPagina){

createXMLHttpRequest();

f = document.forms.form33;
b = document.form33;
		
		if (f.data_arrivo.value == ''   ){
			alert("Please insert Chek in!");
			f.data_arrivo.focus();
			return false;
		}
		
		if (f.n_notti.value == ''   ){
			alert("Please insert n. of nights!");
			f.n_notti.focus();
			return false;
		}
		
		if (f.n_notti.value < 1   ){
			alert("N. of nights must be > 0!");
			f.n_notti.focus();
			return false;
		}
		
				if (!IsNumber(f.n_notti.value)){
					alert("N. of nights is incorrect!");
					f.n_notti.focus();
					return false;
				}
		
		if (f.n_persone.value == ''   ){
			alert("Please insert n. of people!");
			f.n_notti.focus();
			return false;
		}
		
		if (f.n_persone.value < 1   ){
			alert("N. of people must be > 0!");
			f.n_persone.focus();
			return false;
		}
		
				if (!IsNumber(f.n_persone.value)){
					alert("N. of people is incorrect!");
					f.n_persone.focus();
					return false;
				}

		var	postData = "n_notti="+f.n_notti.value
		postData = postData + "&n_persone="+f.n_persone.value
		postData = postData + "&data_arrivo="+f.data_arrivo.value
		postData = postData + "&FunzioneAjax=VisualizzaTastoBookBottom"

		xmlHttp.open("POST", "verifica_date.asp"+UrlPagina, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", postData.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange = handleStateVerificaBottom;
		xmlHttp.send(postData);
}

function VisualizzaTastoBookBottom(UrlPagina){

createXMLHttpRequest();

f = document.forms.form33;
b = document.form33;

f.data_arrivo.value = "";
//f.n_notti.value = "2";
f.n_persone.value = "1";

		var	postData = "visualizza_tasto=1"
		postData = postData + "&FunzioneAjax=BookItBottom"

		xmlHttp.open("POST", "verifica_date.asp"+UrlPagina, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", postData.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange = handleStateVerificaBottom;
		xmlHttp.send(postData);
}

function handleStateVerificaBottom(){

Messaggio = "";
Messaggio = Messaggio + "<table border='0' cellpadding='0' cellspacing='0' style='width:100%; FONT-SIZE: 11px;COLOR: #000000; FONT-FAMILY: Trebuchet MS, Verdana;'>"
Messaggio = Messaggio + "  <tr><td>"
Messaggio = Messaggio + "<center>Impossibile caricare il menu di navigazione ....</center>"
Messaggio = Messaggio + "  </td></tr>"
Messaggio = Messaggio + "</table>"

		if (xmlHttp.readyState==4){

			if (xmlHttp.status == 200){

				document.getElementById("Verifica_Date_Div_Bot").innerHTML = xmlHttp.responseText;

				if ( document.getElementById("redir") != null ) {
					location.href = document.getElementById("redir").value;
				}

			}else{

				// INTERCETTO ERRORE E VISUALIZZO
				handleErrFullPage(xmlHttp.responseText);
				//-------------------------------
				
				document.getElementById("Verifica_Date_Div_Bot").innerHTML = Messaggio;
			}
		
		}else{
				
			document.getElementById("Verifica_Date_Div_Bot").innerHTML = Testo_Check_Av
			
		}


}
/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/



/*-----------------------------------------------*/
/*--- APERTURA POP-UP ---------------------------*/
/*-----------------------------------------------*/

function apriFinestra(page)
{
   winOpened=window.open(page,"","height=500,width=500,scrollbars=yes,toolbar=no");
}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/

/*-----------------------------------------------*/
/*--- GESTIONE E VISUALIZZAZIONE ERRORI ---------*/
/*-----------------------------------------------*/

function handleErrFullPage(strIn) {	

        var errorWin;

        // Create new window and display error
        try {
			errorWin = window.open('', 'errorWin');
			errorWin.document.body.innerHTML = strIn;
        }
        // If pop-up gets blocked, inform user
        catch(e) {
			alert(strIn);
		}

}

/*-----------------------------------------------*/
/*-----------------------------------------------*/
/*-----------------------------------------------*/