function advsrc_adm(){
	if (document.getElementById("div_advsrc")) {
		
		if (document.getElementById("div_advsrc").style.display=='none'){
		document.getElementById("div_advsrc").style.display='block';
		document.getElementById("advsrc").value="1";
		}
		else{
		document.getElementById("advsrc").value="";
		document.getElementById("div_advsrc").style.display='none';
		document.getElementById("AC").checked=false;
		document.getElementById("TV").checked=false;
		document.getElementById("SAT").checked=false;
		document.getElementById("VCR").checked=false;
		document.getElementById("HI").checked=false;
		document.getElementById("TEL").checked=false;
		document.getElementById("Terrace").checked=false;
		document.getElementById("Lift").checked=false;
		document.getElementById("LVT").checked=false;
		document.getElementById("Dishwasher").checked=false;
		document.getElementById("pool").checked=false;
		document.getElementById("PAR").checked=false;
		}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; 
	document.MM_sr=new Array; 
	for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){
			document.MM_sr[j++]=x; 
			if(!x.oSrc) 
			x.oSrc=x.src; 
			x.src=a[i+2];
		}
}



function FullInfo(ID_IMM,page)
{	if(document.getElementById("esearch")){
	document.getElementById("ID_IM").value=ID_IMM;
	document.getElementById("esearch").action=page;
	document.getElementById("esearch").submit();
	}
}
//-->

function order_by(value,url)
{
document.getElementById("order_by").value=value;
document.getElementById("esearch").action=url;
document.getElementById("esearch").submit();
}

function paging(page,order,url){
document.getElementById('esearch').pg.value=page;
document.getElementById('esearch').order_by.value=order;
document.getElementById('esearch').action=url;
document.getElementById('esearch').submit();
}

//modulo_richiesta
function Form_Validator_richiesta(theForm){
  if ((theForm.N_persons.value=="") | isNaN(theForm.N_persons.value)){
    alert("Please enter a numeric value for the \"Number of persons\" field.");
    theForm.N_persons.focus();
    return false;
  }
	if ( !isDate(theForm.DATE_IN2.value) ){
    alert("Please enter correct value for the \"From\" field.");
    theForm.DATE_IN2.focus();
    return false;
  }
	if ( !isDate(theForm.DATE_OUT2.value) ){
    alert("Please enter correct value for the \"to\" field.");
    theForm.DATE_OUT2.focus();
    return false;
  }
	if ( !CompareDate(theForm.DATE_IN2.value,theForm.DATE_OUT2.value) ){
    alert("\"From\" date must be later then \"to\" date.");
    theForm.DATE_OUT2.focus();
    return false;
  }
  if (theForm.surname.value=="" )
	{
	alert("Please enter your Surname");
	  theForm.surname.focus();
	  return (false);
	} 
  if (!isEmail (theForm.email.value)){
    alert("Please enter correct value for the \"email\" field.");
    theForm.email.focus();
    return false;
  }
  return true;
}
//fine modulo_richiesta

//modulo ricerca
function Form_Validator(theForm)
{
	if ((theForm.Per.value=="") | isNaN(theForm.Per.value)){
		alert("Please enter a numeric value for the \"Number of persons\" field.");
		theForm.Per.focus();
		return false;
	}
	//if ((theForm.ZONA.value=="") | isNaN(theForm.ZONA.value)){
	//		alert("Please choose an area.");
	//		theForm.ZONA.focus();
	//	return false;
	//} 	
 	if ( (!isDate(theForm.DATE_IN.value)) ){
      alert("Please enter correct value for the \"Check-In Date\" field.");
      theForm.DATE_IN.focus();
      return false;
    }
 	if ( (!isDate(theForm.DATE_OUT.value) ) ){
      alert("Please enter correct value for the \"Check-Out Date\" field.");
      theForm.DATE_OUT.focus();
      return false;
    }
	if (theForm.DATE_IN.value != "" && theForm.DATE_OUT.value != "" ){
  		if ( !CompareDate(theForm.DATE_IN.value,theForm.DATE_OUT.value) ){
			alert("\"Check-Out Date\" must be later then \"Check-In Date\".");
			theForm.DATE_OUT.focus();
			return false;
		}
		CalculateNights(theForm.Nights,theForm.DATE_IN,theForm.DATE_OUT);
		return true;
	}
	
}
//fine modulo ricerca





