bookmarkurl = "http://www.hoteldeicavalieri.com"
bookmarktitle = "Hotel dei Cavalieri - Milano - Nel cuore vivo di Milano"

function checkLaunch()
{
	if (location.search!="") launch()
}

function launch(params)
{
	if (typeof(params)=="undefined")
	{
		params = location.search
	}
	
	urlPagina = "contenitore.htm" + params;
	win_width = screen.width
	win_height= screen.height
	contenitore = window.open(urlPagina,"contenitore_hdc","width="+win_width+", height=" + win_height + ",top=0,left=0,resizable=yes, status=yes")
	if (typeof(contenitore)!="undefined")
	{
		contenitore.resizeTo(win_width,win_height-30)
		contenitore.moveTo(0,0);
		contenitore.focus();
	} else
	{

	}
}

function launchMeeting()
{
	urlPagina = "meeting_and_events.php"
	win_width = screen.width
	win_height= screen.height
	contenitore_meeting = window.open(urlPagina,"contenitore_meeting_hdc","width="+win_width+", height=" + win_height + ",top=0,left=0,resizable=yes, status=yes, fullscreen=yes, scrollbars=no")
	if (typeof(contenitore_meeting)!="undefined")
	{
		contenitore_meeting.resizeTo(win_width,win_height-30)
		contenitore_meeting.moveTo(0,0);
		contenitore_meeting.focus();
	} 
	else
	{

	}
}
function launchAutoexecutor()
{
	launch("?autoexecutor=si")
}

function closeAutoexecutor()
{
	if (typeof(contenitore)!="undefined")
	{
		contenitore.close();
	}
}



function bookmarkThisSite()
{
	if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle);
}

function apriPDFDinning(id_lingua)
{
	alert("apriPDFDinning() - "+id_lingua)
}

function copyRightWin(id_lingua)
{
	finetra_copyright = window.open("htm/copyright.htm", "copyright" , "width=350, height =300,status=yes, scrollbars=yes, resizable = yes")
	finetra_copyright.focus();
}
function creditsWin(id_lingua)
{
	//alert("creditsWin() - " + id_lingua)
	finetra_credits = window.open("htm/credits.htm", "Credits" , "width=310, height =350,status=yes, resizable=yes")
	finetra_credits.focus();
} 

function apriDocumento(Documento)
{
	finestra_documento = window.open(Documento, "finestraDcoumento", "width=700, height=500, resizable=yes, scrolling=yes, status=yes")
	finestra_documento.focus();
}

function apriImmagine(immagine)
{
	finestra_immagine = window.open(immagine, "finestraImmagine")
	finestra_immagine.focus()
}

function apriFormRichiestaInfoMeeting(id_lingua)
{
	if (id_lingua==1) basepage= "formMeeting.htm";
	if (id_lingua==0) basepage= "formMeeting_eng.htm";
	finestra_richiesta_info_meeting = window.open(basepage+"?id_lingua=" + id_lingua, "finestraRichiestaInfoMeeting" , "width=410, height =590,status=yes, scrollbars=yes, resizable = yes")
	finestra_richiesta_info_meeting.focus();
}


function apriDettaglioPromozioni(id,id_lingua)
{
	if (id_lingua==1) lingua = "ita";
	if (id_lingua==2) lingua = "eng";	
	
	url = "http://bookings.blastness.com/index.html?id_stile=$id_stile&id_albergo=316&dc=211&id_prodotto_sel="+id+"&lingua_int="+lingua+"&id_percorso="
	dettaglio_promozioni = window.open(url, "dettaglio_promozioni", "width=600, height=500, status=yes, resizable=yes, scrollbars=yes");
	dettaglio_promozioni.focus();
}

function apriSala(id_sala, id_lingua)
{
if (id_lingua==0)
	lingua = "eng"
else
	lingua = "ita"

NomeSala = new Array("carmagnola", "cavallo", "malatesta", "visconti", "colleoni", "sforza")
	finestra_link = window.open("htm/popup_sale/" + lingua + "/" + NomeSala[id_sala] + ".htm", "finestraSala" , "width=600, height =600,status=no, scrollbars=no, resizable = no")
	finestra_link.focus();
		
}

