// JavaScript Document
function browser(){
	if(window.navigator.appName=="Microsoft Internet Explorer"){
		return 1;
	}else{
		return 0;
	}
}

function menuMouseOver(obj){
	if(ie){
		document.all(obj.id).style.backgroundColor="#FFFFAA";
	}else{
		obj.style.backgroundColor="#FFFFAA";
	}
}

function menuMouseOut(obj){
	if(ie){
		document.all(obj.id).style.backgroundColor="#FFFFCC";
	}else{
		obj.style.backgroundColor="#FFFFCC";
	}
}

function verificaform(){
		error=0;
		msg="";
		if(document.hpa.nome.value==""){
			error=1;
                        document.hpa.nome.style.backgroundColor = 'yellow';
			//msg="Non � stato indicato alcun nome!\n";
		}
		if(document.hpa.cognome.value==""){
			error=1;
                        document.hpa.cognome.style.backgroundColor = 'yellow';
			//msg+="Non � stato indicato alcun cognome!\n";
		}				
		if(document.hpa.telefono.value==""){
			error=1;
                        document.hpa.telefono.backgroundColor = 'yellow';
			//msg+="Non � stato indicato l'indirizzo e-mail!\n";
		}
                if(document.hpa.cellulare.value==""){
			error=1;
                        document.hpa.cellulare.backgroundColor = 'yellow';
			//msg+="Non � stato indicato l'indirizzo e-mail!\n";
		}
                if(document.hpa.email.value==""){
			error=1;
                        document.hpa.nome.email.backgroundColor = 'yellow';
			//msg+="Non � stato indicato l'indirizzo e-mail!\n";
		}
		if (!error){
			Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		   if (Filtro.test(document.hpa.email.value)){
			  document.hpa.submit();
		   }else{
			alert("L'indirizzo e-mail indicato non � corretto!");	   
		   }
		}
}

function verificaformpren(){
		error=0;
		msg="";
		if(document.prenotazioni.villa.value==""){
			error=1;
			document.prenotazioni.villa.style.backgroundColor = 'yellow';
		}
                if(document.prenotazioni.dal.value==""){
			error=1;
			document.prenotazioni.dal.style.backgroundColor = 'yellow';
		}
                if(document.prenotazioni.al.value==""){
			error=1;
			document.prenotazioni.al.style.backgroundColor = 'yellow';
		}
                if(document.prenotazioni.agenzia.value==""){
			error=1;
			document.prenotazioni.agenzia.style.backgroundColor = 'yellow';
		}
                if(document.prenotazioni.nome.value==""){
			error=1;
			document.prenotazioni.nome.style.backgroundColor = 'yellow';
		}
		if(document.prenotazioni.telefono.value==""){
			error=1;
			document.prenotazioni.telefono.style.backgroundColor = 'yellow';
		}
		if(document.prenotazioni.email.value==""){
			error=1;
			document.prenotazioni.email.style.backgroundColor = 'yellow';
		}
		if (!error){
			Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		   if (Filtro.test(document.prenotazioni.email.value)){
			  document.prenotazioni.submit();
		   }else{
			document.prenotazioni.email.style.backgroundColor = 'yellow';
		   }
		}
}

function showTable(obj){
	obj=document.getElementById(obj);
	if(obj.style.display=="block"){
		obj.style.display="none";
	}else{
		obj.style.display="block";
	}
}

function hideTable(obj){
	obj=document.getElementById(obj);
	obj.style.display="none";
}

function mostraImmagine(img,box, w){
	if(w){
		nw = 'width="'+w+'"';
	}else{
		nw = '';
	}
	boximg = document.getElementById(box);	

	boximg.innerHTML = '<div style="width:'+w+'px;" class="imgvilla"><div style="float:right;width:15px;height:15px;border:solid 1px #663300; background-color:#FFF6C5; color:#663300; text-align:center;font-family: Arial;font-weight:bold;" onClick="nascondiImmagine()" onMouseOver="this.style.cursor=\'pointer\'">X</div><img src="'+img+'" '+nw+'><div>';	
}


function nascondiImmagine(){
	boximg.innerHTML = '';	
}

function mostraLocation(img,box){
	boximg = document.getElementById(box);	
	boximg.innerHTML = '<img src="'+img+'" width="150">';	
}

function attivaCasella(lingua){
	localita = document.getElementById('localita'+lingua);
	esterni = document.getElementById('esterni'+lingua);
	descrizione = document.getElementById('descrizioni'+lingua);
	if(localita.disabled){
		localita.disabled = false;
		esterni.disabled = false;
		descrizione.disabled = false;
	}else{
		localita.disabled = true;
		esterni.disabled = true;
		descrizione.disabled = true;
	}
}

function segnaMeseCompleto(mese){
	//	alert(mese);
	nome = 'disp'+mese+'[]';
	caselle = document.getElementsByName(nome);
	
	for(i=0; i<caselle.length; i++){
		caselle.item(i).checked=true;
	}
}

var ie=browser();
var boximg;