//modulo registrazione
function Form_Validator_registrazione(theForm){
	if ( theForm.username.value==""){
    	alert(" Please enter correct Login.");
    	theForm.username.focus();
    	return false;
	}
	if (!isEmail (theForm.username.value)){
    	alert(" Entered Login is not correct. \n It must be a email address. ");
    	theForm.username.focus();
    	return (false);
  	}
	if ( theForm.password.value==""){
    	alert(" Please enter correct Password.");
    	theForm.password.focus();
    	return false;
	}
	theForm.IdClient.value="";
	//theForm.submit();
	return true;
}
//
function NewClient(theForm){
	theForm.IdClient.value="0";
	theForm.submit();
}
function Reminder(){
	if(document.getElementById('registration').username.value==""){
		alert(" Please enter correct Login.");
		document.getElementById('registration').username.focus();
		return;
	}
	document.getElementById('reminder').email.value=document.getElementById('registration').username.value;
	document.getElementById('reminder').submit();
}
//fine modulo registrazione


//modulo prenotazione
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){
  //alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)
  }
  document.MM_returnValue = (s=='');
}

function FrontPage_Form1_Validator_prenotazione(theForm)
{

  if (theForm.name.value == "")
  {
    alert("Inserire un valore per il campo \"Name\".");
    theForm.name.focus();
    return (false);
  }

  if (theForm.name.value.length < 1)
  {
    alert("Inserire almeno 1 caratteri nel campo \"Name\".");
    theForm.name.focus();
    return (false);
  }

  if (theForm.name.value.length > 50)
  {
    alert("Inserire al massimo 50 caratteri nel campo \"Name\".");
    theForm.name.focus();
    return (false);
  }

  if (theForm.surname.value == "")
  {
    alert("Inserire un valore per il campo \"Surname\".");
    theForm.surname.focus();
    return (false);
  }

  if (theForm.surname.value.length < 1)
  {
    alert("Inserire almeno 1 caratteri nel campo \"Surname\".");
    theForm.surname.focus();
    return (false);
  }

  if (theForm.surname.value.length > 70)
  {
    alert("Inserire al massimo 70 caratteri nel campo \"Surname\".");
    theForm.surname.focus();
    return (false);
  }
YY_checkform('FrontPage_Form1','Date_birth','#^\([0-9][0-9]\)\/\([0-9][0-9]\)\/\([0-9]{4}\)$#1#2#3','3','Field \'data\' is not valid.')
  if (!document.MM_returnValue){
  	alert("Please enter a correct value for the \"Date of birth\" field.");
    theForm.Date_birth.focus();
    return (false);
  }
  if (theForm.Phone.value == "")
  {
    alert("Inserire un valore per il campo \"Telephone\".");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length < 1)
  {
    alert("Inserire almeno 1 caratteri nel campo \"Telephone\".");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length > 25)
  {
    alert("Inserire al massimo 25 caratteri nel campo \"Telephone\".");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.mobilePhone.value == "")
  {
    alert("Inserire un valore per il campo \"Mobile Phone\".");
    theForm.mobilePhone.focus();
    return (false);
  }

  if (theForm.mobilePhone.value.length < 1)
  {
    alert("Inserire almeno 1 caratteri nel campo \"Mobile Phone\".");
    theForm.mobilePhone.focus();
    return (false);
  }

  if (theForm.mobilePhone.value.length > 50)
  {
    alert("Inserire al massimo 50 caratteri nel campo \"Mobile Phone\".");
    theForm.mobilePhone.focus();
    return (false);
  }

  if (theForm.Fax.value == "")
  {
    alert("Inserire un valore per il campo \"Country\".");
    theForm.Fax.focus();
    return (false);
  }

  if (theForm.Fax.value.length < 1)
  {
    alert("Inserire almeno 1 caratteri nel campo \"Country\".");
    theForm.Fax.focus();
    return (false);
  }

  if (theForm.Fax.value.length > 50)
  {
    alert("Inserire al massimo 50 caratteri nel campo \"Country\".");
    theForm.Fax.focus();
    return (false);
  }

  if (theForm.email.value == "")
  {
    alert("Inserire un valore per il campo \"E-mail\".");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 5)
  {
    alert("Inserire almeno 5 caratteri nel campo \"E-mail\".");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length > 100)
  {
    alert("Inserire al massimo 100 caratteri nel campo \"E-mail\".");
    theForm.email.focus();
    return (false);
  }
	if (theForm.password) {
		if (theForm.password.value == "")
		{
		  alert("Inserire un valore per il campo \"Password\".");
		  theForm.password.focus();
		  return (false);
		}

		if (theForm.password.value.length < 3)
		{
		  alert("Inserire almeno 3 caratteri nel campo \"Password\".");
		  theForm.password.focus();
		  return (false);
		}

		if (theForm.password.value.length > 50)
		{
		  alert("Inserire al massimo 50 caratteri nel campo \"Password\".");
		  theForm.password.focus();
		  return (false);
		}
	}
  if (theForm.Credi_card_number.value == "")
  {
    alert("Inserire un valore per il campo \"Credit Card Number\".");
    theForm.Credi_card_number.focus();
    return (false);
  }

  if (theForm.Credi_card_number.value.length < 13)
  {
    alert("Inserire almeno 13 caratteri nel campo \"Credit Card Number\".");
    theForm.Credi_card_number.focus();
    return (false);
  }

  if (theForm.Credi_card_number.value.length > 24)
  {
    alert("Inserire al massimo 24 caratteri nel campo \"Credit Card Number\".");
    theForm.Credi_card_number.focus();
    return (false);
  }

  if (theForm.meseexp.selectedIndex < 0)
  {
    alert("Selezionare una delle opzioni di \"Month Expire Date\".");
    theForm.meseexp.focus();
    return (false);
  }

  if (theForm.meseexp.selectedIndex == 0)
  {
    alert("La prima opzione di \"Month Expire Date\" non è una selezione valida. Scegliere un'altra opzione.");
    theForm.meseexp.focus();
    return (false);
  }

  if (theForm.annoexp.selectedIndex < 0)
  {
    alert("Selezionare una delle opzioni di \"Year Expire Date\".");
    theForm.annoexp.focus();
    return (false);
  }

  if (theForm.annoexp.selectedIndex == 0)
  {
    alert("La prima opzione di \"Year Expire Date\" non è una selezione valida. Scegliere un'altra opzione.");
    theForm.annoexp.focus();
    return (false);
  }
  return (true);
}
//fine modulo prenotazione