function apriPrivacy(id_lingua)
{
	if (id_lingua==0)
	lingua = "ita"
else
	lingua = "ita"
	
	finestra_documento = window.open("documents/privacy_" + lingua + ".pdf", "finestraDcoumento", "width=700, height=500, resizable=yes, scrolling=yes, status=yes")
	finestra_documento.focus();	
}

function apriLink(id_lingua)
{
	if (id_lingua == 0 )
		W = 550;
	else
		W = 410;
	finestra_link = window.open("popup_link_"+ id_lingua +".htm", "finestraLink" , "width=" + W + ", height =300,status=yes, scrollbars=yes, resizable = yes")	
}

function prenota(id_lingua)
{
	lang_array = new Array("uk", "it")
	hhotelSearchPromo('ITDCavalieri',lang_array[id_lingua],'')
}


































function CheckDateAlways(Giorno, Mese, Anno)
{
	var Today = new Date;
	if ( Giorno.length>2 || Mese.length>2 || Anno.length!=4 )
		return false;
	if ( Giorno.substr(0, 1)=="0" )
		Giorno=Giorno.substr(1, 1);
	if ( Mese.substr(0, 1)=="0" )
		Mese=Mese.substr(1, 1);
	Giorno=parseInt(Giorno);
	Mese=parseInt(Mese);
	Anno=parseInt(Anno);
	if ( Giorno<1 || Giorno>31 || Mese<1 || Mese>12 )
		return false;
	if ( Mese==2 )
	{
		if ( Giorno>29 || ( Giorno==29 && Anno%4!=0 ) )
		{
			return false;
		}
	}
	else if ( Mese==4 ||  Mese==6 ||  Mese==9 ||  Mese==11 )
	{
		if ( Giorno>30 )
		{
			return false;
		}
	}
	return true;
}
// Controlla che sia una data valida nel futuro (passata come tre stringhe), non piu' recente del giorno in corso
function CheckDateFuture(Giorno, Mese, Anno)
{
	var Today = new Date;
	if ( Giorno.length>2 || Mese.length>2 || Anno.length>4 )
		return false;
	if ( Giorno.substr(0, 1)=="0" )
		Giorno=Giorno.substr(1, 1);
	if ( Mese.substr(0, 1)=="0" )
		Mese=Mese.substr(1, 1);
	Giorno=parseInt(Giorno);
	Mese=parseInt(Mese);
	Anno=parseInt(Anno);
	if ( Giorno<1 || Giorno>31 || Mese<1 || Mese>12 || Today.getFullYear()>Anno )
		return false;

	if ( Mese==2 )
	{
		if ( Giorno>29 || ( Giorno==29 && Anno%4!=0 ) )
		{
			return false;
		}
	}
	else if ( Mese==4 ||  Mese==6 ||  Mese==9 ||  Mese==11 )
	{
		if ( Giorno>30 )
		{
			return false;
		}
	}
	if ( (Anno==Today.getFullYear() && (Today.getMonth()+1)>Mese) || (Anno==Today.getFullYear() && Mese==(Today.getMonth()+1) && Today.getDate()>Giorno) )
	{
		return false;
	}
	return true;
}
// Controlla che sia una data valida nel passato (passata come tre stringhe), non piu' recente del giorno in corso
function CheckDatePast(Giorno, Mese, Anno)
{
	var Today = new Date;
	if ( Giorno.length>2 || Mese.length>2 || Anno.length>4 )
		return false;
	if ( Giorno.substr(0, 1)=="0" )
		Giorno=Giorno.substr(1, 1);
	if ( Mese.substr(0, 1)=="0" )
		Mese=Mese.substr(1, 1);
	Giorno=parseInt(Giorno);
	Mese=parseInt(Mese);
	Anno=parseInt(Anno);
	if ( Giorno<1 || Giorno>31 || Mese<1 || Mese>12 || Anno<1900 || Anno>Today.getFullYear() )
		return false;
	if ( Mese==2 )
	{
		if ( Giorno>29 || ( Giorno==29 && Anno%4!=0 ) )
		{
			return false;
		}
	}
	else if ( Mese==4 ||  Mese==6 ||  Mese==9 ||  Mese==11 )
	{
		if ( Giorno>30 )
		{
			return false;
		}
	}
	if ( (Anno==Today.getFullYear() && Mese>(Today.getMonth()+1)) || (Anno==Today.getFullYear() && Mese==(Today.getMonth()+1) && Giorno>Today.getDate()) )
	{
		return false;
	}
	return true;
}

