// JavaScript Document
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;

function change_foto(nome) {
	document.getElementById('foto').src='bilocale/'+nome;
}
function change_quadrim(type) {
	var div1 = document.getElementById("quadrimestre1");
	var div2 = document.getElementById("quadrimestre2");
	var div3 = document.getElementById("quadrimestre3");
	if(type == "r1") {
		div1.style.display='none';
		div2.style.display='block';
		div3.style.display='none';
	}
	if(type == "r2") {
		div1.style.display='none';
		div2.style.display='none';		
		div3.style.display='block';
	}
	if(type == "l1") {
		div1.style.display='block';
		div2.style.display='none';		
		div3.style.display='none';
	}	
	if(type == "l2") {
		div1.style.display='block';
		div2.style.display='none';		
		div3.style.display='none';
	}
}
function aggiorna_giorno_arrivo(gg,mm,aa) {
	if(document.prenota.data_arrivo.value.length==0) {
		document.prenota.data_arrivo.value=gg+"/"+mm+"/"+aa;
		document.getElementById('data_arrivo').style.border='1px solid #ff0000';
		document.getElementById('data_partenza').style.border='1px solid #ff0000';
		document.getElementById('data_partenza').style.background='#F3B59C';
		document.getElementById('data_arrivo').style.border='1px solid #ffffff';
	} else {
		document.prenota.data_partenza.value=gg+"/"+mm+"/"+aa;
		document.getElementById('data_partenza').style.border='1px solid #ffffff';
		document.getElementById('data_partenza').style.background='#FFDACB';
	}
}
function resetdate() {
	document.prenota.data_arrivo.value='';
	document.prenota.data_partenza.value='';
	document.getElementById('data_partenza').style.border='1px solid #ffffff';
	document.getElementById('data_partenza').style.background='#FFDACB';
}
function checkform(lingua) {
	var msg_err = "";
	var dataarrivo = document.prenota.data_arrivo.value;
	var datapartenza = document.prenota.data_partenza.value;
	if(dataarrivo.length==0 || datapartenza.length==0) {
		if(lingua == 'ita')
			msg_err += " - Inserisci il giorno di arrivo e il giorno di partenza\n";
		else if(lingua == 'eng')
			msg_err += " - Please, enter check-in date and check-out date\n";
		else if(lingua == 'esp')
			msg_err += " - Selecciona la fecha de llegada y la fecha de partida\n";			
		document.prenota.data_arrivo.focus();
	} else {
		gg_mm_aa_arr = dataarrivo.split('/');
		gg_mm_aa_par = datapartenza.split('/');
		dataarrivo_ = new Date(gg_mm_aa_arr[2],gg_mm_aa_arr[1],gg_mm_aa_arr[0]);
		datapartenza_ = new Date(gg_mm_aa_par[2],gg_mm_aa_par[1],gg_mm_aa_par[0]);
		dataarrivoMillisec = dataarrivo_.getTime();
		datapartenzaMillisec = datapartenza_.getTime();
		if(datapartenzaMillisec<=dataarrivoMillisec){
			if(lingua == 'ita')
				msg_err += " - Il giorno di partenza non è corretto perché antecedente o uguale al giorno di arrivo\n";
			else if(lingua == 'eng')
				msg_err += " - The check-in date must be before the check-out date\n";
			else if(lingua == 'esp')
				msg_err += " - La fecha de llegada tiene que ser anterior a la fecha de partida\n";				
			document.prenota.data_partenza.focus();
			} 
			/*else 	if(Math.ceil((datapartenzaMillisec - dataarrivoMillisec)/(1000*60*60*24))<3){
			if(lingua == 'ita')
				msg_err += " - Il periodo minimo di soggiorno è di tre giorni\n";
			else if(lingua == 'eng')
				msg_err += " - Minimum period must be three days \n";
			else if(lingua == 'esp')
				msg_err += " - El periodo mìnimo de estancia es de tres dìas\n";
				document.prenota.data_partenza.focus();
			}*/
	}
	if(document.prenota.nome.value.length==0) {
		if(lingua == 'ita')
			msg_err += " - Cognome e nome sono obbligatori\n";
		else if(lingua == 'eng')
			msg_err += " - Enter the name and surname\n";
		else if(lingua == 'esp')
			msg_err += " - Escribe nombre y apellido\n";		
		document.prenota.nome.focus();
	}
	if(document.prenota.email.value.length==0) {
		if(lingua == 'ita')
			msg_err += " - L'e-mail è obbligatoria\n";
		else if(lingua == 'eng')
			msg_err += " - Enter the e-mail\n";
		else if(lingua == 'esp')
			msg_err += " - Escribe el e-mail\n";
		document.prenota.nome.focus();
	}
	if(document.prenota.telefono.value.length==0) {
		if(lingua == 'ita')
			msg_err += " - Il telefono è obbligatorio\n";
		else if(lingua == 'eng')
			msg_err += " - Enter the phone number\n";
		else if(lingua == 'esp')
			msg_err += " - Escribe el telefono\n";		
		document.prenota.telefono.focus();
	}
	if(!document.prenota.autorizzo.checked) {
		if(lingua == 'ita')
			msg_err += " - Dai l'autorizzazione al trattamento dei dati\n";
		else if(lingua == 'eng')
			msg_err += " - You must consent the treatment of your personal data\n";
		else if(lingua == 'esp')
			msg_err += " - Da la autorizociòn al tratamiento de datos\n";		
	}
	if(msg_err.length>0) {
		alert(msg_err);
		return false;
	} else
		return true;
}
function checkforminfo(lingua) {
	var msg_err = "";	
	var nome = document.info.nome;
	var email = document.info.email;
	if(nome.value.length==0) {
		if(lingua == 'ita')
			msg_err += " - Cognome e nome sono obbligatori\n";
		else if(lingua == 'eng')
			msg_err += " - Enter the name and surname\n";
		else if(lingua == 'esp')
			msg_err += " - Escribe nombre y apellido\n";		
		nome.focus();
	}	
	if(email.value.length==0) {
			if(lingua == 'ita')
			msg_err += " - L'e-mail è obbligatoria\n";
		else if(lingua == 'eng')
			msg_err += " - Enter the e-mail\n";
		else if(lingua == 'esp')
			msg_err += " - Escribe el e-mail\n";
		email.focus();
	}	
	if(msg_err.length>0) {
		alert(msg_err);
		return false;
	} else
		return true;	
}

function hiddenfoto() {
	document.getElementById('showfoto').style.display='none'
}
function show(image, id_ap, dominio) {
var a = document.getElementById(image);

/*var f = new Array()
for(i=1;i<=num_foto;i++) {
	f[i] = "foto/apartments/"+id_ap+"/apartment"+i+".jpg";
}
f[1] = "foto/apartments/1/1.jpg";
f[2] = "/images/image2.jpg";
f[3] = "/images/image3.jpg";
f[4] = "/images/image4.jpg";
f[5] = "/images/image5.jpg";
f[6] = "/images/image6.jpg";
f[7] = "/images/image7.jpg";
f[8] = "/images/image8.jpg";
f[9] = "/images/image9.jpg";
f[10] = "/images/image10.jpg";
f[11] = "/images/image11.jpg";
f[12] = "/images/image12.jpg";
f[13] = "/images/image13.jpg";
f[14] = "/images/image14.jpg";
f[15] = "/images/image15.jpg";
f[16] = "/images/image16.jpg";
f[17] = "/images/image17.jpg";
f[18] = "/images/image18.jpg";*/

//var url = f[image];

var url = dominio+"/foto/apartments/"+id_ap+"/"+image;
a.setAttribute('href', url);
myLightbox.start(a);
}