//info immobile
     function sync(){
     document.getElementById('DATE_IN').value=document.getElementById('DATE_IN2').value;
     document.getElementById('DATE_OUT').value=document.getElementById('DATE_OUT2').value;
     document.getElementById('Nights').value=document.getElementById('Nights2').value;
     document.getElementById('Per').value=document.getElementById('Per2').value;
     }
     
     
     function Form_Validator_info(theForm)
		{
			if ((theForm.Per2.value=="") | isNaN(theForm.Per2.value)){
				alert("Please enter a numeric value for the \"Number of persons\" field.");
				theForm.Per2.focus();
				return false;
			}
			
		 	if ( (!isDate(theForm.DATE_IN2.value)) ){
		      alert("Please enter correct value for the \"Check-In Date\" field.");
		      theForm.DATE_IN2.focus();
		      return false;
		    }
		 	if (!isDate(theForm.DATE_OUT2.value)){
		      alert("Please enter correct value for the \"Check-Out Date\" field.");
		      theForm.DATE_OUT2.focus();
		      return false;
		    }
			if (theForm.DATE_IN2.value != "" && theForm.DATE_OUT2.value != "" ){
		  		if ( !CompareDate(theForm.DATE_IN2.value,theForm.DATE_OUT2.value) ){
					alert("\"Check-Out Date\" must be later then \"Check-In Date\".");
					theForm.DATE_OUT2.focus();
					return false;
				}
				CalculateNights(theForm.Nights2,theForm.DATE_IN2,theForm.DATE_OUT2);
				return true;
			}
			
			
		}
