function locality(el,loc,val){if(loc==null){loc='location';}
if(val==null){val=-1;}
str=" ";s=el.selectedIndex-1;if(s>-1){for(i=0;i<locations[s].length;i++){if(val==locations[s][i][0])str+='<option selected="selected" value="'+locations[s][i][0]+'">'+locations[s][i][1]+'</option>';else str+='<option value="'+locations[s][i][0]+'">'+locations[s][i][1]+'</option>';}
$(loc).update('<option value="-1">Select Location</option>'+str);}else{$(loc).update('<option value="-1">Select Country first</option>');}}
function priceRange(list,pr1,pr2,pricerange){if(pr1==null){pr1='pricerange1';}
if(pr2==null){pr2='pricerange2';}
if(pricerange==null){pricerange='pricerange';}
if(list.selectedIndex==0){$(pr1).selectedIndex=0;$(pr2).selectedIndex=0;$(pricerange).value=-1;}else{if(list==$(pr1)){if($(pr1).selectedIndex>=$(pr2).selectedIndex)
$(pr2).selectedIndex=$(pr1).selectedIndex;}
if(list==$(pr2)){if($(pr2).selectedIndex<=$(pr1).selectedIndex)
$(pr1).selectedIndex=$(pr2).selectedIndex;}
$(pricerange).value=$(pr1).value+','+$(pr2).value;}}
function populateBuy(name){pricerange=document.getElementById(name);for(var i=pricerange.options.length;i>0;i--)pricerange.options[i]=null;if(pricerange.name=='pricerange1')var offset=0;else var offset=1;if(pricerange.name!='pricerange2')pricerange.options[1]=new Option('\u20ac 25,000','25000');pricerange.options[2-offset]=new Option('\u20ac 50,000','50000');pricerange.options[3-offset]=new Option('\u20ac 100,000','100000');pricerange.options[4-offset]=new Option('\u20ac 150,000','150000');pricerange.options[5-offset]=new Option('\u20ac 200,000','200000');pricerange.options[6-offset]=new Option('\u20ac 250,000','250000');pricerange.options[7-offset]=new Option('\u20ac 300,000','300000');pricerange.options[8-offset]=new Option('\u20ac 350,000','350000');pricerange.options[9-offset]=new Option('\u20ac 400,000','400000');pricerange.options[10-offset]=new Option('\u20ac 450,000','450000');pricerange.options[11-offset]=new Option('\u20ac 500,000','500000');pricerange.options[12-offset]=new Option('\u20ac 550,000','550000');pricerange.options[13-offset]=new Option('\u20ac 600,000','600000');pricerange.options[14-offset]=new Option('\u20ac 650,000','650000');pricerange.options[15-offset]=new Option('\u20ac 700,000','700000');pricerange.options[16-offset]=new Option('\u20ac 750,000','750000');pricerange.options[17-offset]=new Option('\u20ac 800,000','800000');pricerange.options[18-offset]=new Option('\u20ac 900,000','900000');pricerange.options[19-offset]=new Option('\u20ac 1,000,000','1000000');if(pricerange.name!='pricerange1')pricerange.options[20-offset]=new Option('\u20ac 1,5000,00 +','1500000');}
function populateRent(name){pricerange=document.getElementById(name);for(var i=pricerange.options.length;i>0;i--)pricerange.options[i]=null;if(pricerange.name=='pricerange1')var offset=0;else var offset=1;if(pricerange.name!='pricerange2')pricerange.options[1]=new Option('\u20ac 50','50');pricerange.options[2-offset]=new Option('\u20ac 100','100');pricerange.options[3-offset]=new Option('\u20ac 150','150');pricerange.options[4-offset]=new Option('\u20ac 200','200');pricerange.options[5-offset]=new Option('\u20ac 250','250');pricerange.options[6-offset]=new Option('\u20ac 300','300');pricerange.options[7-offset]=new Option('\u20ac 350','350');pricerange.options[8-offset]=new Option('\u20ac 400','400');pricerange.options[9-offset]=new Option('\u20ac 450','450');pricerange.options[10-offset]=new Option('\u20ac 500','500');pricerange.options[11-offset]=new Option('\u20ac 550','550');pricerange.options[12-offset]=new Option('\u20ac 600','600');pricerange.options[13-offset]=new Option('\u20ac 650','650');pricerange.options[14-offset]=new Option('\u20ac 700','700');pricerange.options[15-offset]=new Option('\u20ac 750','750');pricerange.options[16-offset]=new Option('\u20ac 800','800');pricerange.options[17-offset]=new Option('\u20ac 850','850');pricerange.options[18-offset]=new Option('\u20ac 900','900');pricerange.options[19-offset]=new Option('\u20ac 950','950');pricerange.options[20-offset]=new Option('\u20ac 1000','1000');pricerange.options[21-offset]=new Option('\u20ac 2000','2000');pricerange.options[22-offset]=new Option('\u20ac 3000','3000');pricerange.options[23-offset]=new Option('\u20ac 4000','4000');pricerange.options[24-offset]=new Option('\u20ac 5000','5000');pricerange.options[25-offset]=new Option('\u20ac 6000','6000');if(name!='pricerange1')pricerange.options[26-offset]=new Option('\u20ac 7000 +','7000');}
function populateHoliday(name){pricerange=document.getElementById(name);for(var i=pricerange.options.length;i>0;i--)pricerange.options[i]=null;if(pricerange.name=='pricerange1')var offset=0;else var offset=1;if(pricerange.name!='pricerange2')pricerange.options[1]=new Option('\u20ac 10','10');pricerange.options[2-offset]=new Option('\u20ac 25','25');pricerange.options[3-offset]=new Option('\u20ac 50','50');pricerange.options[4-offset]=new Option('\u20ac 75','75');pricerange.options[5-offset]=new Option('\u20ac 100','100');pricerange.options[6-offset]=new Option('\u20ac 125','125');pricerange.options[7-offset]=new Option('\u20ac 150','150');pricerange.options[8-offset]=new Option('\u20ac 175','175');pricerange.options[9-offset]=new Option('\u20ac 200','200');pricerange.options[10-offset]=new Option('\u20ac 225','225');pricerange.options[11-offset]=new Option('\u20ac 250','250');pricerange.options[12-offset]=new Option('\u20ac 300','300');pricerange.options[13-offset]=new Option('\u20ac 350','350');pricerange.options[14-offset]=new Option('\u20ac 400','400');pricerange.options[15-offset]=new Option('\u20ac 450','450');pricerange.options[16-offset]=new Option('\u20ac 500','500');pricerange.options[17-offset]=new Option('\u20ac 550','550');pricerange.options[18-offset]=new Option('\u20ac 600','600');pricerange.options[19-offset]=new Option('\u20ac 650','650');pricerange.options[20-offset]=new Option('\u20ac 700','700');pricerange.options[21-offset]=new Option('\u20ac 750','750');pricerange.options[22-offset]=new Option('\u20ac 800','800');pricerange.options[23-offset]=new Option('\u20ac 850','850');pricerange.options[24-offset]=new Option('\u20ac 900','900');pricerange.options[25-offset]=new Option('\u20ac 950','950');pricerange.options[26-offset]=new Option('\u20ac 1000','1000');if(name!='pricerange1')pricerange.options[27-offset]=new Option('\u20ac 1000+','1001');}
function populate_pw(name,type,v){pricerange=document.getElementById(name);for(var i=pricerange.options.length;i>0;i--)pricerange.options[i]=null;if(type==1){pricerange.options[1]=new Option('Less than \u20ac 25,000','25000');pricerange.options[2]=new Option('Less than \u20ac 50,000','50000');pricerange.options[3]=new Option('Less than \u20ac 100,000','100000');pricerange.options[4]=new Option('Less than \u20ac 150,000','150000');pricerange.options[5]=new Option('Less than \u20ac 200,000','200000');pricerange.options[6]=new Option('Less than \u20ac 250,000','250000');pricerange.options[7]=new Option('Less than \u20ac 300,000','300000');pricerange.options[8]=new Option('Less than \u20ac 350,000','350000');pricerange.options[9]=new Option('Less than \u20ac 400,000','400000');pricerange.options[10]=new Option('Less than \u20ac 450,000','450000');pricerange.options[11]=new Option('Less than \u20ac 500,000','500000');pricerange.options[12]=new Option('Less than \u20ac 550,000','550000');pricerange.options[13]=new Option('Less than \u20ac 600,000','600000');pricerange.options[14]=new Option('Less than \u20ac 650,000','650000');pricerange.options[15]=new Option('Less than \u20ac 700,000','700000');pricerange.options[16]=new Option('Less than \u20ac 750,000','750000');pricerange.options[17]=new Option('Less than \u20ac 800,000','800000');pricerange.options[18]=new Option('Less than \u20ac 900,000','900000');pricerange.options[19]=new Option('Less than \u20ac 1,000,000','1000000');pricerange.options[20]=new Option('\u20ac 1,0000,00 +','1000001');}else{pricerange.options[1]=new Option('Less than \u20ac 50','50');pricerange.options[2]=new Option('Less than \u20ac 100','100');pricerange.options[3]=new Option('Less than \u20ac 150','150');pricerange.options[4]=new Option('Less than \u20ac 200','200');pricerange.options[5]=new Option('Less than \u20ac 250','250');pricerange.options[6]=new Option('Less than \u20ac 300','300');pricerange.options[7]=new Option('Less than \u20ac 350','350');pricerange.options[8]=new Option('Less than \u20ac 400','400');pricerange.options[9]=new Option('Less than \u20ac 450','450');pricerange.options[10]=new Option('Less than \u20ac 500','500');pricerange.options[11]=new Option('Less than \u20ac 550','550');pricerange.options[12]=new Option('Less than \u20ac 600','600');pricerange.options[13]=new Option('Less than \u20ac 650','650');pricerange.options[14]=new Option('Less than \u20ac 700','700');pricerange.options[15]=new Option('Less than \u20ac 750','750');pricerange.options[16]=new Option('Less than \u20ac 800','800');pricerange.options[17]=new Option('Less than \u20ac 850','850');pricerange.options[18]=new Option('Less than \u20ac 900','900');pricerange.options[19]=new Option('Less than \u20ac 950','950');pricerange.options[20]=new Option('Less than \u20ac 1000','1000');pricerange.options[21]=new Option('Less than \u20ac 2000','2000');pricerange.options[22]=new Option('Less than \u20ac 3000','3000');pricerange.options[23]=new Option('Less than \u20ac 4000','4000');pricerange.options[24]=new Option('Less than \u20ac 5000','5000');pricerange.options[25]=new Option('Less than \u20ac 6000','6000');pricerange.options[26]=new Option('\u20ac 6000 +','6001');}
for(var i=0;i<pricerange.options.length;i++)if(pricerange.options[i].value==v)pricerange.options[i].selected=true;}
function isblank(s){for(var i=0;i<s.value.length;i++){var c=s.value.charAt(i);if((c!=' ')&&(c!='\n')&&(c!='\t'))return false;}
return true;}
function checkemail(email_var){if(isblank(email_var))return errorMessage(email_var,'Please enter your Email');if(!isblank(email_var))
{var valid=true;var atcount=0;var email=email_var.value;var email_length=email_var.value.length;for(index=0;index<email_length;index++)
{if((email.substring(index,index+1)==":")||(email.substring(index,index+1)==",")||(email.substring(index,index+1)=="'")||(email.substring(index,index+1)==" "))
{valid=false;}}
for(i=0;i<email_length;i++)
{if(email.substring(i,i+1)=="@")
{++atcount;if(email.substring(i-1,i)==".")
valid=false;if(email.substring(i+1,i+2)==".")
valid=false;}}
if(email.substring(email_length-1,email_length)=="@")
valid=false;if(email.substring(email_length-1,email_length)==".")
valid=false;if(email.substring(0,1)=="@")
valid=false;if(email.substring(0,1)==".")
valid=false;if(email_var.value.indexOf(".")==-1)
valid=false;if(atcount>1||atcount==0)
valid=false;if(!valid){return errorMessage(email_var,'Please enter a correct Email');}}}
var errors=0;function errorMessage(el,message,newline){if(newline)line="<BR>";else line='';$(el).up().down('label').insert('<span class="error">&nbsp;&nbsp;'+line+'['+message+']</span>');errors=errors+1;}
function clearErrors(form){spans=$(form).select('span[class="error"]');for(i=0;i<spans.length;i++)spans[i].remove();errors=0;}
function checkContact(form){clearErrors(form);if(isblank(form.name))errorMessage(form.name,'Please enter your Name');checkemail(form.email);if(isblank(form.number))errorMessage(form.number,'Please enter a Contact Number');if(isblank(form.message))errorMessage(form.message,'Please enter a Message');if(errors)return false;}
function checkSignUp(form){clearErrors(form);if(isblank(form.name))errorMessage(form.name,'Please enter your Name');if(isblank(form.surname))errorMessage(form.surname,'Please enter your Surame');checkemail(form.email);if(isblank(form.password))errorMessage(form.password,'Please enter a Password');if(isblank(form.confirm_password))errorMessage(form.confirm_password,'Please re-type Password');if(form.password.value!=form.confirm_password.value)errorMessage(form.confirm_password,'Passwords do not match!');if(errors)return false;}
function checkLogin(form){clearErrors(form);checkemail(form.log_email);if(isblank(form.log_password))errorMessage(form.log_password,'Please enter a Password');if(isblank(form.seller_id))errorMessage(form.seller_id,'Please enter Seller ID');if(errors)return false;}
function checkForgotPassword(form){clearErrors(form);checkemail(form.email);if(errors)return false;}
function checkPersonalDetails(form){clearErrors(form);if(isblank(form.name))errorMessage(form.name,'Please enter your Name');if(isblank(form.surname))errorMessage(form.surname,'Please enter your Surame');if(form.type.selectedIndex==0)errorMessage(form.type,'Please select an option');if(isblank(form.mobile))errorMessage(form.mobile,'Please enter your Mobile Number');if(isblank(form.phone))errorMessage(form.phone,'Please enter your Phone Number');if(isblank(form.town))errorMessage(form.town,'Please enter your Town / City');if(errors)return false;}
function checkShortLets(form){clearErrors(form);if(isblank(form.name))errorMessage(form.name,'Please enter your Name');checkemail(form.email);if(isblank(form.numofpeople))errorMessage(form.numofpeople,'Required');var d1;var d2;if(isblank(form.arrival))errorMessage(form.arrival,'Please select Date');else d1=new Date(form.arrival.value.replace(/-/gi,"/"));if(isblank(form.departure))errorMessage(form.departure,'Please select Date');else d2=new Date(form.departure.value.replace(/-/gi,"/"));if(d1>d2){alert('Please make sure that your return date\nis not earlier than your arrival date.');return false;}
if(errors)return false;}
function checkLoginDetails(form){clearErrors(form);checkemail(form.email);if(isblank(form.password))errorMessage(form.password,'Please enter a Password');if(isblank(form.confirm_password))errorMessage(form.confirm_password,'Please re-type Password',true);if(form.password.value!=form.confirm_password.value)errorMessage(form.confirm_password,'Passwords do not match!',true);if(errors)return false;}
function add_to_favs(type,web_ref){var params='web_ref='+web_ref+'&add='+type;var myAjax=new Ajax.Updater('client_favorites','/ajax/favorites.php',{method:'get',parameters:params});}
function form_submit(form,arr){for(i=0;i<arr.length;i++){$(form).select('[name="'+arr[i][0]+'"]')[0].value=''+arr[i][1];}
$(form).submit();}
function printIT(web_ref){window.open('property-flyer.php?web_ref='+web_ref,'printwin','left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');}
function changeFrequency(e,s){window.location='process.php?t=13&search_id='+s+'&f='+e.value;}
function changeCurrency(cur){var myAjax=new Ajax.Request('/ajax/currency.php',{method:'get',parameters:'c='+cur,onSuccess:function(){if($('page_form'))$('page_form').submit();else window.location.reload(true);}});}
function favsNotLogged(e){e.checked=false;if(confirm('You must be logged in to save your favorite properties.\nWould you like to create a free account?'))window.location='./register';}
function submitSidebarForm(t){$(t).checked=true;$('country').selectedIndex=0;$('location').selectedIndex=0;$('pricerange').value=-1;$('property_type_id').selectedIndex=0;$('ref_no').value='';$('sidebar-form').submit();}
function calendar(offset,property_ref){var params='property_ref='+property_ref+'&offset='+offset;var myAjax=new Ajax.Updater('calendar','http://www.doorsrealestate.com/ajax/calendar.php',{method:'get',parameters:params});};function Yetii(){this.defaults={id:null,active:1,interval:null,wait:null,persist:null,tabclass:'tab',activeclass:'active',callback:null,leavecallback:null};this.activebackup=null;for(var n in arguments[0]){this.defaults[n]=arguments[0][n]};this.getTabs=function(){var a=[];var b=document.getElementById(this.defaults.id).getElementsByTagName('*');var c=new RegExp("(^|\\s)"+this.defaults.tabclass.replace(/\-/g,"\\-")+"(\\s|$)");for(var i=0;i<b.length;i++){if(c.test(b[i].className))a.push(b[i])}return a};this.links=document.getElementById(this.defaults.id+'-nav').getElementsByTagName('a');this.listitems=document.getElementById(this.defaults.id+'-nav').getElementsByTagName('li');this.show=function(a){for(var i=0;i<this.tabs.length;i++){this.tabs[i].style.display=((i+1)==a)?'block':'none';if((i+1)==a){this.addClass(this.links[i],this.defaults.activeclass);this.addClass(this.listitems[i],this.defaults.activeclass+'li')}else{this.removeClass(this.links[i],this.defaults.activeclass);this.removeClass(this.listitems[i],this.defaults.activeclass+'li')}}if(this.defaults.leavecallback&&(a!=this.activebackup))this.defaults.leavecallback(this.defaults.active);this.activebackup=a;this.defaults.active=a;if(this.defaults.callback)this.defaults.callback(a)};this.rotate=function(a){this.show(this.defaults.active);this.defaults.active++;if(this.defaults.active>this.tabs.length)this.defaults.active=1;var b=this;if(this.defaults.wait)clearTimeout(this.timer2);this.timer1=setTimeout(function(){b.rotate(a)},a*1000)};this.next=function(){var a=(this.defaults.active+1>this.tabs.length)?1:this.defaults.active+1;this.show(a);this.defaults.active=a};this.previous=function(){var a=((this.defaults.active-1)==0)?this.tabs.length:this.defaults.active-1;this.show(a);this.defaults.active=a};this.previous=function(){this.defaults.active--;if(!this.defaults.active)this.defaults.active=this.tabs.length;this.show(this.defaults.active)};this.gup=function(a){a=a.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var b="[\\?&]"+a+"=([^&#]*)";var c=new RegExp(b);var d=c.exec(window.location.href);if(d==null)return null;else return d[1]};this.parseurl=function(a){var b=this.gup(a);if(b==null)return null;if(parseInt(b))return parseInt(b);if(document.getElementById(b)){for(var i=0;i<this.tabs.length;i++){if(this.tabs[i].id==b)return(i+1)}}return null};this.createCookie=function(a,b,c){if(c){var d=new Date();d.setTime(d.getTime()+(c*24*60*60*1000));var e="; expires="+d.toGMTString()}else var e="";document.cookie=a+"="+b+e+"; path=/"};this.readCookie=function(a){var b=a+"=";var d=document.cookie.split(';');for(var i=0;i<d.length;i++){var c=d[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(b)==0)return c.substring(b.length,c.length)}return null};this.contains=function(a,b,c){return a.indexOf(b,c)!=-1};this.hasClass=function(a,b){return this.contains(a.className,b,' ')};this.addClass=function(a,b){if(!this.hasClass(a,b))a.className=(a.className+' '+b).replace(/\s{2,}/g,' ').replace(/^\s+|\s+$/g,'')};this.removeClass=function(a,b){a.className=a.className.replace(new RegExp('(^|\\s)'+b+'(?:\\s|$)'),'$1');a.className.replace(/\s{2,}/g,' ').replace(/^\s+|\s+$/g,'')};this.tabs=this.getTabs();this.defaults.active=(this.parseurl(this.defaults.id))?this.parseurl(this.defaults.id):this.defaults.active;if(this.defaults.persist&&this.readCookie(this.defaults.id))this.defaults.active=this.readCookie(this.defaults.id);this.activebackup=this.defaults.active;this.show(this.defaults.active);var f=this;for(var i=0;i<this.links.length;i++){this.links[i].customindex=i+1;this.links[i].onclick=function(){if(f.timer1)clearTimeout(f.timer1);if(f.timer2)clearTimeout(f.timer2);f.show(this.customindex);if(f.defaults.persist)f.createCookie(f.defaults.id,this.customindex,0);if(f.defaults.wait)f.timer2=setTimeout(function(){f.rotate(f.defaults.interval)},f.defaults.wait*1000);return false}}if(this.defaults.interval)this.rotate(this.defaults.interval)};
