document.observe("dom:loaded",function(){init()});function init(){if($("change-currency")){$("change-currency").observe("click",function(b){$("new-currency-form").toggle();Event.element(b).hide();Event.stop(b)})}if($("new-currency")){$("new-currency").observe("change",function(c){jar=new CookieJar({expires:3600,path:"/"});vals=Event.element(c).value;reload_page=Event.element(c).className;jar.put("currency",vals);if(reload_page!=""){var b=document.URL;window.location.href=b}})}if($("Level_1")){$("Level_1").onchange=_addLevel}_addHightLights();if($("more-details")){if($("gallery")){$("gallery").hide();$("photo").show()}}if($("all_property_type")){Event.observe("all_property_type","click",_allTypes)}if($("navigationTools")){__CreatePathToShortList()}if($("results")){element=$$(".shortList");element.each(function(b){Event.observe(b,"click",_shortList)})}if($("results")){Shadowbox.setup("a.inspection-trip",{player:"iframe",width:500})}if($("flybuy")){Shadowbox.setup("a.inspection-trip",{player:"iframe",width:600})}if($("date")){Calendar.setup({inputField:"date",ifFormat:"%Y/%m/%d",showsTime:true,eventName:"click",singleClick:true,step:1})}}function _addLevel(){url=_HOST+"calls.php";if(this.value!=""){new Ajax.Request(url,{method:"post",parameters:{ID:this.value,ACTION:this.name,FUNCTION:"setLevel"},onSuccess:function(b){block=b.responseText;$("citiesCon").innerHTML=block}})}}function _addHightLights(){$$("input").each(function(b){b.observe("focus",function(){b.style.backgroundColor="#fdf"});b.observe("blur",function(){b.style.backgroundColor="#fff"})})}function _allCities(){obj=$$(".cities");if($("all_cities_type").checked){$("all_cities_type").checked=true;obj.each(function(b){b.checked=true})}else{$("all_cities_type").checked=false;obj.each(function(b){b.checked=false})}}function _allTypes(){obj=$$(".property_type");if($("all_property_type").checked){$("all_property_type").checked=true;obj.each(function(b){b.checked=true})}else{$("all_property_type").checked=false;obj.each(function(b){b.checked=false})}}function _shortList(){var c=__getCookies();var b="";obj={id:this.id,reference:this.title};exist=false;c.each(function(d){if(obj.id==d.id){exist=true}});if(!exist){c.push(obj)}c.each(function(d){a=Object.toJSON(d);b+="###"+a.replace(/\\/g,"")});jar=new CookieJar({path:"/"});jar.put("shortlist",b);shortlist=jar.get("shortlist");$("navigationTools").update("Shortlist ("+c.length+")")}function __CreatePathToShortList(){stock=__getCookies();$("navigationTools").update("Shortlist ("+stock.length+")")}function deleteProperty(ref){$(ref).remove();jar=new CookieJar({path:"/"});string=jar.get("shortlist");var stock=[];var i="";if((string!=null)&&string!=""){arg=string.split("###");arg.each(function(item){if(item!=""){obj=eval("("+item+")");if(ref!=obj.id){stock.push(obj)}}})}stock.each(function(it){a=Object.toJSON(it);i+="###"+a.replace(/\\/g,"")});jar=new CookieJar({path:"/"});jar.put("shortlist",i);__CreatePathToShortList()}function __getCookies(){jar=new CookieJar({path:"/"});string=jar.get("shortlist");var stock=[];if((string!=null)&&string!=""){arg=string.split("###");arg.each(function(item){if(item!=""){object=eval("("+item+")");stock.push(object)}})}return stock}function formatNumber(c,b){anynum=c;divider=10;switch(b){case 0:divider=1;break;case 1:divider=10;break;case 2:divider=100;break;default:divider=1000}workNum=Math.abs((Math.round(anynum*divider)/divider));workStr=""+workNum;if(workStr.indexOf(".")==-1){workStr+="."}dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0;pStr=workStr.substr(workStr.indexOf("."));while(pStr.length-1<b){pStr+="0"}if(pStr=="."){pStr=""}if(dNum>=1000){dLen=dStr.length;dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)}if(dNum>=1000000){dLen=dStr.length;dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)}retval=dStr+pStr;if(anynum<0){retval="("+retval+")"}return retval}function format(b){var c=b.value.replace(/\,/g,"");if(!isNaN(c)){if(c.indexOf(".")>-1){c=c.split(".");c[0]=c[0].toString().split("").reverse().join("").replace(/(?=\d*\.?)(\d{3})/g,"$1,").split("").reverse().join("").replace(/^[\,]/,"");if(c[1].length>2){alert("You may only enter two decimals!");c[1]=c[1].substring(0,c[1].length-1)}b.value=c[0]+"."+c[1]}else{b.value=c.toString().split("").reverse().join("").replace(/(?=\d*\.?)(\d{3})/g,"$1,").split("").reverse().join("").replace(/^[\,]/,"")}}else{alert((lang=="es"?"Solo puedes ingresar numeros en el casillero":"You may enter only numbers in this field!"));b.value=b.value.substring(0,b.value.length-1)}};