//Controlla se l'intervallo (passato come sei stringhe) dato e' valido, e lungo almeno un giorno (DataInizio>DataFine)
function CompareDate(Giorno1, Mese1, Anno1, Giorno2, Mese2, Anno2)
{
	if ( Giorno1.substr(0, 1)=="0" )
		Giorno1=Giorno1.substr(1, 1);
	if ( Mese1.substr(0, 1)=="0" )
		Mese1=Mese1.substr(1, 1);
	if ( Giorno2.substr(0, 1)=="0" )
		Giorno2=Giorno2.substr(1, 1);
	if ( Mese2.substr(0, 1)=="0" )
		Mese2=Mese2.substr(1, 1);
	Giorno1=parseInt(Giorno1);
	Mese1=parseInt(Mese1);
	Anno1=parseInt(Anno1);
	Giorno2=parseInt(Giorno2);
	Mese2=parseInt(Mese2);
	Anno2=parseInt(Anno2);
	if ( (Anno1>Anno2) || (Anno1==Anno2 && Mese1>Mese2) || ((Anno1==Anno2 && Mese1==Mese2) && Giorno1>Giorno2) )
	{
		return false;
	}
	return true;
}

// Controlla se la stringa passata e' costituita da cifre
function IsNum(Stringa)
{
	var i;
	for (i=0; i<Stringa.length; i++)
		if ( Stringa.charCodeAt(i)<0x0030 || Stringa.charCodeAt(i)>0x0039 )
			return false;
	return true;
}

function Controllo(id_lingua)
{	
if (id_lingua==0)
{
		vNomeAzienda = "Enter your company";
		vNome = "Enter your name"; 
		vCognome = "Enter your surname";
		vMail= "Enter your e-mail address";
		vCheckMail = "Check your e-mail address";
		vCorpo = "There is no message in the provided field!";	
}
else
{
		vNomeAzienda = "Manca il nome dell'azienda";
		vNome = "Manca il nome";
		vCognome = "Manca il cognome";
		vMail= "Manca l'indirizzo e-mail";
		vCheckMail = "Controlla l'indirizzo email inserito";
		vCorpo = "Attenzione! Il corpo della richiesta è vuoto";
}

	Form=document.forms['FormRichiesta'];
	if(Form.elements['NomeAzienda'].value=="")
	{
		alert (vNomeAzienda);
		Form.elements['NomeAzienda'].focus();
		return false;
	}
	if(Form.elements['Nome'].value=="")
	{
		alert (vNome);
		Form.elements['Nome'].focus();
		return false;
	}	
	if(Form.elements['Cognome'].value=="")
	{
		alert (vCognome);
		Form.elements['Cognome'].focus();
		return false;
	}
	
	Email = Form.elements['Email'];
	if( (Email.value=="") )
	{	
					alert (vMail);
					Email.focus();
					return false;
	}
	else
	{
		ValidaMail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		if (!( ValidaMail.test(Email.value) ) )
		{
			alert(vCheckMail);
			Email.focus();
			return false;
		}
	}
	if(Form.elements['Corpo'].value=="")
	{
		alert (vCorpo);
		Form.elements['Corpo'].focus();
		return false;
	}
	
}
