function ViewPromo(){var t=GetCurrentLanguage()=="1"?395:410;$("body").css("overflow-y","hidden"),GetCurrentLanguage()=="2"&&$("#lblDigest").html("AHA Digest 現時只提供英文版本參閱。"),GetCurrentLanguage()=="3"&&$("#lblDigest").html("AHA Digest 现时只提供英文版本参阅。"),$(".inline").colorbox({inline:!0,width:"640px",height:t,onCleanup:function(){$("body").css({"overflow-x":"hidden","overflow-y":"auto"})}}),$("#promoConfirmation").hide(),$("#promoInput").show(),$("#showPromo").show()}function loadSVG(n){function k(){$(".districtArea").click(function(n){n.stopPropagation(),$(".districtArea").stop().slideDown()}),$("#features").click(function(n){n.stopPropagation(),$(".features").css("display")=="block"?$(".features").css("display","none"):$(".features").css("display","block")}),$("#disfeatures").click(function(n){n.stopPropagation(),$(".features").css("display")=="block"?$(".features").css("display","none"):$(".features").css("display","block")}),$(".features").click(function(n){n.stopPropagation(),$(".features").css("display","")}),$("#drpDistrictArea").click(function(n){n.stopPropagation(),$("#districtAreaBox").css("overflow","visible"),$(".districtArea").stop().slideToggle(400,function(){$(".districtArea").css("display")=="block"?($(".mapSearch, .map > svg").animate({width:"528px"}),$(".mapSearch").css("border","1px solid #fff"),$(".mapSelect, .closemap, .map > svg, .hoverMap").css("display","block"),$(".mapSearch").show()):($(".mapSearch, .map > svg").animate({width:"0"}),$(".mapSearch").css("border",0),$(".mapSelect, .closemap, .map > svg, .hoverMap").css("display","none"))});var t=$(".mapSearch").outerHeight()-(f+$("#drpDistrictArea").outerHeight()+$(".districtAreaSearch").innerHeight()+1);$(".districtAreaWrapper").css("height",t)}),$(document).click(function(){$(".districtArea").slideUp(),$(".features").css("display","none"),$(".mapSearch, .map > svg").animate({width:"0"}),$(".mapSearch").css("border",0),$(".mapSelect, .closemap, .map > svg, .hoverMap").css("display","none")}),$("#chkAll").change(function(){Currentlanguageid=="1"?($(this).is(":checked")?($(".areas").find("input:checkbox").attr("checked","checked"),$("#distAreasText").text("("+$(".districtArea").find(".districts:checked").length+") Districts selected")):($(".areas").find("input:checkbox").removeAttr("checked"),$("#distAreasText").text("Districts/Areas")),$(".districts").each(function(){id=$(this).attr("id"),id=id.substring(id.indexOf("_")+1),r(id),t($("#mainHK"),$("#mapAllArea"),$("#cntAllArea"),"")})):Currentlanguageid=="2"?($(this).is(":checked")?($(".areas").find("input:checkbox").attr("checked","checked"),$("#distAreasText").text("已選地區("+$(".districtArea").find(".districts:checked").length+") 個")):($(".areas").find("input:checkbox").removeAttr("checked"),$("#distAreasText").text("地區")),$(".districts").each(function(){id=$(this).attr("id"),id=id.substring(id.indexOf("_")+1),r(id),t($("#mainHK"),$("#mapAllArea"),$("#cntAllArea"),"")})):Currentlanguageid=="3"&&($(this).is(":checked")?($(".areas").find("input:checkbox").attr("checked","checked"),$("#distAreasText").text("已选地区 ("+$(".districtArea").find(".districts:checked").length+") 个")):($(".areas").find("input:checkbox").removeAttr("checked"),$("#distAreasText").text("地区")),$(".districts").each(function(){id=$(this).attr("id"),id=id.substring(id.indexOf("_")+1),r(id),t($("#mainHK"),$("#mapAllArea"),$("#cntAllArea"),"")}))}),$(".areaName").find("input:checkbox").change(function(){var n=$(this).attr("id"),t;n=n.substring(n.length-1),Currentlanguageid=="1"?$(this).is(":checked")?($(".districtOfArea_"+n).find("input:checkbox").attr("checked","checked"),$("#distAreasText").text("("+$(".districtArea").find(".districts:checked").length+") Districts selected")):($(".districtOfArea_"+n).find("input:checkbox").removeAttr("checked"),t=$(".districtArea").find(".districts:checked").length,t>0?$("#distAreasText").text("("+t+") Districts selected"):($("#distAreasText").text("Districts/Areas"),$("#chkAll").removeAttr("checked"))):Currentlanguageid=="2"?$(this).is(":checked")?($(".districtOfArea_"+n).find("input:checkbox").attr("checked","checked"),$("#distAreasText").text("已選地區("+$(".districtArea").find(".districts:checked").length+")個")):($(".districtOfArea_"+n).find("input:checkbox").removeAttr("checked"),t=$(".districtArea").find(".districts:checked").length,t>0?$("#distAreasText").text("已選地區("+t+")個"):($("#distAreasText").text("地區"),$("#chkAll").removeAttr("checked"))):Currentlanguageid=="3"&&($(this).is(":checked")?($(".districtOfArea_"+n).find("input:checkbox").attr("checked","checked"),$("#distAreasText").text("已选地区("+$(".districtArea").find(".districts:checked").length+")个")):($(".districtOfArea_"+n).find("input:checkbox").removeAttr("checked"),t=$(".districtArea").find(".districts:checked").length,t>0?$("#distAreasText").text("已选地区("+t+")个"):($("#distAreasText").text("地区"),$("#chkAll").removeAttr("checked")))),n=$(this).attr("id"),n=n.substring(n.indexOf("_")+1),it(n),u()}),$(".districtArea").find(".districts").change(function(){id=$(this).attr("id"),id=id.substring(id.indexOf("_")+1),u(),r(id),c(id)})}function u(){var n=$(".districtArea").find(".districts:checked").length,t=$(".districtArea").find(".districts").length;n!=t?$("#chkAll").attr("checked",!1):$("#chkAll").attr("checked",!0),n>0?Currentlanguageid=="1"?$("#distAreasText").text("("+n+") Districts selected"):Currentlanguageid=="2"?$("#distAreasText").text("已選地區 ("+n+") 個"):Currentlanguageid=="3"&&$("#distAreasText").text("已选地区("+n+") 个"):Currentlanguageid=="1"?($("#distAreasText").text("Districts/Areas"),$("#chkAll").removeAttr("checked")):Currentlanguageid=="2"?($("#distAreasText").text("地區"),$("#chkAll").removeAttr("checked")):Currentlanguageid=="3"&&($("#distAreasText").text("地区"),$("#chkAll").removeAttr("checked"))}function b(n,t){var c=JSON.parse($("#AreasDistrictsSaleLease").val()),u;document.all&&!document.addEventListener?($("#IEallLocation").css("display","block"),$("#IEareas").css("display","block"),$("#allLocations").css("display","none"),$(".areas").css("display","block"),$("#IEallLocation").empty(),$("#IEareas").empty()):($("#IEallLocation").css("display","none"),$("#IEareas").css("display","none")),$("#allLocations").empty(),$(".areas").empty(),t==1&&(u=c.Table),t==2&&(u=c.Table1);var f=0,i="",l="",r=0,e=0,a=0,o=!1,s=!1,h=0;$.each(u,function(n,t){var c,a,v,y;t.AreaID!=0&&f!=t.AreaID&&(s=!1,c=jQuery.grep(u,function(n){return n.AreaID===t.AreaID}),a=c.length-1,h=parseInt(c[c.length-1].DistrictID),a%2==0?e=a/2:(e=Math.ceil(a/2),s=!0),o=!1),t.AreaID==0&&t.AreaName==""&&t.DistrictID==0&&t.DistrictName==""&&(document.all&&!document.addEventListener?$("#IEallLocation").append("<input type='checkbox' name='chkAll' id='chkAll'><label for='chkAll'>"+SearchBarAllLocations+"(<span>"+t.TotalCount+"</span>)</label>"):$("#allLocations").append("<input type='checkbox' name='chkAll' id='chkAll'><label for='chkAll'>"+SearchBarAllLocations+"(<span>"+t.TotalCount+"</span>)</label>")),t.AreaID>0&&t.AreaName!=""&&t.DistrictID==0&&t.DistrictName==""&&(i+="<div class='totalLsts areaName' id=area"+t.AreaID+"><input class=chkArea type='checkbox' name=chkArea_"+t.AreaID+" id=chkArea_"+t.AreaID+"><label for=chkArea_"+t.AreaID+">"+t.AreaName+" (<span>"+t.TotalCount+"</span>)</label></div>"),t.AreaID!=0&&r==0&&t.AreaID==f&&(i+="<ul class=districtOfArea_"+t.AreaID+">"),t.AreaID!=0&&t.AreaName!=""&&t.DistrictID!=0&&t.DistrictName!=""&&(r=r+1,v=t.DisplayDistrictName,y=v.indexOf("(")+1!="0"?v.substring(v.indexOf("(")):"",i+=y!=""?l+"<li><input type='checkbox' class=districts name=chkDistrict_"+t.DistrictID+" id=chkDistrict_"+t.DistrictID+" ><label  for=chkDistrict_"+t.DistrictID+">"+t.DistrictName+"<br /><span>"+y+"</span>&nbsp;("+t.TotalCount+")</label></li>":l+"<li><input type='checkbox' class=districts name=chkDistrict_"+t.DistrictID+" id=chkDistrict_"+t.DistrictID+"><label for=chkDistrict_"+t.DistrictID+">"+t.DistrictName+" ("+t.TotalCount+")</label></li>",$("path#"+t.DistrictID).removeAttr("class"),$("path#"+t.DistrictID).attr("class","disExists"),$("path#"+t.DistrictID).css("fill","#05aba3"),t.DistrictID==1&&($("path#1_1").removeAttr("class"),$("path#1_1").attr("class","disExists"),$("path#1_1").css("fill","#05aba3"))),r!=0&&(r==e||s==!0&&o==!0&&h!=0&&h==t.DistrictID)&&(r=0,i+="</ul>",o=!0),f=t.AreaID}),document.all&&!document.addEventListener?$("#IEareas").html(i):$(".areas").html(i),k(),ft()}function w(){$("#drpPriceMin").val("0"),selectMenu($("#drpPriceMin"),70),$("#drpPriceMax").val("0"),selectMenu($("#drpPriceMax"),70),$("#drpSize").val("0"),selectMenu($("#drpSize"),99),$("#drpBeds").val("0"),selectMenu($("#drpBeds"),70),$("#saleable").removeAttr("checked"),$("#gross").attr("checked","checked"),$("#drpDistrictPriceMin").val("0"),selectMenu($("#drpDistrictPriceMin"),70),$("#drpDistrictPriceMax").val("0"),selectMenu($("#drpDistrictPriceMax"),70),$("#drpDistrictSize").val("0"),selectMenu($("#drpDistrictSize"),99),$("#drpDistrictBeds").val("0"),selectMenu($("#drpDistrictBeds"),70),$("#newLease").removeAttr("checked"),$("#newGross").attr("checked","checked"),$("#gross").parent().css("background-position","50% -19px"),$("#saleable").parent().css("background-position","50% 0"),$("#newGross").parent().css("background-position","50% -19px"),$("#newLease").parent().css("background-position","50% 0"),$("[id*='txtSmartSearch']").val(smart_text_search)}function p(){var i,u,f,a,t,e,s,h,p;$("[id*='postingpurposeid']").val(currentSelectedTab);var o=$("#drpPriceMin option:selected").val(),u=o.substring(o.length-1),f=o.substring(0,o.length-1),l;u=="M"&&(l=parseFloat(f)*1e6),u=="K"&&(l=parseFloat(f)*1e3),$("[id*='minprice']").val(l),i=$("#drpPriceMax option:selected").val(),i.indexOf("+")!=-1?$("[id*='maxprice']").val("-1"):(u=i.substring(i.length-1),f=i.substring(0,i.length-1),u=="M"&&(a=parseFloat(f)*1e6),u=="K"&&(a=parseFloat(f)*1e3),$("[id*='maxprice']").val(a)),$("input:radio[name=leaseType]:checked").attr("id")=="gross"&&$("[id*='grossornetopt']").val("1"),$("input:radio[name=leaseType]:checked").attr("id")=="saleable"&&$("[id*='grossornetopt']").val("2"),t=$("#drpSize option:selected").text(),t!=Size_Text&&t!=Size_Text_Any?$("[id*='grossornetsize']").val(t.substring(0,t.indexOf("+")).replace(/\,/g,"")):t==Size_Text?$("[id*='grossornetsize']").val("0"):t==Size_Text_Any&&$("[id*='grossornetsize']").val("-1"),e=$("#drpBeds option:selected").text(),e!="Beds"?e=="0+"?$("[id*='beds']").val("-1"):$("[id*='beds']").val(e.substring(0,e.indexOf("+"))):$("[id*='beds']").val("0"),s=replaceHTMLCharacters($("[id*='txtSmartSearch']").val()),s!=""&&s!=smart_text_search?$("[id*='keywordSearch']").val(s):$("[id*='keywordSearch']").val(""),$("#hasmaidroom").is(":checked")?$("[id*='hasmaidroom']").val("1"):$("[id*='hasmaidroom']").val("0"),$("#hasbalcony").is(":checked")?$("[id*='hasbalcony']").val("1"):$("[id*='hasbalcony']").val("0"),$("#hasterrace").is(":checked")?$("[id*='hasterrace']").val("1"):$("[id*='hasterrace']").val("0"),$("#hasrooftop").is(":checked")?$("[id*='hasrooftop']").val("1"):$("[id*='hasrooftop']").val("0"),$("#hasgarden").is(":checked")?$("[id*='hasgarden']").val("1"):$("[id*='hasgarden']").val("0"),$("#hasparking").is(":checked")?$("[id*='hasparking']").val("1"):$("[id*='hasparking']").val("0"),h="",p="",$(".chkFacilities").each(function(){var n,t;$(this).is(":checked")&&(n=$(this).attr("id"),n=n.substring(n.indexOf("_")+1),t=$(this).attr("value"),n=="pool"&&(n="3,18"),h+=n+",")}),$("[id*='facilities']").val(h.substring(0,h.length-1));var n="",c="",r="",v="",y="";return $("#chkAll").is(":checked")?($(".districtArea").find(".chkArea").each(function(){var i=$(this).attr("value"),t;i=i.substring(i.indexOf("_")+1),v+=i+",",t=$(this).attr("id"),t=t.substring(t.indexOf("_")+1),n+=t+","}),$(".districts").each(function(){var t=$(this).attr("value"),n;t=t.substring(t.indexOf("_")+1),y+=t+",",n=$(this).attr("id"),n=n.substring(n.indexOf("_")+1),r+=n+","}),$("[id*='areaNames']").val(v.substring(0,n.length-1)),$("[id*='area']").val(n.substring(0,n.length-1)),$("[id*='selarea']").val(n.substring(0,n.length-1)),$("[id*='districtNames']").val(y.substring(0,n.length-1)),$("[id*='district']").val(r.substring(0,r.length-1)),!0):($(".districtArea").find(".chkArea").each(function(){if($(this).is(":checked")){var t=$(this).attr("id");t=t.substring(t.indexOf("_")+1),n+=t+","}}),$(".districts").each(function(){var n,t,i,u;$(this).is(":checked")&&(n=$(this).attr("id"),n=n.substring(n.indexOf("_")+1),t=$("#chkDistrict_"+n).closest("ul").attr("class"),i=t.substring(t.indexOf("_")+1),c.indexOf(i+",")==-1&&(c+=i+","),r+=n+",")}),$("[id*='area']").val(n.substring(0,n.length-1)),$("[id*='selarea']").val(c.substring(0,c.length-1)),$("[id*='district']").val(r.substring(0,r.length-1)),!0)}function tt(){var i,u,f,a,t,e,s,h,p;$("[id*='postingpurposeid']").val(currentSelectedTab);var o=$("#drpDistrictPriceMin option:selected").val(),u=o.substring(o.length-1),f=o.substring(0,o.length-1),l;u=="M"&&(l=parseFloat(f)*1e6),u=="K"&&(l=parseFloat(f)*1e3),$("[id*='minprice']").val(l),i=$("#drpDistrictPriceMax option:selected").val(),i.indexOf("+")!=-1?$("[id*='maxprice']").val("-1"):(u=i.substring(i.length-1),f=i.substring(0,i.length-1),u=="M"&&(a=parseFloat(f)*1e6),u=="K"&&(a=parseFloat(f)*1e3),$("[id*='maxprice']").val(a)),$("input:radio[name=newLeaseType]:checked").attr("id")=="newGross"&&$("[id*='grossornetopt']").val("1"),$("input:radio[name=newLeaseType]:checked").attr("id")=="newLease"&&$("[id*='grossornetopt']").val("2"),t=$("#drpDistrictSize option:selected").text(),t!=Size_Text&&t!=Size_Text_Any?$("[id*='grossornetsize']").val(t.substring(0,t.indexOf("+")).replace(/\,/g,"")):t==Size_Text?$("[id*='grossornetsize']").val("0"):t==Size_Text_Any&&$("[id*='grossornetsize']").val("-1"),e=$("#drpDistrictBeds option:selected").text(),e!="Beds"?e=="0+"?$("[id*='beds']").val("-1"):$("[id*='beds']").val(e.substring(0,e.indexOf("+"))):$("[id*='beds']").val("0"),s=replaceHTMLCharacters($("[id*='txtSmartSearch']").val()),s!=""&&s!=smart_text_search?$("[id*='keywordSearch']").val(s):$("[id*='keywordSearch']").val(""),$("#dishasmaidroom").is(":checked")?$("[id*='hasmaidroom']").val("1"):$("[id*='hasmaidroom']").val("0"),$("#dishasbalcony").is(":checked")?$("[id*='hasbalcony']").val("1"):$("[id*='hasbalcony']").val("0"),$("#dishasterrace").is(":checked")?$("[id*='hasterrace']").val("1"):$("[id*='hasterrace']").val("0"),$("#dishasrooftop").is(":checked")?$("[id*='hasrooftop']").val("1"):$("[id*='hasrooftop']").val("0"),$("#dishasgarden").is(":checked")?$("[id*='hasgarden']").val("1"):$("[id*='hasgarden']").val("0"),$("#dishasparking").is(":checked")?$("[id*='hasparking']").val("1"):$("[id*='hasparking']").val("0"),h="",p="",$(".chkdisFacilities").each(function(){var n,t;$(this).is(":checked")&&(n=$(this).attr("id"),n=n.substring(n.indexOf("_")+1),t=$(this).attr("value"),n=="pool"&&(n="3,18"),h+=n+",")}),$("[id*='facilities']").val(h.substring(0,h.length-1));var n="",c="",r="",v="",y="";return $("#chkAll").is(":checked")?($(".districtArea").find(".chkArea").each(function(){var i=$(this).attr("value"),t;i=i.substring(i.indexOf("_")+1),v+=i+",",t=$(this).attr("id"),t=t.substring(t.indexOf("_")+1),n+=t+","}),$(".districts").each(function(){var t=$(this).attr("value"),n;t=t.substring(t.indexOf("_")+1),y+=t+",",n=$(this).attr("id"),n=n.substring(n.indexOf("_")+1),r+=n+","}),$("[id*='areaNames']").val(v.substring(0,n.length-1)),$("[id*='area']").val(n.substring(0,n.length-1)),$("[id*='selarea']").val(n.substring(0,n.length-1)),$("[id*='districtNames']").val(y.substring(0,n.length-1)),$("[id*='district']").val(r.substring(0,r.length-1)),!0):($(".districtArea").find(".chkArea").each(function(){if($(this).is(":checked")){var t=$(this).attr("id");t=t.substring(t.indexOf("_")+1),n+=t+","}}),$(".districts").each(function(){var n,t,i,u;$(this).is(":checked")&&(n=$(this).attr("id"),n=n.substring(n.indexOf("_")+1),t=$("#chkDistrict_"+n).closest("ul").attr("class"),i=t.substring(t.indexOf("_")+1),c.indexOf(i+",")==-1&&(c+=i+","),r+=n+",")}),$("[id*='area']").val(n.substring(0,n.length-1)),$("[id*='selarea']").val(c.substring(0,c.length-1)),$("[id*='district']").val(r.substring(0,r.length-1)),!0)}function t(n,t,i,r){$(".map").hide(),$(".mapArea").removeClass("mapAreaHighlight"),$(".selArea").removeClass("mapCountHighlight"),$(n).show(),$(t).addClass("mapAreaHighlight"),$(i).addClass("mapCountHighlight"),$("#areaMapName").html(r)}function i(n,t,i){e(n,$(t).val())?($(t).val(v($(t).val(),n)),$("#"+n).css("fill","#05aba3"),n==1&&$("#1_1").css("fill","#05aba3")):($(t).val(d($(t).val(),n)),$("#"+n).css("fill","#a82325"),n==1&&$("#1_1").css("fill","#a82325")),y($(t).val(),i)}function e(n,t){return ids=t.split(","),ids.indexOf(n)!=-1?!0:!1}function y(n,t){var r=GetCurrentLanguage(),i;n=n.split(","),n.length-1!=0?r==2?$("#"+t).html("已選地區"+(n.length-1)+" 個"):r==3?$("#"+t).html("已选地区"+(n.length-1)+" 个"):$("#"+t).html(n.length-1+" selected"):$("#"+t).html(""),i=o(),i.length-1!=0?r==2?$("#cntAllArea").html("已選地區"+(i.length-1)+" 個"):r==3?$("#cntAllArea").html("已选地区"+(i.length-1)+" 个"):$("#cntAllArea").html(i.length-1+" selected"):$("#cntAllArea").html("")}function v(n,t){if(n!=""){n=n.split(","),n.indexOf(t)!=-1&&n.splice(n.indexOf(t),1);var i=o();return i.indexOf(t)!=-1&&i.splice(i.indexOf(t),1),a(i),n.join(",")}return""}function d(n,t){n=n.split(","),n.indexOf(t)==-1&&n.push(t);var i=o();return i.indexOf(t)==-1&&i.push(t),a(i),n.join(",")}function a(n){currentSelectedTab==2?$("#hdnAllIds").val(n.join(",")):$("#hdnSaleAllIds").val(n.join(","))}function o(){var n="";return n=currentSelectedTab==2?$("#hdnAllIds").val().split(","):$("#hdnSaleAllIds").val().split(",")}function l(n){$("#chkDistrict_"+n).is(":checked")?$("#chkDistrict_"+n).removeAttr("checked"):$("#chkDistrict_"+n).attr("checked","checked"),u(),c(n)}function c(n){try{areaCls=$("#chkDistrict_"+n).closest("ul").attr("class"),areaId=areaCls.substring(areaCls.indexOf("_")+1);var t=$(".districtOfArea_"+areaId).find(".districts:checked").length,i=$(".districtOfArea_"+areaId).find(".districts").length;t==i?$("#chkArea_"+areaId).attr("checked","checked"):$("#chkArea_"+areaId).removeAttr("checked")}catch(r){}}function it(n){$('path[areaid="'+n+'"]').each(function(){r($(this).attr("id"))})}function h(n){isNaN(n)||(disId=n,n=$('path[id="'+disId+'"]').attr("id"),hdnId="",cntId="",$("#"+n).closest("div").attr("id")=="outlyingHK"?(hdnId=currentSelectedTab==2?"hdnOutlyingIds":"hdnSaleOutlyingIds",cntId="cntOutlying"):$("#"+n).closest("div").attr("id")=="islandHK"?(hdnId=currentSelectedTab==2?"hdnIslandIds":"hdnSaleIslandIds",cntId="cntHKArea"):$("#"+n).closest("div").attr("id")=="kowloonHK"?(hdnId=currentSelectedTab==2?"hdnKowloonIds":"hdnSaleKowloonIds",cntId="cntKowloon"):$("#"+n).closest("div").attr("id")=="newTerHK"&&(hdnId=currentSelectedTab==2?"hdnNewTerIds":"hdnSaleNewTerIds",cntId="cntNewTerr"),cntId!=""&&hdnId!=""&&($("#chkDistrict_"+disId).is(":checked")?($("#"+hdnId).val(d($("#"+hdnId).val(),n)),$("#"+n).css("fill","#a82325"),n=="1"&&$("#1_1").css("fill","#a82325")):($("#"+hdnId).val(v($("#"+hdnId).val(),n)),$("#"+n).attr("class")=="disExists"?($("#"+n).css("fill","#05aba3"),n=="1"&&$("#1_1").css("fill","#05aba3")):($("#"+n).css("fill","#919296"),n=="1"&&$("#1_1").css("fill","#919296"))),y($("#"+hdnId).val(),cntId)))}function r(n){h(n),$(".map").hide(),$(".mapArea").removeClass("mapAreaHighlight"),$(".selArea").removeClass("mapCountHighlight"),$("#hoverMapName").html("&nbsp;"),$("#"+n).closest("div").attr("id")=="outlyingHK"?($("#outlyingHK").show(),$("#mapOutlying").addClass("mapAreaHighlight"),$("#cntOutlying").addClass("mapCountHighlight"),$("#areaMapName").html(allOutlyingMapName)):$("#"+n).closest("div").attr("id")=="islandHK"?($("#islandHK").show(),$("#mapHKArea").addClass("mapAreaHighlight"),$("#cntHKArea").addClass("mapCountHighlight"),$("#areaMapName").html(allHKMapName)):$("#"+n).closest("div").attr("id")=="kowloonHK"?($("#kowloonHK").show(),$("#mapKowloon").addClass("mapAreaHighlight"),$("#cntKowloon").addClass("mapCountHighlight"),$("#areaMapName").html(allKowloonMapName)):$("#"+n).closest("div").attr("id")=="newTerHK"?($("#newTerHK").show(),$("#mapNewTerr").addClass("mapAreaHighlight"),$("#cntNewTerr").addClass("mapCountHighlight"),$("#areaMapName").html(allNewTerrMapName)):($("#mainHK").show(),$("#mapAllArea").show(),$("#mapAllArea").addClass("mapAreaHighlight"),$("#cntAllArea").addClass("mapCountHighlight"),$("#areaMapName").html("&nbsp;"))}function ft(){var n="";n=currentSelectedTab==2?$("#hdnAllIds").val():$("#hdnSaleAllIds").val(),arrAllIds=n.split(","),$.each(arrAllIds,function(n){l(arrAllIds[n]),h(arrAllIds[n])})}function nt(){$("path").each(function(){$(this).attr("isMain")==undefined&&($(this).attr("class","svgPathDisable"),$(this).css("fill","#919296"))}),$("#cntAllArea").html(""),$("#cntHKArea").html(""),$("#cntKowloon").html(""),$("#cntNewTerr").html(""),$("#cntOutlying").html("")}var s,g;$("#svg-content").html(n),(currentLanguageId==2||currentLanguageId==3)&&($("#newTerName, #outlyingName, #kowloonName, #hkIslandName").css("font-size","13px"),$("#tspan3003-5-9").attr({x:235,y:145}),$("#tspan3003-5-7").attr({x:100,y:305}),$("#tspan3003-5").attr("x","305"),$("#tspan3003").attr("x","300")),b(languageid,2),$(".postingPurpose").click(function(){nt();var n=$(this).attr("id");$(".postingPurpose").removeClass("active"),$(this).addClass("active"),currentSelectedTab=parseInt(n.substring(n.length-1)),b(languageid,currentSelectedTab),k(),Currentlanguageid=="1"?$("#distAreasText").text("Districts/Areas"):Currentlanguageid=="2"?$("#distAreasText").text("地區"):Currentlanguageid=="3"&&$("#distAreasText").text("地区"),populateMinMaxPrices(currentSelectedTab),w(),$(".districtArea").find("input:checkbox").removeAttr("checked"),$(".features").find("input:checkbox").removeAttr("checked"),$("#featuresFacilitesText").text(Features_Text),$("#DisfeaturesFacilitesText").text(Features_Text),$(".features").css("display","none")}),$("#btnSubmit").click(function(){var n,t=0,i,r;($("#txtFullName").val()==Global_Search_FullName?(t=1,$(".errorMsg").show(),$(".errorFN").show(),$("#txtFullName").addClass("inputError"),$("#gsFullName").css("left",-($("#gsFullName div").outerWidth()-115)),n=!1):($(".errorFN").hide(),$("#txtFullName").removeClass("inputError"),n=!0),$("#txtEmailID").val()==Global_Search_Email?(t=1,$(".errorMsg").show(),$(".errorEmail").show(),$("#txtEmailID").addClass("inputError"),$("#gsEmail").css("left",-($("#gsEmail div").outerWidth()-115)),n=!1):(i=/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,i.test($("#txtEmailID").val())?($(".errorEmail").hide(),$("#txtEmailID").removeClass("inputError"),n=!0):(t=1,$(".errorEmail").show(),$("#txtEmailID").addClass("inputError"),$("#gsEmail").css("left",-($("#gsEmail div").outerWidth()-115)),n=!1)),$("#txtCityBudget").val()==Global_Search_City_Budget?(t=1,$(".errorMsg").show(),$(".errorBudget").show(),$("#txtCityBudget").addClass("inputError"),$("#gsBudget").css("left",-($("#gsBudget div").outerWidth()-115)),n=!1):($(".errorBudget").hide(),$("#txtCityBudget").removeClass("inputError"),n=!0),t!=1)&&(showLoader(),r=JSON.stringify({FullName:$("#txtFullName").val(),PhoneNumber:$("#txtPhoneNo").val(),Email:$("#txtEmailID").val(),Budget:$("#txtCityBudget").val(),UserComments:"",PropertiesOfInterest:"",InternationalPropertiesofInterest:"",Preferredlanguage:"",preferredAgentName:"",NewsLetter:"",popuptype:4}),$.ajax({type:"POST",url:"/Homepage/Default.aspx/SavePropertyEnquiries",contentType:"application/json; charset=utf-8",data:r,dataType:"json",success:function(n){n.d!=""&&(hideLoader(),$(".srchSuccess").show(),setTimeout(function(){$(".srchSuccess").hide(),$("#txtFullName").val(Global_Search_FullName),$("#txtEmailID").val(Global_Search_Email),$("#txtPhoneNo").val(Global_Search_Phone_Number),$("#txtCityBudget").val(Global_Search_City_Budget)},5e3))},failure:FailureHandler}))}),populateMinMaxPrices(currentSelectedTab),w(),$("[id*='searchProperties']").click(function(){p()}),$("[id*='MapSearchProp']").click(function(){tt()}),$("[id*='ActivateSearch']").click(function(){p()}),$("path").mouseover(function(){var r="",t="",i,n;r=currentSelectedTab==2?$("#hdnAllIds").val():$("#hdnSaleAllIds").val(),$(this).attr("class")=="disExists"?(t=$(this).attr("id"),t=="1_1"&&(t="1"),e(t,r)||(t=="1"?($("#1").css("fill","#055762"),$("#1_1").css("fill","#055762")):$(this).css("fill","#055762"))):$(this).css("fill","#919296"),i=$(this).attr("id"),i=="1_1"&&(i=1),n=$("#chkDistrict_"+i).next("label").html(),n!=undefined&&(n=n.substring(0,n.indexOf("(")-1),$("#hoverMapName").html(n))}),$("path").mouseout(function(){var t="",n="";t=currentSelectedTab==2?$("#hdnAllIds").val():$("#hdnSaleAllIds").val(),$(this).attr("class")=="disExists"?(n=$(this).attr("id"),n=="1_1"&&(n="1"),e(n,t)||(n=="1"?($("#1").css("fill","#05aba3"),$("#1_1").css("fill","#05aba3")):$(this).css("fill","#05aba3"))):$(this).css("fill","#919296"),$("#hoverMapName").html("&nbsp;")}),$("#M3, #M4, #M5, #M6, #M7, #outlyingName").mouseover(function(){$("#M3, #M4, #M5, #M6, #M7").css("fill","#055762"),$("#outlyingName").css("fill","#ffffff"),$("#hoverMapName").html(allOutlyingMapName)}),$("#M3, #M4, #M5, #M6, #M7,#outlyingName").mouseout(function(){$("#M3, #M4, #M5, #M6, #M7").css("fill","#05aba3"),$("#outlyingName").css("fill","#000000"),$("#hoverMapName").html("")}),$("#newTerName, #M8").mouseover(function(){$("#M8").css("fill","#055762"),$("#newTerName").css("fill","#fff"),$("#hoverMapName").html(allNewTerrMapName)}),$("#newTerName, #M8").mouseout(function(){$("#M8").css("fill","#05aba3"),$("#newTerName").css("fill","#000"),$("#hoverMapName").html("")}),$("#kowloonName, #M2").mouseover(function(){$("#M2").css("fill","#055762"),$("#kowloonName").css("fill","#fff"),$("#hoverMapName").html(allKowloonMapName)}),$("#kowloonName, #M2").mouseout(function(){$("#M2").css("fill","#05aba3"),$("#kowloonName").css("fill","#000"),$("#hoverMapName").html("")}),$("#hkIslandName, #M1").mouseover(function(){$("#M1").css("fill","#055762"),$("#hkIslandName").css("fill","#fff"),$("#hoverMapName").html(allHKMapName)}),$("#hkIslandName, #M1").mouseout(function(){$("#M1").css("fill","#05aba3"),$("#hkIslandName").css("fill","#000"),$("#hoverMapName").html("")}),$("path").attr("pointer-events","all"),$("#M3, #M4, #M5, #M6, #M7, #mapOutlying, #outlyingName").click(function(){t($("#outlyingHK"),$("#mapOutlying"),$("#cntOutlying"),allOutlyingMapName)}),$("#M1, #mapHKArea, #hkIslandName").click(function(){t($("#islandHK"),$("#mapHKArea"),$("#cntHKArea"),allHKMapName)}),$("#M2, #mapKowloon, #kowloonName").click(function(){t($("#kowloonHK"),$("#mapKowloon"),$("#cntKowloon"),allKowloonMapName)}),$("#M8, #mapNewTerr, #newTerName").click(function(){t($("#newTerHK"),$("#mapNewTerr"),$("#cntNewTerr"),allNewTerrMapName)}),$("#mapAllArea").click(function(){t($("#mainHK"),$("#mapAllArea"),$("#cntAllArea"),"")}),$("path").click(function(){id=$(this).attr("id"),id=="1_1"&&(id="1"),disId=id,$("#chkDistrict_"+disId).length>0&&($("#"+id).closest("div").attr("id")=="outlyingHK"?currentSelectedTab==2?i(id,$("#hdnOutlyingIds"),"cntOutlying"):i(id,$("#hdnSaleOutlyingIds"),"cntOutlying"):$("#"+id).closest("div").attr("id")=="islandHK"?currentSelectedTab==2?i(id,$("#hdnIslandIds"),"cntHKArea"):i(id,$("#hdnSaleIslandIds"),"cntHKArea"):$("#"+id).closest("div").attr("id")=="kowloonHK"?currentSelectedTab==2?i(id,$("#hdnKowloonIds"),"cntKowloon"):i(id,$("#hdnSaleKowloonIds"),"cntKowloon"):$("#"+id).closest("div").attr("id")=="newTerHK"&&(currentSelectedTab==2?i(id,$("#hdnNewTerIds"),"cntNewTerr"):i(id,$("#hdnSaleNewTerIds"),"cntNewTerr")),l(disId))}),$(".mapSearch").click(function(n){n.stopPropagation(),$(".mapSearch").show()}),$(".closemap").click(function(n){n.stopPropagation(),$(".districtArea").slideUp(),$(".mapSearch, .map > svg").animate({width:"0"}),$(".mapSearch").css("border",0),$(".mapSelect, .closemap, .map > svg, .hoverMap").css("display","none")});var rt=$("#searchSection").offset(),ut=$("#drpDistrictArea").offset(),f=ut.top-rt.top;mapLeft=$("#searchSection").offset().left+$("#searchSection").outerWidth(),$(".mapSearch").css("left",mapLeft),$(".districtArea").css("left",$("#drpDistrictArea").offset().left),$(".districtArea").css("top",$("#drpDistrictArea").offset().top+$("#drpDistrictArea").outerHeight()-1),$(".mapSearch").css("top",$("#searchSection").offset().top),s=$(".mapSearch").outerHeight()-(f+$("#drpDistrictArea").outerHeight()+1),$(".districtArea").css("height",s),$(window).resize(function(){$(".districtArea").css("left",$("#drpDistrictArea").offset().left),$(".districtArea").css("top",$("#drpDistrictArea").offset().top+$("#drpDistrictArea").outerHeight()-1),$(".mapSearch").css("top",$("#searchSection").offset().top);var n=$(".mapSearch").outerHeight()-(f+$("#drpDistrictArea").outerHeight()+$(".districtAreaSearch").innerHeight()+1);$(".districtAreaWrapper").css("height",n),mapLeft=$("#searchSection").offset().left+$("#searchSection").outerWidth(),$(".mapSearch").css("left",mapLeft)}),$("path").each(function(){$(this).attr("class")=="disExists"?$(this).css("fill","#05aba3"):$(this).css("fill","#919296")}),g=!!navigator.userAgent.match(/Trident.*rv\:11\./),document.all||g==!0?($("#outlyingName").text(allOutlyingMapName),$("#hkIslandName").text(allHKMapName),$("#kowloonName").text(allKowloonMapName),$("#newTerName").text(allNewTerrMapName)):($("#outlyingName tspan").html(allOutlyingMapName),$("#hkIslandName tspan").html(allHKMapName),$("#kowloonName tspan").html(allKowloonMapName),$("#newTerName tspan").html(allNewTerrMapName)),$("selector").colorbox({onLoad:function(){$("#cboxClose").remove()}})}function populateMinMaxPrices(n){n==1&&(currencyid==1&&(MinPriceArray_Int=["500K","750K","1M","1.5M","2M","2.5M","3M","3.5M","4M","5M","6M","7M","8M","9M","10M","12M","14M","16M","18M","20M","25M","28M","30M"],MaxPriceArray_Int=MinPriceArray_Int.slice(0),MaxPriceArray_Int.push("30M+")),currencyid==2&&(MinPriceArray_Int=["500K","700K","900K","1M","1.5M","2M","2.5M","3M","3.5M","4M","5M","6M","7M","8M","9M","10M","12M","14M","16M","18M","20M","22M","25M"],MaxPriceArray_Int=MinPriceArray_Int.slice(0),MaxPriceArray_Int.push("25M+")),(currencyid==3||currencyid==4)&&(MinPriceArray_Int=["4M","6M","8M","10M","12M","14M","16M","18M","20M","25M","30M","35M","40M","45M","50M","60M","70M","80M","90M","100M","150M","200M","250M"],MaxPriceArray_Int=MinPriceArray_Int.slice(0),MaxPriceArray_Int.push("250M+")),currencyid==5&&(MinPriceArray_Int=["400K","500K","600K","800K","1M","1.5M","2M","2.5M","3M","3.5M","4M","4.5M","5M","6M","7M","8M","9M","10M","12M","14M","16M","18M","20M"],MaxPriceArray_Int=MinPriceArray_Int.slice(0),MaxPriceArray_Int.push("20M+"))),n==2&&(currencyid==1&&(MinPriceArray_Int=["1K","2K","3K","4K","5K","6K","7K","8K","9K","10K","11K","12K","13K","14K","15K","16K","17K","18K","19K","20K","21K","23K","25K"],MaxPriceArray_Int=MinPriceArray_Int.slice(0),MaxPriceArray_Int.push("25K+")),currencyid==2&&(MinPriceArray_Int=["1K","1.5K","2K","2.5K","3K","3.5K","4K","5K","6K","7K","8K","9K","10K","11K","12K","13K","14K","15K","16K","17K","18K","19K","20K"],MaxPriceArray_Int=MinPriceArray_Int.slice(0),MaxPriceArray_Int.push("20K+")),(currencyid==3||currencyid==4)&&(MinPriceArray_Int=["10K","15K","20K","25K","30K","35K","40K","45K","50K","55K","60K","65K","70K","75K","80K","85K","90K","95K","100K","125K","150K","175K","200K"],MaxPriceArray_Int=MinPriceArray_Int.slice(0),MaxPriceArray_Int.push("200K+")),currencyid==5&&(MinPriceArray_Int=["800","1K","1.5K","2K","2.5K","3K","3.5K","4K","4.5K","5K","5.5K","6K","6.5K","7K","8K","9K","10K","11K","12K","13K","14K","15K","16K"],MaxPriceArray_Int=MinPriceArray_Int.slice(0),MaxPriceArray_Int.push("16K+"))),populateDropdownMarkup(MinPriceArray_Int,$("#drpPriceMin"),currentcurrencysymbol+" "+Min_price_Text),populateDropdownMarkup(MaxPriceArray_Int,$("#drpPriceMax"),currentcurrencysymbol+" "+Max_Price_Text),populateDropdownMarkup(MinPriceArray_Int,$("#drpDistrictPriceMin"),currentcurrencysymbol+" "+Min_price_Text),populateDropdownMarkup(MaxPriceArray_Int,$("#drpDistrictPriceMax"),currentcurrencysymbol+" "+Max_Price_Text)}$(document).ready(function(){function f(n,t){return t=Math.pow(10,t),n=n*t,n=Math.round(n),n=n/t}function e(n,t){return n=n/t,n=Math.round(n)*t}function c(){var e=$("#finalResult").text(),n,u,t,i,f,r;e=e.replace(/\,/g,""),n=e,currencyid==1&&(i=[5e5,75e4,1e6,15e5,2e6,25e5,3e6,35e5,4e6,5e6,6e6,7e6,8e6,9e6,1e7,12e6,14e6,16e6,18e6,2e7,25e6,28e6,3e7],n<5e5?(u=5e5,t=5e5):jQuery.inArray(n,i)==-1?(r=jQuery.grep(i,function(t){return parseInt(t)<n}),f=jQuery.grep(i,function(t){return parseInt(t)>n}),u=Math.max.apply(Math,r),t=Math.min.apply(Math,f),t=="Infinity"&&(t=-1)):(r=jQuery.grep(i,function(t){return parseInt(t)<n}),u=Math.max.apply(Math,r),t=n)),currencyid==2&&(i=[5e5,7e5,9e5,1e6,2e6,25e5,3e6,35e5,4e6,5e6,6e6,7e6,8e6,9e6,1e7,12e6,14e6,16e6,18e6,2e7,22e6,25e6],n<5e5?(u=5e5,t=5e5):jQuery.inArray(n,i)==-1?(r=jQuery.grep(i,function(t){return parseInt(t)<=n}),f=jQuery.grep(i,function(t){return parseInt(t)>n}),u=Math.max.apply(Math,r),t=Math.min.apply(Math,f),t=="Infinity"&&(t=-1)):(r=jQuery.grep(i,function(t){return parseInt(t)<n}),u=Math.max.apply(Math,r),t=n)),(currencyid==3||currencyid==4)&&(i=[4e6,6e6,8e6,1e7,12e6,14e6,16e6,18e6,2e7,25e6,3e7,35e6,4e7,45e6,5e7,6e7,7e7,8e7,9e7,1e8,15e7,2e8,25e7],currencyid==3?n==4e6?(u=0,t=4e6):n==25e7?(u=4e6,t=25e7):n<4e6?(u=4e6,t=4e6):n>25e7?(u=25e7,t=-1):jQuery.inArray(n,i)==-1?(r=jQuery.grep(i,function(t){return parseInt(t)<=n}),f=jQuery.grep(i,function(t){return parseInt(t)>n}),u=Math.max.apply(Math,r),t=Math.min.apply(Math,f),t=="Infinity"&&(t=-1)):(r=jQuery.grep(i,function(t){return parseInt(t)<n}),u=Math.max.apply(Math,r),t=n):n<4e6?(u=4e6,t=4e6):jQuery.inArray(n,i)==-1?(r=jQuery.grep(i,function(t){return parseInt(t)<=n}),f=jQuery.grep(i,function(t){return parseInt(t)>n}),u=Math.max.apply(Math,r),t=Math.min.apply(Math,f),t=="Infinity"&&(t=-1)):(r=jQuery.grep(i,function(t){return parseInt(t)<n}),u=Math.max.apply(Math,r),t=n)),currencyid==5&&(i=[4e5,5e5,6e5,8e5,1e6,15e5,2e6,25e5,3e6,35e5,4e6,45e5,5e6,6e6,7e6,8e6,9e6,1e7,12e6,14e6,16e6,18e6,2e7],n<4e5?(u=4e5,t=4e5):jQuery.inArray(n,i)==-1?(r=jQuery.grep(i,function(t){return parseInt(t)<=n}),f=jQuery.grep(i,function(t){return parseInt(t)>n}),u=Math.max.apply(Math,r),t=Math.min.apply(Math,f),t=="Infinity"&&(t=-1)):(r=jQuery.grep(i,function(t){return parseInt(t)<n}),u=Math.max.apply(Math,r),t=n)),$("[id*='minprice']").val(u),$("[id*='maxprice']").val(t)}var o,u;$("#showPromo").hide(),$("#promoConfirmation").hide(),selectMenu($("#monthlyPayment"),150),selectMenu($("#downPayment"),150),selectMenu($("#drpPriceMin"),70),selectMenu($("#drpDistrictPriceMin"),70),selectMenu($("#drpDistrictPriceMax"),70),selectMenu($("#drpPriceMax"),70),selectMenu($("#drpBeds"),70),selectMenu($("#drpDistrictBeds"),70),selectMenu($("#drpSize"),99),selectMenu($("#drpDistrictSize"),99),selectMenu($("#drpFeatures"),103),selectMenu($("#drpCurrency"),55);var r=GetCurrentCurrency(),s=parseInt(GetCurrentLanguage()),l=["10K to 20K","20K to 30K","30K to 50K","50K to 70K","70K to 100K","200 to 250K","250K to 300K","400K+"],a=["1M to 3M","3M to 5M","5M to 10M","10M to 15M","15M to 20M","20M to 30M","30M to 50M","50M to 70M","70M to 100M","100M+"];currentSelectedTab="2",searchHomes=1,$.ajax({type:"POST",url:"/Homepage/Default.aspx/GetHomePageData",data:JSON.stringify({languageid:s,exchangerate:parseFloat(exchangerate)}),contentType:"application/json; charset=utf-8",dataType:"json",success:function(n){var i=JSON.parse(n.d),o="",y="",v="",w="",p,c=GetCurrentLanguage()==1?"en":GetCurrentLanguage()==2?"zh-t":GetCurrentLanguage()==3?"zh-s":"en";if(i.Table.length>0&&($.each(i.Table,function(n,t){var u=i.Table.length,r;p=t.Question.length>122?t.Question.substring(0,122)+" ...?":t.Question,y+="<article>",r="",t.TotalAnswers>=1&&(t.TotalAnswers>1&&(r="<i> ("+t.TotalAnswers+" answers)</i>"),t.TotalAnswers==1&&(r="<i> ("+t.TotalAnswers+" answer)</i>")),y+="<a href='"+WebsiteUrl+"/"+c+"/property-questions/"+trimUrlLength(replaceSpecialCharacters(t.Question.replace(/\?/g,"").replace(/\s+/g,"-")))+"/"+t.QuestionId+"'>"+p+r+"</a>",y+="</article>"}),$("#quesList").append(y)),i.Table1.length>0&&($.each(i.Table1,function(n,t){o+="<article>",o+=t.ImageName!=""?" <a href='"+WebsiteUrl+"/"+c+"/property-news/"+replaceSpecialCharacters(t.Url.replace(/\?/g,"").replace(/\s+/g,"-"))+"/"+t.TemplateId+"' title='"+replaceQuote($.htmlClean(t.Title))+"'><img alt='"+replaceQuote($.htmlClean(t.Title))+"' src='"+imagePath+ImageModules.Contents+"/"+ImageFolders.Original+"/"+t.ImageName+"' width='68' height='68'></a>":"<img alt='"+replaceQuote($.htmlClean(t.Title))+"' src='/CommonContent/Images/summary-icn-small.gif' width='68' height='68' />",o+="<div class='insightsHome'>",o+="<a href='"+WebsiteUrl+"/"+c+"/property-news/"+replaceSpecialCharacters(t.Url.replace(/\?/g,"").replace(/\s+/g,"-"))+"/"+t.TemplateId+"' title='"+replaceQuote($.htmlClean(t.Title))+"'>"+replaceQuote($.htmlClean(t.Title))+"</a>",o+=" <p>"+replaceQuote($.htmlClean(t.SubTitle))+"</p>",o+="</div></article>"}),$("#newsList").append(o)),i.Table4.length>0&&($.each(i.Table4,function(n,t){v+="<img alt='"+replaceQuote(t.AgentName)+"' src='"+imagePath+ImageModules.Agent+"/"+ImageFolders.Original+"/"+t.AgentImage+"'>",v+=" <h6>"+(t.AgentName.length>35?t.AgentName.substring(0,28)+" ...":t.AgentName)+"</h6>",t.AgentBio!=null&&(v+=" <p>"+(t.AgentBio.length>450?t.AgentBio.substring(0,449)+" ...":t.AgentBio)+"</p>"),v+="<a href='"+WebsiteUrl+"/"+(t.ProfileCategoryId==2||t.ProfileCategoryId==5?c+"/real-estate-agents/"+replaceSpecialCharacters(t.AgentName.trim().replace(/\?/g,"").replace(/\s+/g,"-"))+"/"+t.AgentId+"?ppid=1&pno=1":c+"/property-experts/"+replaceSpecialCharacters(t.AgentName.trim().replace(/\?/g,"").replace(/\s+/g,"-"))+"/"+t.AgentId)+"' title='"+replaceQuote($.htmlClean(ViewFullProfile))+"'>"+ViewFullProfile+"</a>"}),$("#profileBox").append(v),$(".profileBox *").not("img").wrapAll("<div></div>")),i.Table2.length>0&&$.each(i.Table2,function(n,t){t.ImageName!=""&&$("#TotalNoOfPropertiesHK").append(t.TotalNoOfPropertiesHK)}),i.Table3.length>0&&($.each(i.Table3,function(n,t){var i,u,o;t.PropertyID!=null&&t.PropertyID!=undefined?(saleprice="",leaseprice="",issolegeant="",t.IsSoleAgent?issolegeant="Sole Agent - ":issoleagent="",t.IsSaleSTO?(saleprice=Price_Subject_To_Offer,saleprice+=" | "):r==3||r==4?t.SalePrice!="0.00"&&(saleprice=currentCurrencyName+" "+commaSeparateNumber(f(t.ConvertedSalePrice.toString(),2))+" M",saleprice+=" | "):t.SalePrice!="0.00"&&(i=commaSeparateNumber(e(t.ConvertedSalePrice*1e6,100)),saleprice=currentCurrencyName+" "+i,saleprice+=" | "),t.IsLeaseSTO?(leaseprice=Price_Subject_To_Offer,leaseprice+=" | "):r==3||r==4?t.LeasePrice!="0.00"&&(leaseprice=currentCurrencyName+" "+commaSeparateNumber(f(t.ConvertedLeasePrice.toString(),2))+" K",t.LeaseInc=="I"&&(leaseprice+=" "+inclText),t.LeaseInc=="E"&&(leaseprice+=" "+exclText),leaseprice+=" | "):t.LeasePrice!="0.00"&&(u=commaSeparateNumber(e(t.ConvertedLeasePrice*1e3,100)),leaseprice=currentCurrencyName+" "+u,t.LeaseInc=="I"&&(leaseprice+=" "+inclText),t.LeaseInc=="E"&&(leaseprice+=" "+exclText),leaseprice+=" | "),o=GetCurrentLanguage()==1?"en":GetCurrentLanguage()==2?"zh-t":GetCurrentLanguage()==3?"zh-s":"en",$("#featuredProperties").append("<li><a href='"+WebsiteUrl+"/"+o+"/property/"+(t.PostingPurposeID.toString()=="1"?"sale":t.PostingPurposeID.toString()=="2"?"rent":"rent-sale")+"/"+t.PropertyID+"-"+replaceSpecialCharacters(t.PropertyName.replace(/\ /g,"-"))+"/"+t.PropertyID+"'><img src='"+imagePath+ImageModules.HotProperty+"/"+ImageFolders.Folder150+"/"+t.ImageName+"' style='width:100%;height:316px;'/><p class='caption'>"+issolegeant+"<b>"+t.PropertyName+"</b> | "+saleprice+leaseprice+t.DistrictName+"</p></a></li>")):$("#featuredProperties").append("<li><a "+(t.RefLink!=null&&t.RefLink!=undefined&&$.trim(t.RefLink)!=""?'target="_blank"':"")+(t.RefLink!=null&&t.RefLink!=undefined&&$.trim(t.RefLink)!=""?'href="'+(t.RefLink.indexOf("http:")<0?"http://"+t.RefLink:t.RefLink)+'"':"")+"><img alt='"+(t.AltTag!=null?t.AltTag:"")+"' src='"+imagePath+ImageModules.HotProperty+"/"+ImageFolders.Folder150+"/"+t.ImageName+"' style='width:100%;height:316px;'/></a></li>")}),initializeBannerSlider()),i.Table6.length>0){var s="",h="",u=i.Table6;s+="<li><input type=checkbox class='chkFeatures ff' id='hasmaidroom'><label for='hasmaidroom'>"+u[0].hasmaidroom+"</label></li>",s+="<li><input type=checkbox class='chkFeatures ff' id='hasbalcony'><label for='hasbalcony'>"+u[0].hasbalcony+"</label></li>",s+="<li><input type=checkbox class='chkFeatures ff' id='hasterrace'><label for='hasterrace'>"+u[0].hasterrace+"</label></li>",s+="<li><input type=checkbox class='chkFeatures ff' id='hasrooftop'><label for='hasrooftop'>"+u[0].hasrooftop+"</label></li>",s+="<li><input type=checkbox class='chkFeatures ff' id='hasgarden'><label for='hasgarden'>"+u[0].hasgarden+"</label></li>",s+="<li><input type=checkbox class='chkFeatures ff' id='hasparking'><label for='hasparking'>"+u[0].hasparking+"</label></li>",h+="<li><input type=checkbox class='chkdisFeatures disff' id='dishasmaidroom'><label for='hasmaidroom'>"+u[0].hasmaidroom+"</label></li>",h+="<li><input type=checkbox class='chkdisFeatures disff' id='dishasbalcony'><label for='hasbalcony'>"+u[0].hasbalcony+"</label></li>",h+="<li><input type=checkbox class='chkdisFeatures disff' id='dishasterrace'><label for='hasterrace'>"+u[0].hasterrace+"</label></li>",h+="<li><input type=checkbox class='chkdisFeatures disff' id='dishasrooftop'><label for='hasrooftop'>"+u[0].hasrooftop+"</label></li>",h+="<li><input type=checkbox class='chkdisFeatures disff' id='dishasgarden'><label for='hasgarden'>"+u[0].hasgarden+"</label></li>",h+="<li><input type=checkbox class='chkdisFeatures disff' id='dishasparking'><label for='hasparking'>"+u[0].hasparking+"</label></li>",$("#drpFeaturesList").append(s),$("#drpDisFeaturesList").append(h)}if(i.Table7.length>0){var l="",a="",t=i.Table7;l+="<li><input type=checkbox class='chkFacilities ff' id='feat_1' value="+t[0]["1"]+"><label for='feat_1'>"+t[0]["1"]+"</label></li>",l+="<li><input type=checkbox class='chkFacilities ff' id='feat_2' value="+t[0]["2"]+"><label for='feat_2'>"+t[0]["2"]+"</label></li>",l+="<li><input type=checkbox class='chkFacilities ff' id='feat_4' value="+t[0]["4"]+"><label for='feat_4'>"+t[0]["4"]+"</label></li>",l+="<li><input type=checkbox class='chkFacilities ff' id='feat_10' value="+t[0]["10"]+"><label for='feat_10'>"+t[0]["10"]+"</label></li>",l+="<li><input type=checkbox class='chkFacilities ff' id='feat_pool' value="+t[0].pool+"><label for='feat_pool'>"+t[0].pool+"</label></li>",a+="<li><input type=checkbox class='chkdisFacilities disff' id='disfeat_1' value="+t[0]["1"]+"><label for='feat_1'>"+t[0]["1"]+"</label></li>",a+="<li><input type=checkbox class='chkdisFacilities disff' id='disfeat_2' value="+t[0]["2"]+"><label for='feat_2'>"+t[0]["2"]+"</label></li>",a+="<li><input type=checkbox class='chkdisFacilities disff' id='disfeat_4' value="+t[0]["4"]+"><label for='feat_4'>"+t[0]["4"]+"</label></li>",a+="<li><input type=checkbox class='chkdisFacilities disff' id='disfeat_10' value="+t[0]["10"]+"><label for='feat_10'>"+t[0]["10"]+"</label></li>",a+="<li><input type=checkbox class='chkdisFacilities disff' id='disfeat_pool' value="+t[0].pool+"><label for='feat_pool'>"+t[0].pool+"</label></li>",$("#facilitiesList").append(l),$("#disfacilitiesList").append(a)}$(".ff:checked, .disff:checked").length>0?$(this).hasClass("ff")?$("#featuresFacilitesText").text("Selected ("+$(".ff:checked").length+")"):$("#DisfeaturesFacilitesText").text("Selected ("+$(".disff:checked").length+")"):$(this).hasClass("ff")?$("#featuresFacilitesText").text(Features_Text):$("#DisfeaturesFacilitesText").text(Features_Text),$(".disff").change(function(){$(this).is(":checked")?$("#DisfeaturesFacilitesText").text("Selected ("+$(".disff:checked").length+")"):$(".disff:checked").length==0?$("#DisfeaturesFacilitesText").text(Features_Text):$("#DisfeaturesFacilitesText").text("Selected ("+$(".disff:checked").length+")"),$("#dishasmaidroom").is(":checked")?$("#hasmaidroom").prop("checked",!0):$("#hasmaidroom").prop("checked",!1),$("#dishasbalcony").is(":checked")?$("#hasbalcony").prop("checked",!0):$("#hasbalcony").prop("checked",!1),$("#dishasterrace").is(":checked")?$("#hasterrace").prop("checked",!0):$("#hasterrace").prop("checked",!1),$("#dishasrooftop").is(":checked")?$("#hasrooftop").prop("checked",!0):$("#hasrooftop").prop("checked",!1),$("#dishasgarden").is(":checked")?$("#hasgarden").prop("checked",!0):$("#hasgarden").prop("checked",!1),$("#dishasparking").is(":checked")?$("#hasparking").prop("checked",!0):$("#hasparking").prop("checked",!1),$(".ff:checked").length==0?$("#featuresFacilitesText").text(Features_Text):$("#featuresFacilitesText").text("Selected ("+$(".ff:checked").length+")")}),$(".ff").change(function(){$(this).is(":checked")?$("#featuresFacilitesText").text("Selected ("+$(".ff:checked").length+")"):$(".ff:checked").length==0?$("#featuresFacilitesText").text(Features_Text):$("#featuresFacilitesText").text("Selected ("+$(".ff:checked").length+")"),$("#hasmaidroom").is(":checked")?$("#dishasmaidroom").prop("checked",!0):$("#dishasmaidroom").prop("checked",!1),$("#hasbalcony").is(":checked")?$("#dishasbalcony").prop("checked",!0):$("#dishasbalcony").prop("checked",!1),$("#hasterrace").is(":checked")?$("#dishasterrace").prop("checked",!0):$("#dishasterrace").prop("checked",!1),$("#hasrooftop").is(":checked")?$("#dishasrooftop").prop("checked",!0):$("#dishasrooftop").prop("checked",!1),$("#hasgarden").is(":checked")?$("#dishasgarden").prop("checked",!0):$("#dishasgarden").prop("checked",!1),$("#hasparking").is(":checked")?$("#dishasparking").prop("checked",!0):$("#dishasparking").prop("checked",!1),$(".disff:checked").length==0?$("#DisfeaturesFacilitesText").text(Features_Text):$("#DisfeaturesFacilitesText").text("Selected ("+$(".disff:checked").length+")")}),$(".chkFacilities ").change(function(){$("#feat_4").is(":checked")?$("#disfeat_4").prop("checked",!0):$("#disfeat_4").prop("checked",!1),$("#feat_1").is(":checked")?$("#disfeat_1").prop("checked",!0):$("#disfeat_1").prop("checked",!1),$("#feat_2").is(":checked")?$("#disfeat_2").prop("checked",!0):$("#disfeat_2").prop("checked",!1),$("#feat_10").is(":checked")?$("#disfeat_10").prop("checked",!0):$("#disfeat_10").prop("checked",!1),$("#feat_pool").is(":checked")?$("#disfeat_pool").prop("checked",!0):$("#disfeat_pool").prop("checked",!1),$(".disff:checked").length==0?$("#DisfeaturesFacilitesText").text(Features_Text):$("#DisfeaturesFacilitesText").text("Selected ("+$(".disff:checked").length+")")}),$(".chkdisFacilities ").change(function(){$("#disfeat_4").is(":checked")?$("#feat_4").prop("checked",!0):$("#feat_4").prop("checked",!1),$("#disfeat_1").is(":checked")?$("#feat_1").prop("checked",!0):$("#feat_1").prop("checked",!1),$("#disfeat_2").is(":checked")?$("#feat_2").prop("checked",!0):$("#feat_2").prop("checked",!1),$("#disfeat_10").is(":checked")?$("#feat_10").prop("checked",!0):$("#feat_10").prop("checked",!1),$("#disfeat_pool").is(":checked")?$("#feat_pool").prop("checked",!0):$("#feat_pool").prop("checked",!1),$(".ff:checked").length==0?$("#featuresFacilitesText").text(Features_Text):$("#featuresFacilitesText").text("Selected ("+$(".disff:checked").length+")")}),w+="<a style='text-transform: none;' href='http://www.okay.com/"+c+"/property-news/PART-1-Peter-Churchouses-Rules-for-Buying-Real-Estate--Introduction--Rules-1-3/153?nid=57#.U-wqSvmSyZM' title='Peter Churchouse’s Rules for Buying Real Estate'>Peter Churchouse’s Rules for Buying Real Estate</a>",$("#guideList").append(w),$(".homeNewsInsights article > div *").dotdotdot()}}),o=$("body").width(),u=(o-1e3)/2,$(".silderLeft").css("width",u),$(".silderRight").css("width",u),$(".sliderMid").bjqs({animtype:"slide",height:316,width:1e3,responsive:!0,randomstart:!1}),$("input:radio").screwDefaultButtons({image:'url("/CommonContent/images/radio-btn-bg.png")',height:19});var n=WebsiteUrl+"/CommonContent/Images/",t=[[n+"cnbc-logo.gif","OKAY.com Property News Coverage, CNBC","47"],[n+"forbes-logo.gif","OKAY.com Property News Coverage, Forbes","60"],[n+"scmp-logo.gif","OKAY.com Property News Coverage, South China Morning Post","58"],[n+"rthk-logo.gif","OKAY.com Property News Coverage, RTHK","48"],[n+"bloomberg-logo.gif","OKAY.com Property News Coverage, Bloomberg","104"],[n+"oriental-daily-news-logo.gif","OKAY.com Property News Coverage, Oriental Daily News","83"],[n+"hk-economic-times-logo.gif","OKAY.com Property News Coverage, Hong Kong Economic Times","86"],[n+"red-herring-winner-logo.gif","OKAY.com Property News Coverage, Red Herring Winner","51"],[n+"im-logo.gif","OKAY.com Property News Coverage, iMoney","49"]],h=$("#logoLists");for(i=0;i<t.length;i++)h.append("<li><a href='"+WebsiteUrl+"/"+(currentLanguageId==1?"en":currentLanguageId==2?"zh-t":currentLanguageId==3?"zh-s":"en")+"/about-us/in-the-press' title='"+t[i][1]+"'><img src='"+t[i][0]+"' alt='"+t[i][1]+"' width='"+t[i][2]+"' height='51'></a></li>");$("#drpPriceMin").change(function(){var n=$("#drpPriceMin option:selected").val(),t,r,u,f,e,i;n!="0"?(t=n.indexOf("M")!=-1?"M":n.indexOf("K")!=-1?"K":"",t==""?u=n:(r=n.indexOf("+")!=-1?n.substring(0,n.length-2):n.substring(0,n.length-1),t=="M"&&(u=parseFloat(r)*1e6),t=="K"&&(u=parseFloat(r)*1e3)),f=[],$("#drpPriceMax option").each(function(){if($(this).val()!="0"){var n=$(this).val(),t,i,r;t=n.indexOf("M")!=-1?"M":n.indexOf("K")!=-1?"K":"",t==""?r=n:(i=n.indexOf("+")!=-1?n.substring(0,n.length-2):n.substring(0,n.length-1),t=="M"&&(r=parseFloat(i)*1e6),t=="K"&&(r=parseFloat(i)*1e3)),f.push(r)}}),e=jQuery.grep(f,function(n){return n>u}),i=[],$.each(e,function(n,t){t>=1e6?i.push(t/1e6+"M"):t>=1e3?i.push(t/1e3+"K"):i.push(t)}),populateDropdownMarkup(i,$("#drpPriceMax"),currentcurrencysymbol+" "+Max_Price_Text),$("#drpPriceMax option").last().text($("#drpPriceMax option").last().text()+"+"),$("#drpPriceMax option").last().val($("#drpPriceMax option").last().val()+"+")):populateMinMaxPrices(currentSelectedTab),selectMenu($("#drpPriceMax"),70),$("#drpDistrictPriceMin").val(n).attr("selected","selected"),selectMenu($("#drpDistrictPriceMin"),70),$("#drpDistrictPriceMax").val($("#drpPriceMax option:selected").val()).attr("selected","selected"),selectMenu($("#drpDistrictPriceMax"),70)}),$("#drpDistrictPriceMin").change(function(){var n=$("#drpDistrictPriceMin option:selected").val(),t,r,u,f,e,i;n!="0"?(t=n.indexOf("M")!=-1?"M":n.indexOf("K")!=-1?"K":"",t==""?u=n:(r=n.indexOf("+")!=-1?n.substring(0,n.length-2):n.substring(0,n.length-1),t=="M"&&(u=parseFloat(r)*1e6),t=="K"&&(u=parseFloat(r)*1e3)),f=[],$("#drpDistrictPriceMax option").each(function(){if($(this).val()!="0"){var n=$(this).val(),t,i,r;t=n.indexOf("M")!=-1?"M":n.indexOf("K")!=-1?"K":"",t==""?r=n:(i=n.indexOf("+")!=-1?n.substring(0,n.length-2):n.substring(0,n.length-1),t=="M"&&(r=parseFloat(i)*1e6),t=="K"&&(r=parseFloat(i)*1e3)),f.push(r)}}),e=jQuery.grep(f,function(n){return n>u}),i=[],$.each(e,function(n,t){t>=1e6?i.push(t/1e6+"M"):t>=1e3?i.push(t/1e3+"K"):i.push(t)}),populateDropdownMarkup(i,$("#drpDistrictPriceMax"),currentcurrencysymbol+" "+Max_Price_Text),$("#drpDistrictPriceMax option").last().text($("#drpDistrictPriceMax option").last().text()+"+"),$("#drpDistrictPriceMax option").last().val($("#drpDistrictPriceMax option").last().val()+"+")):populateMinMaxPrices(currentSelectedTab),selectMenu($("#drpDistrictPriceMax"),70),$("#drpPriceMin").val(n).attr("selected","selected"),selectMenu($("#drpPriceMin"),70),$("#drpPriceMax").val($("#drpDistrictPriceMax option:selected").val()).attr("selected","selected"),selectMenu($("#drpPriceMax"),70)}),$("#drpDistrictPriceMax").change(function(){$("#drpPriceMax").val($("#drpDistrictPriceMax option:selected").val()).attr("selected","selected"),selectMenu($("#drpPriceMax"),70)}),$("#drpPriceMax").change(function(){$("#drpDistrictPriceMax").val($("#drpPriceMax option:selected").val()).attr("selected","selected"),selectMenu($("#drpDistrictPriceMax"),70)}),$('input:radio[name="newLeaseType"]').change(function(){$(this).val()=="2"?($("#gross").removeAttr("checked"),$("#gross").parent().css("background-position","50% 0"),$("#saleable").attr("checked",!0),$("#saleable").parent().css("background-position","50% -19px")):($("#saleable").removeAttr("checked"),$("#saleable").parent().css("background-position","50% 0"),$("#gross").attr("checked",!0),$("#gross").parent().css("background-position","50% -19px"))}),$('input:radio[name="leaseType"]').change(function(){$(this).val()=="2"?($("#newGross").removeAttr("checked"),$("#newGross").parent().css("background-position","50% 0"),$("#newLease").attr("checked",!0),$("#newLease").parent().css("background-position","50% -19px")):($("#newLease").removeAttr("checked"),$("#newLease").parent().css("background-position","50% 0"),$("#newGross").attr("checked",!0),$("#newGross").parent().css("background-position","50% -19px"))}),$("#drpSize").change(function(){$("#drpDistrictSize").val($("#drpSize option:selected").val()).attr("selected","selected"),selectMenu($("#drpDistrictSize"),99)}),$("#drpDistrictSize").change(function(){$("#drpSize").val($("#drpDistrictSize option:selected").val()).attr("selected","selected"),selectMenu($("#drpSize"),99)}),$("#drpBeds").change(function(){$("#drpDistrictBeds").val($("#drpBeds option:selected").val()).attr("selected","selected"),selectMenu($("#drpDistrictBeds"),70)}),$("#drpDistrictBeds").change(function(){$("#drpBeds").val($("#drpDistrictBeds option:selected").val()).attr("selected","selected"),selectMenu($("#drpBeds"),70)}),populateMinMaxPrices(2),populateDropdownMarkup(NoOfBedsArray,$("#drpBeds"),Beds_Text),populateDropdownSize(GFAValuesArray,$("#drpSize"),Size_Text,Size_Text_Any),populateDropdownMarkup(NoOfBedsArray,$("#drpDistrictBeds"),Beds_Text),populateDropdownSize(GFAValuesArray,$("#drpDistrictSize"),Size_Text,Size_Text_Any),$("#searchSection").show(),$("[id*='txtSmartSearch']").autocomplete({messages:{noResults:"",results:function(){}},source:function(n,t){$.ajax({type:"POST",url:"/Homepage/Default.aspx/GetKeywordSearchResults_HK",contentType:"application/json; charset=utf-8",dataType:"json",data:JSON.stringify({keyword:$("[id*='txtSmartSearch']").val(),postingpurposeid:currentSelectedTab}),success:function(n){t($.map(JSON.parse(n.d),function(n){return{value:n.result,label:n.result}}))},failure:FailureHandler})},minLength:3,open:function(){$(".ui-autocomplete").css("left","-=0"),$(".ui-autocomplete").css("top","+=0"),$(".ui-autocomplete").css("border-radius","0"),$(".ui-autocomplete").css("width","184")}}).data("uiAutocomplete")._renderItem=function(n,t){var i=String(t.label).replace(new RegExp(this.term,"gi"),"<strong style='color:#913030;font-size:14px; border:none;' class='ui-state-highlight'>$&</strong>"),r=["&apos;"],u=["'"];return i=i.replace(r,u),$("<li></li>").data("item.autocomplete",t).append("<a><span style='font-size:14px;padding:5px;'>"+i+"</span></a>").appendTo(n)},$("#btnSendRequest").click(function(){var n,i=window.location.href,t;return $("#conciergeSearchEmail").val()!="Your email"&&$("#conciergeSearchEmail").val()!=""?(n=$("#conciergeSearchEmail").val(),t="/Enquiry.aspx?email="+n+"&mlSbj=Concierge Search&Source=Concierge&PageUrl="+i+""):(n="",t="/Enquiry.aspx?mlSbj=Concierge Search"),window.open(t),!1}),$("[id*='findOut']").click(function(){if(searchHomes==1){var n=$("#finalResult").text();n=n.substring(n.indexOf("D")+1).replace(/\,/g,""),$("[id*='AffordPrice']").val(n),c()}else return!1}),$("[id*='keywordSearch']").val($("[id*='txtSmartSearch']").val()),$.get("/Homepage/Hong_Kong.svg",{},function(n){loadSVG(n)},"text")}),function(n,t){function y(n,t,i){var e=n.children(),o=!1,u,s,f;for(n.empty(),u=0,s=e.length;u<s;u++)if(f=e.eq(u),n.append(f),i&&n.append(i),r(n,t)){f.remove(),o=!0;break}else i&&i.detach();return o}function h(t,i,u,f,e){var o=!1,s="table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param, ol, ul, dl, blockquote, select, optgroup, option, textarea, script, style",c="script";return t.contents().detach().each(function(){var a=this,l=n(a);if(typeof a=="undefined"||a.nodeType==3&&n.trim(a.data).length==0)return!0;if(l.is(c))t.append(l);else{if(o)return!0;t.append(l),e&&t[t.is(s)?"after":"append"](e),r(u,f)&&(o=a.nodeType==3?v(l,i,u,f,e):h(l,i,u,f,e),o||(l.detach(),o=!0)),o||e&&e.detach()}}),o}function v(t,f,o,s,h){var c=t[0],nt,k,d;if(!c)return!1;var b=e(c),tt=b.indexOf(" ")!==-1?" ":"　",w=s.wrap=="letter"?"":tt,a=b.replace(/\s+/g,"").split(w),g=-1,p=-1,y=0,v=a.length-1;for(s.fallbackToLetter&&y==0&&v==0&&(w="",a=b.split(w),v=a.length-1);y<=v&&!(y==0&&v==0);){if(nt=Math.floor((y+v)/2),nt==p)break;p=nt,u(c,a.slice(0,p+1).join(w)+s.ellipsis),r(o,s)?(v=p,s.fallbackToLetter&&y==0&&v==0&&(w="",a=a[0].split(w),g=-1,p=-1,y=0,v=a.length-1)):(g=p,y=p)}return g==-1||a.length==1&&a[0].length==0?(k=t.parent(),t.detach(),d=h&&h.closest(k).length?h.length:0,k.contents().length>d?c=i(k.contents().eq(-1-d),f):(c=i(k,f,!0),d||k.detach()),c&&(b=l(e(c),s),u(c,b),d&&h&&n(c).parent().append(h))):(b=l(a.slice(0,g+1).join(w),s),u(c,b)),!0}function r(n,t){return n.innerHeight()>t.maxHeight}function l(t,i){while(n.inArray(t.slice(-1),i.lastCharacter.remove)>-1)t=t.slice(0,-1);return n.inArray(t.slice(-1),i.lastCharacter.noEllipsis)<0&&(t+=i.ellipsis),t}function s(n){return{width:n.innerWidth(),height:n.innerHeight()}}function u(n,t){n.innerText?n.innerText=t:n.nodeValue?n.nodeValue=t:n.textContent&&(n.textContent=t)}function e(n){return n.innerText?n.innerText:n.nodeValue?n.nodeValue:n.textContent?n.textContent:""}function f(n){do n=n.previousSibling;while(n&&n.nodeType!==1&&n.nodeType!==3);return n}function i(t,r,u){var o=t&&t[0],e;if(o){if(!u){if(o.nodeType===3)return o;if(n.trim(t.text()))return i(t.contents().last(),r)}for(e=f(o);!e;){if(t=t.parent(),t.is(r)||!t.length)return!1;e=f(t[0])}if(e)return i(n(e),r)}return!1}function p(t,i){return t?typeof t=="string"?(t=n(t,i),t.length?t:!1):t.jquery?t:!1:!1}function w(n){for(var r=n.innerHeight(),u=["paddingTop","paddingBottom"],i,t=0,f=u.length;t<f;t++)i=parseInt(n.css(u[t]),10),isNaN(i)&&(i=0),r-=i;return r}var c,o,a;n.fn.dotdotdot||(n.fn.dotdotdot=function(t){var i;if(this.length==0)return n.fn.dotdotdot.debug('No element found for "'+this.selector+'".'),this;if(this.length>1)return this.each(function(){n(this).dotdotdot(t)});i=this,i.data("dotdotdot")&&i.trigger("destroy.dot"),i.data("dotdotdot-style",i.attr("style")||""),i.css("word-wrap","break-word"),i.css("white-space")==="nowrap"&&i.css("white-space","normal"),i.bind_events=function(){return i.bind("update.dot",function(t,s){t.preventDefault(),t.stopPropagation(),u.maxHeight=typeof u.height=="number"?u.height:w(i),u.maxHeight+=u.tolerance,typeof s!="undefined"&&((typeof s=="string"||s instanceof HTMLElement)&&(s=n("<div />").append(s).contents()),s instanceof n&&(o=s)),e=i.wrapInner('<div class="dotdotdot" />').children(),e.contents().detach().end().append(o.clone(!0)).find("br").replaceWith("  <br />  ").end().css({height:"auto",width:"auto",border:"none",padding:0,margin:0});var l=!1,c=!1;return f.afterElement&&(l=f.afterElement.clone(!0),l.show(),f.afterElement.detach()),r(e,u)&&(c=u.wrap=="children"?y(e,u,l):h(e,i,e,u,l)),e.replaceWith(e.contents()),e=null,n.isFunction(u.callback)&&u.callback.call(i[0],c,o),f.isTruncated=c,c}).bind("isTruncated.dot",function(n,t){return n.preventDefault(),n.stopPropagation(),typeof t=="function"&&t.call(i[0],f.isTruncated),f.isTruncated}).bind("originalContent.dot",function(n,t){return n.preventDefault(),n.stopPropagation(),typeof t=="function"&&t.call(i[0],o),o}).bind("destroy.dot",function(n){n.preventDefault(),n.stopPropagation(),i.unwatch().unbind_events().contents().detach().end().append(o).attr("style",i.data("dotdotdot-style")||"").data("dotdotdot",!1)}),i},i.unbind_events=function(){return i.unbind(".dot"),i},i.watch=function(){if(i.unwatch(),u.watch=="window"){var t=n(window),r=t.width(),e=t.height();t.bind("resize.dot"+f.dotId,function(){r==t.width()&&e==t.height()&&u.windowResizeFix||(r=t.width(),e=t.height(),l&&clearInterval(l),l=setTimeout(function(){i.trigger("update.dot")},100))})}else a=s(i),l=setInterval(function(){if(i.is(":visible")){var n=s(i);(a.width!=n.width||a.height!=n.height)&&(i.trigger("update.dot"),a=n)}},500);return i},i.unwatch=function(){return n(window).unbind("resize.dot"+f.dotId),l&&clearInterval(l),i};var o=i.contents(),u=n.extend(!0,{},n.fn.dotdotdot.defaults,t),f={},a={},l=null,e=null;return u.lastCharacter.remove instanceof Array||(u.lastCharacter.remove=n.fn.dotdotdot.defaultArrays.lastCharacter.remove),u.lastCharacter.noEllipsis instanceof Array||(u.lastCharacter.noEllipsis=n.fn.dotdotdot.defaultArrays.lastCharacter.noEllipsis),f.afterElement=p(u.after,i),f.isTruncated=!1,f.dotId=c++,i.data("dotdotdot",!0).bind_events().trigger("update.dot"),u.watch&&i.watch(),i},n.fn.dotdotdot.defaults={ellipsis:"... ",wrap:"word",fallbackToLetter:!0,lastCharacter:{},tolerance:0,callback:null,after:null,height:null,watch:!1,windowResizeFix:!0},n.fn.dotdotdot.defaultArrays={lastCharacter:{remove:[" ","　",",",";",".","!","?"],noEllipsis:[]}},n.fn.dotdotdot.debug=function(){},c=1,o=n.fn.html,n.fn.html=function(i){return i!=t&&!n.isFunction(i)&&this.data("dotdotdot")?this.trigger("update",[i]):o.apply(this,arguments)},a=n.fn.text,n.fn.text=function(i){return i!=t&&!n.isFunction(i)&&this.data("dotdotdot")?(i=n("<div />").text(i).html(),this.trigger("update",[i])):a.apply(this,arguments)})}(jQuery)