//fine info immobile

function popImage(imageURL,imageTitle,pos,AutoClose,CopyRight){
	//Safari workaround
	is_safari=(navigator.userAgent.toLowerCase().indexOf("safari")!=-1)?true:false;
	safari_version=Number(navigator.userAgent.substring(navigator.userAgent.indexOf("Safari/")+7));
	if (is_safari && safari_version<300){
		var f="top=0, left=0, width="+screen.width+",height="+screen.height+" ,scrollbars=yes";
		imgWin=window.open(imageURL,'im',f);
	}
	else{
		//Based on browser set correct resize mode
		if (parseInt(navigator.appVersion.charAt(0))>=4){
			if (navigator.appName=="Netscape" || is_safari){
				var f="width="+screen.width+",height="+screen.height;	
				var rs="var iWidth=window.innerWidth;iHeight=window.innerHeight";
				var adj="0";
			}
			if(document.all){
				var f="width=150,height=150";	
				var rs = "var iWidth=document.body.clientWidth;iHeight=document.body.clientHeight;";
				if(typeof window.opera != 'undefined'){ 
					 var adj="window.outerHeight-24";
				 }
				else{
					var adj="32";
				}	 
			} 
		}
		//
		v=pos.substring(0,pos.indexOf("_"));
		h=pos.substring(pos.indexOf("_")+1);
		f+=",left=0,top=0";
		imgWin=window.open('about:blank','',f);
		imDoc=imgWin.document;
		with (imDoc){
			writeln('<html><head><title>Loading...</title>');writeln('<sc'+'ript>');
			writeln('var sdstr=\"\";window.onerror=function(){return true;}');
			writeln('function resizeWin(){');
			//If the image size is bigger then screen resize window to the screen size
			writeln('sc=(navigator.userAgent.toLowerCase().indexOf("safari")!=-1)?15:"";');
			writeln('iW=document.images[0].width;iH=document.images[0].height;sW=screen.availWidth;sH=screen.availHeight;');
			writeln('if(iW>=sW || iH>=sH){window.resizeTo(sW,sH);window.moveTo(0,0)}else{');
			writeln(rs);
			writeln('var v=\"'+v+'\";var h=\"'+h+'\";');
			writeln('switch (v){case \"top\":vPos=0;break;case \"middle\":vPos=(sH-iH-'+adj+')/2;break;case \"bottom\":vPos=sH-'+adj+'-iH'+((is_safari)?'-20':'')+';break;default: vPos=0;}');
			
			writeln('switch (h){case \"left\":hPos=0;break;case \"center\":hPos=(sW-iW)/2;break;case \"right\":hPos=sW-iW'+((is_safari)?'-20':'')+';break;default: hPos=0;}');
			writeln('iWidth = document.images[0].width - iWidth;iHeight = document.images[0].height - iHeight;');
			writeln('window.resizeBy(iWidth+sc, iHeight+sc);');
			writeln('window.moveBy(hPos,vPos)}}');
			writeln('function doTitle(){document.title="'+unescape(imageTitle)+'";}'+'</sc'+'ript>');
			var cT=(!AutoClose)?"":"onBlur=\"sdstr=setTimeout('window.close(this)',1000)\"";
			//Prevent closing in IE
			var fL=(!AutoClose)?"":"onfocus=\"clearTimeout(sdstr)\"";
			var safari_fix=(is_safari)?" onload='resizeWin()'":"";
			if(!CopyRight){var cr1="";var cr2=""}else{var cr1=" galleryimg=\"no\" title=\"Copyright Protected\" onmousedown=\"window.close()\" ";var cr2="oncontextmenu=\"return false\" "}
			writeln('</head><body  leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" bgcolor=\"FFFFFF\"  onload="'+ ((!is_safari)?'resizeWin();doTitle();':'')+'self.focus()" '+cT+' '+fL+' '+cr2+'>');
			writeln('<div '+fL+' align=\"center\" style=\"width:100%;height:100%;overflow:auto\"><img src="'+imageURL+'" '+cr1+safari_fix+' ></div></body></html>');
			close();
		}
	}
}

