function resizeContent(){var a=$(window).height();$("#fs-image").css("height",a-120)}function set_share_qtip(){$("ul.listicons li a[title]").qtip({position:{corner:{target:"topMiddle",tooltip:"bottomMiddle"}},style:{name:"blue",padding:"7px 13px",width:{max:210,min:0},tip:{corner:"bottomMiddle",size:{x:10,y:8}}}})}function area_ajax(){var a=$(".icon-plus-small");for(var b=0;b<a.length;b++){var c=a[b];var d=c["id"];$(c).qtip({content:{text:'<img src="'+template+'/images/ajax-loader.gif" alt="Loading..." />',url:template+"/ajax-area.php",data:{ajaxid:"area",id:d},method:"post"},style:{name:"blue",tip:"leftMiddle",title:{overflow:"hidden","font-size":12},button:{display:"hidden"}},show:{effect:"fade"},hide:{when:"mouseout",fixed:true},position:{corner:{target:"rightMiddle",tooltip:"leftMiddle"}}})}}function disable_area_qtip(){$(".icon-plus-small").qtip("disable")}function get_photos(a){a.html('View photos <img align="center" src="'+template+'/images/ajax-loader-small.gif" />');var b=[];$.getJSON(template+"/show-image.php",{gid:a.attr("id")},function(c){a.html("View photos");$.each(c.items,function(a,c){b.push({href:c.href,title:c.title})});$.fancybox(b,{padding:0,type:"image",changeFade:0})})}function get_orderby(){var a=$("#sortlistings").val();return a}function get_property_bedrooms(){var a=$("#bedrooms").val();return a}function get_property_location(){var a=new Array;$.each($("input[name='propertylocation']:checked"),function(){a.push($(this).val())});return a}function get_property_type(){var a=new Array;$.each($("input[name='propertytype']:checked"),function(){a.push($(this).val())});return a}function ajax_display(a){if(a=="hide"){$("#ajax-loader").css({display:"block"});$("#content-list").css({opacity:.2})}else{$("#ajax-loader").css({display:"none"});$("#content-list").html(a).css({opacity:1})}}function number_format(a,b,c,d){a=(a+"").replace(/[^0-9+\-Ee.]/g,"");var e=!isFinite(+a)?0:+a,f=!isFinite(+b)?0:Math.abs(b),g=typeof d==="undefined"?",":d,h=typeof c==="undefined"?".":c,i="",j=function(a,b){var c=Math.pow(10,b);return""+Math.round(a*c)/c};i=(f?j(e,f):""+Math.round(e)).split(".");if(i[0].length>3){i[0]=i[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,g)}if((i[1]||"").length<f){i[1]=i[1]||"";i[1]+=(new Array(f-i[1].length+1)).join("0")}return i.join(h)}function convert_area(){var a=10.7639;var b=$("#displayarea").text();if(b=="sqm"){var c="feet";$("#displayarea").text("sq.ft.");$("#tosqft").addClass("hidden");$("#tosqm").removeClass("hidden")}else{var c="sqm";$("#displayarea").text("sqm");$("#tosqm").addClass("hidden");$("#tosqft").removeClass("hidden")}$(".displayarea").each(function(c){var d=$(this).text();if(b=="sqm"){amount=number_format($(this).next(".sqmarea").text()*a,0);$(this).text(amount)}else{amount=number_format($(this).next(".sqmarea").text(),0);$(this).text(amount)}});$.post(template+"/convert-area.php",{convertto:c})}function open_facebook(a,b){var c="fb"+Math.floor(Math.random()*2e3);window.open("http://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(a)+"&t="+encodeURIComponent(b),c,"menubar=0,resizable=1,width=550,height=370")}function open_twitter(a,b){var c="tweet"+Math.floor(Math.random()*2e3);if(b=="rental"){var d="Check out this Phuket rental listing on Hunter Sotheby's International Realty: "}else{var d="Check out this Phuket property for sale listing on Hunter Sotheby's International Realty: "}window.open("http://twitter.com/share?url="+a+"&text="+d,c,"menubar=0,resizable=1,width=550,height=370")}function slideTheMenuDown(){$(this).click(function(){$("#keysearch").css("color","#002249").val("");$(this).addClass("active");$(this).find(".subnav").slideDown("fast")})}function slideTheMenuUp(){if($("#keysearch").val()==""){$("#keysearch").css("color","#CCC").val("Quick Search by ID#")}$(this).find(".subnav").slideUp("fast");$(this).removeClass("active")}$(document).ready(function(){$.localScroll();$("#tabs").tabs();$("li.mega").hoverIntent({sensitivity:7,interval:100,over:slideTheMenuDown,timeout:200,out:slideTheMenuUp});if($(".fbform").length){$(".fbform").fancybox({padding:0,autoDimensions:true,width:520,height:365,autoScale:true,transitionIn:"none",transitionOut:"none",type:"iframe"})}$(".video").click(function(){$.fancybox({padding:0,autoScale:false,transitionIn:"none",transitionOut:"none",title:this.title,width:640,height:385,href:this.href.replace(new RegExp("watch\\?v=","i"),"v/"),type:"swf",swf:{wmode:"opaque",allowfullscreen:"true"}});return false});if($("#contactform").length){$("#contactform").validate({rules:{vname:"required",vemail:{required:true,email:true},venquiry:"required",captcha_code:"required"},messages:{vname:"Your name is required",vemail:"A valid email address is required",venquiry:"Please enter your comment or enquiry",captcha_code:"Incorrect validation code. Please try again."},errorPlacement:function(a,b){a.appendTo(b.parent().children(".err1"))}})}if(is_home){jQuery.event.add(window,"load",resizeContent);jQuery.event.add(window,"resize",resizeContent);jQuery.preloadImages=function(){var a=typeof arguments[0]=="object"?arguments[0]:arguments;for(var b=a.length-1;b>0;b--){jQuery("<img>").attr("src",a[b])}};$.supersized({slideshow:1,autoplay:1,start_slide:0,slide_interval:9e3,transition:1,transition_speed:500,new_window:1,pause_hover:0,keyboard_nav:1,performance:0,min_width:0,min_height:0,vertical_center:1,horizontal_center:1,fit_portrait:0,fit_landscape:0,navigation:1,thumbnail_navigation:1,slide_counter:0,slide_captions:1,slides:imgarray});$.preloadImages(imgpreload)}if(list_property){area_ajax();$("#toArea").change(function(){var a=10.7639;var b=$(this).val();if(b=="sqm"){var c="sqft";var d="sqm"}else{var c="sqm";var d="feet"}$(".area").each(function(b){var d=$(this).text();if(c=="sqm"){amount=d.replace("sqm","");amount=number_format(amount.replace(",","")*a,0)+"sq.ft.";$(this).html(amount)}else{amount=d.replace("sq.ft.","");amount=number_format(amount.replace(",","")/a,0)+"sqm";$(this).html(amount)}});$.post(template+"/convert-area.php",{convertto:d});disable_area_qtip();area_ajax()});$("input[name='propertytype'], input[name='propertylocation'], #bedrooms, #sortlistings").change(function(){ajax_display("hide");disable_area_qtip();var a="pajax=1&porderby="+get_orderby()+"&ptype="+get_property_type()+"&plocation="+get_property_location()+"&pbeds="+get_property_bedrooms()+"&pmin="+$slider.slider("values",0)+"&pmax="+$slider.slider("values",1);$.ajax({type:"POST",url:template+"/show-property.php",data:a,success:function(a){ajax_display(a);area_ajax();set_share_qtip();$(".clearall").button().click(function(){b()});$(".fbox-call").click(function(){get_photos($(this))})}});History.replaceState({state:1,rand:Math.random()},window.document.title,"?pp=1&"+a)});$slider=$("#slider");$amount=$("#priceamount");$slider.slider({range:true,min:0,max:3e8,step:1e6,values:[p_vallo,p_valhi],start:function(a,b){initlo=b.values[0];inithi=b.values[1]},slide:function(a,b){if(b.values[0]==0){minvalue="Min"}else{minvalue=b.values[0]/1e6+"M"}if(b.values[1]==3e8){maxvalue="Max"}else{maxvalue=b.values[1]/1e6+"M"}$amount.html(minvalue+" to "+maxvalue)},stop:function(a,c){if(c.values[0]!=initlo||c.values[1]!=inithi){ajax_display("hide");disable_area_qtip();var d="pajax=1&porderby="+get_orderby()+"&ptype="+get_property_type()+"&plocation="+get_property_location()+"&pbeds="+get_property_bedrooms()+"&pmin="+c.values[0]+"&pmax="+c.values[1];$.ajax({type:"POST",url:template+"/show-property.php",data:d,success:function(a){ajax_display(a);area_ajax();set_share_qtip();$(".clearall").button().click(function(){b()});$(".fbox-call").click(function(){get_photos($(this))})}});History.replaceState({state:1,rand:Math.random()},window.document.title,"?pp=1&"+d)}}});if($slider.slider("values",0)==0){minvalue1="Min"}else{minvalue1=$slider.slider("values",0)/1e6+"M"}if($slider.slider("values",1)==3e8){maxvalue1="Max"}else{maxvalue1=$slider.slider("values",1)/1e6+"M"}$amount.html(minvalue1+" to "+maxvalue1)}if(list_rental){$("input[name='propertytype'], input[name='propertylocation'], #bedrooms, #sortlistings").change(function(){ajax_display("hide");var a="pajax=1&porderby="+get_orderby()+"&ptype="+get_property_type()+"&plocation="+get_property_location()+"&pbeds="+get_property_bedrooms()+"&pmin="+$slider.slider("values",0)+"&pmax="+$slider.slider("values",1)+"&pperiod="+slidertype;$.ajax({type:"POST",url:template+"/show-rental.php",data:a,success:function(a){ajax_display(a);set_share_qtip();$(".clearall").button().click(function(){b()});$(".fbox-call").click(function(){get_photos($(this))})}});History.replaceState({state:1,rand:Math.random()},window.document.title,"?pr=1&renttype="+renttype+"&"+a)});function a(a,c){$slider=$("#slider");$amount=$("#priceamount");if(a=="short"){smax=3e4;sstep=1e3}else{smax=3e5;sstep=1e4}if(r_valhi==-1){r_valhi=smax}if(c==1){r_vallo=0;r_valhi=smax}$slider.slider({range:true,min:0,max:smax,step:sstep,values:[r_vallo,r_valhi],start:function(a,b){initlo=b.values[0];inithi=b.values[1]},slide:function(a,b){if(b.values[0]==0){minvalue="Min"}else{minvalue=b.values[0]/1e3+"K"}if(b.values[1]==smax){maxvalue="Max"}else{maxvalue=b.values[1]/1e3+"K"}$amount.html(minvalue+" to "+maxvalue)},stop:function(c,d){if(d.values[0]!=initlo||d.values[1]!=inithi){ajax_display("hide");var e="pajax=1&porderby="+get_orderby()+"&ptype="+get_property_type()+"&plocation="+get_property_location()+"&pbeds="+get_property_bedrooms()+"&pmin="+d.values[0]+"&pmax="+d.values[1]+"&pperiod="+a;$.ajax({type:"POST",url:template+"/show-rental.php",data:e,success:function(a){ajax_display(a);set_share_qtip();$(".clearall").button().click(function(){b()});$(".fbox-call").click(function(){get_photos($(this))})}});History.replaceState({state:1,rand:Math.random()},window.document.title,"?pr=1&"+e);if(a=="short"){$("#sortlistings option[value='rentlong_desc'], #sortlistings option[value='rentlong_asc']").attr("disabled","disabled");$("#sortlistings option[value='rentdaily_desc'], #sortlistings option[value='rentdaily_asc']").attr("disabled","");if($("#sortlistings option[value='rentlong_desc'], #sortlistings option[value='rentlong_asc']").is(":selected")){$("#sortlistings option[value='date_desc']").attr("selected",true)}}else if(a=="long"){$("#sortlistings option[value='rentdaily_desc'], #sortlistings option[value='rentdaily_asc']").attr("disabled","disabled");$("#sortlistings option[value='rentlong_desc'], #sortlistings option[value='rentlong_asc']").attr("disabled","");if($("#sortlistings option[value='rentdaily_desc'], #sortlistings option[value='rentdaily_asc']").is(":selected")){$("#sortlistings option[value='date_desc']").attr("selected",true)}}}}});if($slider.slider("values",0)==0){minvalue1="Min"}else{minvalue1=$slider.slider("values",0)/1e3+"K"}if($slider.slider("values",1)==smax){maxvalue1="Max"}else{maxvalue1=$slider.slider("values",1)/1e3+"K"}$amount.html(minvalue1+" to "+maxvalue1)}if($("#pricetype_0").is(":checked")){slidertype="short";a(slidertype,0)}else{slidertype="long";a(slidertype,0)}$("input[name=pricetype]").change(function(){slidertype=$(this).val();a(slidertype,1)})}if(list_property||list_rental){$.fn.clearForm=function(){return this.each(function(){var a=this.type,b=this.tagName.toLowerCase();if(b=="form")return $(":input",this).clearForm();if(a=="text"||a=="password"||b=="textarea")this.value="";else if(a=="checkbox"||a=="radio")this.checked=false;else if(b=="select")this.selectedIndex=0})};function b(){History.replaceState({state:1,rand:Math.random()},window.document.title,"?");ajax_display("hide");$("#filtersearch").clearForm();$(".location").hide();$(".region").each(function(){$(this).children("span").removeClass("icon-minus-small-white").addClass("icon-plus-small-white")});$slider.slider("values",0,0);$slider.slider("values",1,3e8);$amount.html("Min to Max");if(list_property){disable_area_qtip();var b="pajax=1&porderby="+get_orderby()+"&ptype="+get_property_type()+"&plocation="+get_property_location()+"&pbeds="+get_property_bedrooms()+"&pmin="+0+"&pmax="+3e8;$.ajax({type:"POST",url:template+"/show-property.php",data:b,success:function(a){ajax_display(a);area_ajax();set_share_qtip();$(".fbox-call").click(function(){get_photos($(this))})}})}else if(list_rental){$("#pricetype_0").attr("checked",true);slidertype="short";a(slidertype,1);var b="pajax=1&porderby="+get_orderby()+"&ptype="+get_property_type()+"&plocation="+get_property_location()+"&pbeds="+get_property_bedrooms()+"&pmin=&pmax=&pperiod=";$.ajax({type:"POST",url:template+"/show-rental.php",data:b,success:function(a){ajax_display(a);set_share_qtip();$(".fbox-call").click(function(){get_photos($(this))})}})}}$(".region").click(function(){if($(this).next(".location").is(":hidden")){$(this).next(".location").slideDown();$(this).children("span").removeClass("icon-plus-small-white").addClass("icon-minus-small-white")}else{$(this).next(".location").slideUp();$(this).children("span").removeClass("icon-minus-small-white").addClass("icon-plus-small-white")}});$(".clearall").button().click(function(){b()});set_share_qtip();$(".fbox-call").click(function(){get_photos($(this))});$("#toCurrency").change(function(){$(".priceval").html('<img align="center" src="'+template+'/images/ajax-loader.gif" alt="Loading..." />');var a=$(this).val();if(a==""){var b=true;$("#toCurrency").attr("selectedIndex",0)}else{var b=false}var c="to="+a;$.ajax({type:"POST",url:template+"/convert-fx.php",data:c,success:function(c){var d=c.split(",");var e=d[0];var f=d[1];$("span.THBprice").each(function(c){var d=$(this).text();var f=$(this).siblings(".priceval");if(b){a="THB"}f.html(a+" "+number_format(e*d,0));if(a=="THB"){$(this).siblings(".pricecaption").hide()}else{$(this).siblings(".pricecaption").show()}});$("span.USDprice").each(function(c){var d=$(this).text();var e=$(this).siblings(".priceval");if(b){a="USD"}e.html(a+" "+number_format(f*d,0));if(a=="USD"){$(this).siblings(".pricecaption").hide()}else{$(this).siblings(".pricecaption").show()}})}})})}if(single_property||single_rental){if(show_gallery){$("#gallery").galleria({width:620,height:505,showInfo:false,lightbox:true})}}if(single_property){$("#dialog-currency").dialog({autoOpen:false,height:180,width:350,modal:true,buttons:{Convert:function(){var a=$("#amount").val();var b=$("#toCurrency").val();if(b==""){b="THB"}var c="to="+b;$.ajax({type:"POST",url:template+"/convert-fx.php",data:c,success:function(a){var c=a.split(",");var d=c[0];var e=c[1];$("span.THBprice").each(function(a){var c=$(this).text();var e=$(this).siblings(".priceval");e.html(b+" "+number_format(d*c,0));if(b=="THB"){$(this).siblings(".pricecaption").hide()}else{$(this).siblings(".pricecaption").show()}});$("span.USDprice").each(function(a){var c=$(this).text();var d=$(this).siblings(".priceval");d.html(b+" "+number_format(e*c,0));if(b=="USD"){$(this).siblings(".pricecaption").hide()}else{$(this).siblings(".pricecaption").show()}})}});$("#dialog-currency").dialog("close")},Cancel:function(){$(this).dialog("close")}}});$("#convert").click(function(){$("#dialog-currency").dialog("open")})}if(single_rental){$("#dialog-currency").dialog({autoOpen:false,height:180,width:350,modal:true,buttons:{Convert:function(){var a=$("#toCurrency").val();if(a==""){var b=true;$("#toCurrency").attr("selectedIndex",0)}else{var b=false}var c="to="+a;$.ajax({type:"POST",url:template+"/convert-fx.php",data:c,success:function(c){var d=c.split(",");var e=d[0];var f=d[1];$("span.THBprice").each(function(c){var d=$(this).text();var f=$(this).siblings(".priceval");if(b){a="THB"}f.html(a+" "+number_format(e*d,0))});$("span.USDprice").each(function(c){var d=$(this).text();var e=$(this).siblings(".priceval");if(b){a="USD"}e.html(a+" "+number_format(f*d,0))});if(b){$("#currency-disclaimer").hide()}else{$("#currency-disclaimer").show()}$("#dialog-currency").dialog("close")}})},Cancel:function(){$(this).dialog("close")}}});$("#convert").click(function(){$("#dialog-currency").dialog("open")})}if(single_post&&!single_property&&!single_rental){jQuery.fn.getTitle=function(){var a=jQuery("a.fancybox");jQuery.each(a,function(){var a=jQuery(this).children("img").attr("title");jQuery(this).attr("title",a)})};var c='a:has(img)[href$=".bmp"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".BMP"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';jQuery(c).addClass("fancybox").attr("rel","fancybox").getTitle();jQuery("a.fancybox").fancybox({imageScale:true,titlePosition:"over",padding:0,frameWidth:560,frameHeight:340,centerOnScroll:true,titleShow:false})}})
