// JavaScript Document


var win= null;

function NewWindow(mypage,myname,w,h,scroll){
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=no,location=no,status=no,menubar=no,resizable=no,dependent=no'
	win=window.open(mypage,myname,settings)
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

function SubThis(val) {
	val.submit();
	return true
}

var foto01, foto02;
if (document.images) {
	foto01 = new Image(22,14);
	foto01.src = "images/over.gif"; 
	foto02 = new Image(22,14);
	foto02.src = "images/spacer_2x2_trasp.gif"; 
}

function fotochange(base,id) {
	if (document.images) {
		//document.images.fotoc.src = "apartaments/<%=app%>/"+id+".jpg";
		over = eval("document.images."+base);
		over.src = eval("foto"+id+".src");
	}
}
function fotochange2(base,id) {
	if (document.images) {
		//document.images.fotogal.src = "images/"+id;
		foto = new Image(130,24);
		foto.src = "images/"+id; 
		over = eval("document.images."+base);
		over.src = foto.src;
	}
}
function Preload() {
	if (document.images) {
		foto01 = new Image(22,14);
		foto01.src = "images/over.gif"; 
		foto02 = new Image(22,14);
		foto02.src = "images/spacer_2x2_trasp.gif"; 
	}
return
}
function validSearch(mioform) {
	var str,strS,count,lun,richiedichiave;
	var theform = eval('document.'+mioform+'');
	//alert(theform.name);
	richiedichiave = true;
	
	if (richiedichiave && theform.localita.options[theform.localita.selectedIndex].value == 0) {
		richiedichiave = true;
	}else{
		richiedichiave = false;
	}
	if (richiedichiave && theform.struttura.options[theform.struttura.selectedIndex].value == 0) {
		richiedichiave = true;
	}else{
		richiedichiave = false;
	}
	if (richiedichiave && theform.stelle.options[theform.stelle.selectedIndex].value == 0) {
		richiedichiave = true;
	}else{
		richiedichiave = false;
	}
	/*//if (isNaN(theform.fasciaprezzo.value)) {
			//richiedichiave = true;
	//}else{
		if (theform.fasciaprezzo.value == 0)
			richiedichiave = true;
		}else{
			richiedichiave = false;
		}
	//}*/
	//alert(richiedichiave);
	if (richiedichiave) {
		count=0;
		str = theform.chiave.value;
		strS=str.split(" ");
		lun=strS.length;
		if (lun > 0) {
			for (var i=0; i < lun; i++) {
				if (strS[i].length >= 3) {
					count=count+1;
				}
			}
		}
		if (count < 1) {
			
				alert('Length min. 3 digits.');
			
			return false;
		}else{
			return true;
		}
	}else{
		return true;
	}		
}

function controllaRichiesta(item)
{
	linguaSel="en"
	codicesiurezza1=item
	codicesiurezza2=document.formMail.captcha.value
	nome=document.formMail.nome.value
	email=document.formMail.email.value
	tipo=document.formMail.tipo.value
	//data1=document.formMail.data1.value
	//data2=document.formMail.data2.value
	data1=parent.dataInizio.document.formCaL.inizio.value
	data2=parent.dataFine.document.formCaL.fine.value
	
	document.formMail.data1.value=data1
	document.formMail.data2.value= data2
	//alert(linguaSel)
	//alert(data1)
	//alert(nome +"  " + email +"  " + tipo +"  " + data1 +"  " +data2)
	
	if (nome=="")
	{
		if (linguaSel=="it")
				{
					alert("Attenzione inserisci il campo nome")
				}
		else	{
				alert("Attention insert your name")
				}
	}
	else
	{
		if (email=="")
		{
				if (linguaSel=="it")
				{
					alert("Attenzione inserisci il campo email")
				}
				else	{
				alert("Attention insert your email")
				}
		}
		else
			if (tipo=="-")
			{
				if (linguaSel=="it")
				{
				alert("Attenzione selezionare il tipo di alloggio")
				}
				else	{
				alert("Attention insert Accommodation")
				}
			}
			else
			{
				if (data1=="")
				{
						if (linguaSel=="it")
							{
								alert("Attenzione inserire la data inizio soggiorno")
							}
						else	{
						alert("Attention insert Arrival")
						}
				}
				else
				{
					if (data2=="")
					{	
						if (linguaSel=="it")
							{
								alert("Attenzione inserire la data fine soggiorno")
								}
								else	{
								alert("Attention insert Departure")
								}
					}	
					else
					{
							if (codicesiurezza1==codicesiurezza2)
							{
							//alert("ok")
								document.formMail.submit()
							}
							else
							{
									if (linguaSel=="it")
									{
										alert("Attenzione verificare i codici di sicurezza")
									}
									else	{
										alert("Attention insert secure code")
									}
							}
							
					}
				}
			}
	}
	
	
}