var webroot="/",areaCheck="",areaArray=[],locationCheck="",locationArray=[],checkedAreaArray=[],elem=[],imageWidth,imageHeight,homeVideo="",startState="";$(document).ready(function(){$("form.quick-search input.search").Watermark("Enter web #, address, building name, or agent","#999999");$("form.quick-search input.search").focus(function(){$("form.quick-search .quicksearch-help").css({display:"block"})});$("form.quick-search input.search").keydown(function(){if($(this).val()=="")$("form.quick-search .quicksearch-help").css({display:"block"});else $("form.quick-search .quicksearch-help").css({display:"none"})});$("form.quick-search input.search").keyup(function(){if($(this).val()=="")$("form.quick-search .quicksearch-help").css({display:"block"});else $("form.quick-search .quicksearch-help").css({display:"none"})});$("form.quick-search input.search").blur(function(){$("form.quick-search .quicksearch-help").css({display:"none"})});(navigator.platform=="iPad"||navigator.platform=="iPhone"||navigator.platform=="iPod")&&$("#fullscreen-photos").css({display:"none"});(navigator.platform=="iPad"||navigator.platform=="iPhone"||navigator.platform=="iPod")&&$("html").click(function(){$("ul.navigation li div").fadeOut("fast")});$("ul.navigation li").hoverIntent(function(){$("div",this).css({display:"block"})},function(){$("div",this).css({display:"none"})});$("ul.navigation li .properties-subnav",this).hover(function(){$("ul.navigation li a.properties").addClass("properties-hover")},function(){$("ul.navigation li a.properties").removeClass("properties-hover")});$("ul.navigation li .developments-subnav",this).hover(function(){$("ul.navigation li a.developments").addClass("developments-hover")},function(){$("ul.navigation li a.developments").removeClass("developments-hover")});$("ul.navigation li .areastowns-subnav",this).hover(function(){$("ul.navigation li a.areas-towns").addClass("areastowns-hover")},function(){$("ul.navigation li a.areas-towns").removeClass("areastowns-hover")});$("ul.navigation li .agents-subnav",this).hover(function(){$("ul.navigation li a.agents").addClass("agents-hover")},function(){$("ul.navigation li a.agents").removeClass("agents-hover")});$("ul.navigation li .aboutus-subnav",this).hover(function(){$("ul.navigation li a.about-us").addClass("aboutus-hover")},function(){$("ul.navigation li a.about-us").removeClass("aboutus-hover")});$("#halstead-search").autocomplete(data,{matchContains:true,minChars:2,width:269,max:50,scrollHeight:245,formatItem:function(a){return a.text}}).result(function(b,a){location.href=a.url});$(".result-photo").each(function(){$(".result-photo").aeImageResize({width:214,height:143})});navigator.platform!="iPad"&&$("img").not(".thumbs img").not(".idx").not(".result-photo").lazyload({placeholder:webroot+"img/grey.gif",effect:"fadeIn"});$("#dim-lights").css("height",$(document).height()).hide();$("#media-close").css("height",$(document).height()).hide();$(".homepage-video").click(function(){$("#dim-lights").show();$(".video-over").show();$(".h11 h1").css({background:"none"});$(".featured-property a img").css({display:"none"});$(".featured-property .property-bar").css({display:"none"});$(".featured-property .property-information").css({display:"none"});$(".video-over .video-overlay").html('<iframe src="http://www.wellcomemat.com/wm_video_u/'+homeVideo+'" scrolling="no" frameborder="0" width="676" height="452" id="IFRAMEID"></iframe>')});$(".propertv-link").click(function(){$("#dim-lights").show();$(".video-over").show();$(".h11 h1").css({background:"none"});$(".featured-property a img").css({display:"none"});$(".featured-property .property-bar").css({display:"none"});$(".featured-property .property-information").css({display:"none"});$(".video-over .video-overlay").html('<iframe src="http://www.wellcomemat.com/wm_video_u/'+homeVideo+'" scrolling="no" frameborder="0" width="676" height="452" id="IFRAMEID"></iframe>')});$("#dim-lights").click(function(){$("#dim-lights").hide();$(".video-over").hide();$(".h11 h1").css({background:"url(img/halstead_property.gif) no-repeat"});$(".h11 h1").css({"background-position":"-5px -6px"});$(".h11 a.home").css({background:"url("+webroot+"img/halstead_property.gif) no-repeat"});$(".h11 a.home").css({"background-position":"-5px -6px"});$(".h11 .luxury-portfolio-affiliation").css({background:"url("+webroot+"img/luxury-portfolio-affiliation_522011.gif) no-repeat"});$(".featured-property a img").css({display:"block"});$(".featured-property .property-bar").css({display:"block"});$(".featured-property .property-information").css({display:"block"});$(".video-over .video-overlay").html("")});$(".video-over").click(function(){$("#dim-lights").hide();$(".video-over").hide();$(".h11 h1").css({background:"url(img/halstead_property.gif) no-repeat"});$(".h11 h1").css({"background-position":"-5px -6px"});$(".h11 a.home").css({background:"url("+webroot+"img/halstead_property.gif) no-repeat"});$(".h11 a.home").css({"background-position":"-5px -6px"});$(".h11 .luxury-portfolio-affiliation").css({background:"url("+webroot+"img/luxury-portfolio-affiliation_522011.gif) no-repeat"});$(".featured-property a img").css({display:"block"});$(".featured-property .property-bar").css({display:"block"});$(".featured-property .property-information").css({display:"block"});$(".video-over .video-overlay").html("")});$("p.count").fadeIn("fast").html("<span>Select some criteria to begin your search</span>");$("#nys").click(function(){map.panTo(pantoNewYork);map.setZoom(12);$("#nys").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#hamptons").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#cts").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#njs").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#nys").addClass("active");$("#hamptons").addClass("inactive");$("#cts").addClass("inactive");$("#njs").addClass("inactive");$("#ny").fadeIn("fast");$("#hps").fadeOut("fast");$("#ct").fadeOut("fast");$("#nj").fadeOut("fast");$("#featured-properties").css({display:"none"});$("#left-search").css({display:"block"});$(".no-search").css({display:"none"})});$("#hamptons").click(function(){map.panTo(pantoHamptons);map.setZoom(9);$("#nys").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#hamptons").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#cts").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#njs").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#nys").addClass("inactive");$("#hamptons").addClass("active");$("#cts").addClass("inactive");$("#njs").addClass("inactive");$("#ny").fadeOut("fast");$("#hps").fadeIn("fast");$("#ct").fadeOut("fast");$("#nj").fadeOut("fast");$("#featured-properties").css({display:"none"});$("#left-search").css({display:"none"});google.maps.event.trigger(map,"resize");$(".no-search").css({display:"none"})});$("#cts").click(function(){map.panTo(pantoConnecticut);map.setZoom(10);$("#nys").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#hamptons").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#cts").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#njs").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#nys").addClass("inactive-first");$("#hamptons").addClass("inactive");$("#cts").addClass("active");$("#njs").addClass("inactive");$("#ct").fadeIn("fast");$("#ny").fadeOut("fast");$("#hps").fadeOut("fast");$("#nj").fadeOut("fast");$("#featured-properties").css({display:"none"});$("#left-search").css({display:"block"});$(".no-search").css({display:"none"})});$("#njs").click(function(){map.panTo(pantoNewJersey);map.setZoom(13);$("#nys").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#hamptons").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#cts").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#njs").removeClass("active").removeClass("inactive").removeClass("inactive-first");$("#nys").addClass("inactive-first");$("#hamptons").addClass("inactive-first");$("#cts").addClass("inactive-first");$("#njs").addClass("active");$("#nj").fadeIn("fast");$("#ny").fadeOut("fast");$("#hps").fadeOut("fast");$("#ct").fadeOut("fast");$("#featured-properties").css({display:"block"});$("#left-search").css({display:"block"});$(".no-search").css({display:"none"})});var e;$(".section-wrap .check").click(function(){if($(this).attr("checked")){$(this).parent(".section-wrap").find(".choose-locations .check").each(function(){$(this).attr("checked",true);var a="url('"+webroot+"img/button_expand.gif')";$(this).parent("div").parent(".choose-locations").parent(".section-wrap").find("a.expand-area").css("background-image",a)});if(c==webroot+"rentals")searchForm("search-listings-rentals","preview");else searchForm("search-listings","preview")}else{$(this).parent(".section-wrap").find(".choose-locations .check").each(function(){$(this).removeAttr("checked");var a="url('"+webroot+"img/button_expand_grey.gif')";$(this).parent("div").parent(".choose-locations").parent(".section-wrap").find("a.expand-area").css("background-image",a)});if(c==webroot+"rentals")searchForm("search-listings-rentals","preview");else searchForm("search-listings","preview")}});$(".section-wrap-float .check").click(function(){if($(this).attr("checked")){$(this).parent(".section-wrap-float").find(".choose-locations .check").each(function(){$(this).attr("checked",true)});if(c==webroot+"rentals")searchForm("search-listings-rentals","preview");else searchForm("search-listings","preview")}else{$(this).parent(".section-wrap-float").find(".choose-locations .check").each(function(){$(this).removeAttr("checked")});if(c==webroot+"rentals")searchForm("search-listings-rentals","preview");else searchForm("search-listings","preview")}});var b,a="";$("a.expand-area").click(function(){b=$(this).parent(".section-wrap").find(".choose-locations");$(".choose-locations .check").each(function(){if($(this).attr("checked")){var a="url('"+webroot+"img/button_expand.gif')";$(this).parent("div").parent(".choose-locations").parent(".section-wrap").find("a.expand-area").css("background-image",a)}});if(b.css("display")!="block"){a="url('"+webroot+"img/button_expand_minus.gif')";$(this).css("background-image",a);b.slideDown("fast");b.css({display:"block"})}else{b.slideUp("fast");b.css({display:"none"});a="url('"+webroot+"img/button_expand_grey.gif')";$(this).css("background-image",a);$(this).parent(".section-wrap").find(".choose-locations .check").each(function(){if($(this).attr("checked")){var a="url('"+webroot+"img/button_expand.gif')";$(this).parent("div").parent(".choose-locations").parent(".section-wrap").find("a.expand-area").css("background-image",a)}})}});$("a.expand-all").click(function(){b=$(".choose-locations");if(b.css("display")!="block"){$("a.expand-area").css("display","block");$(".choose-locations").slideDown("fast");a="url('"+webroot+"img/button_expand_minus.gif')";$("a.expand-area").css("background-image",a)}else{$(".choose-locations").slideUp("fast");a="url('"+webroot+"img/button_expand_grey.gif')";$("a.expand-area").css("background-image",a)}});$(".agent-list").hoverIntent(function(){$("div.agent-bio-preview",this).css({display:"block"})},function(){$("div.agent-bio-preview",this).css({display:"none"})});$("li.agent-preview").hoverIntent(function(){$("div.agent-bio-preview",this).css({display:"block"})},function(){$("div.agent-bio-preview",this).css({display:"none"})});$("#search").length>0&&document.forms.search.reset();$("#searchFooter").length>0&&document.forms.searchFooter.reset();function d(){$(".panel .panel_body").hide();$(".panel .panel_body:first").show();$(".panel h3").hoverIntent(function(){h3class=$(this).attr("class");var a=$(this).next();if(a.is(".panel_body")&&a.is(":visible"))return false;if(a.is(".panel_body")&&!a.is(":visible")){$(".panel .panel_body:visible").slideUp("fast");a.slideDown("fast");return false}},function(){})}d();$(".primary-photo").aeImageResize({width:428,height:350});$(".thumbs").find("img").each(function(){$(".thumbs img").aeImageResize({width:86,height:70})});$(".thumbs a img").hoverIntent(function(){$(".primary-photo-holder").css({display:"block","float":"left",margin:"0px 0px 18px 0px"});$(".map-container").css({display:"none"});$("#map_canvas").css({display:"none"});var a=$(this).attr("src");a=a.replace("_t","");$("img.primary-photo").attr("src",a);document.getElementById("primaryPhoto").width=0;document.getElementById("primaryPhoto").height=0;var b=document.getElementById("primaryPhoto"),d=b.clientWidth,c=b.clientHeight;$(".primary-photo").aeImageResize({width:428,height:350})},function(){});$(".listing-media a:last").css({"border-bottom":"0px"});var c=window.location.pathname;$("#media-close").click(function(){$("#media-close").hide();$(".media-overlay").hide()});$(".agent-modal").click(function(){$("form.modal").fadeIn("fast");$("form.modal-on").fadeIn("fast")});$(".details-modal-share").click(function(){$("#modal-share").fadeIn("fast");$("#modal-purchase").fadeOut("fast");$("#modal-contact").fadeOut("fast");$("form.mortgage").fadeOut("fast");$("#fullscreen-photos").css({display:"none"})});$(".details-modal").click(function(){$("#modal-contact").fadeIn("fast");$("#modal-share").fadeOut("fast");$("#modal-purchase").fadeOut("fast");$("form.mortgage").fadeOut("fast");$("#fullscreen-photos").css({display:"none"})});$(".details-modal-purchase").click(function(){$("#modal-purchase").fadeIn("fast");$("#modal-share").fadeOut("fast");$("#modal-contact").fadeOut("fast");$("form.mortgage").fadeOut("fast")});$(".mortgage-calculator-call").click(function(){$("form.mortgage").fadeIn("fast");$("#modal-share").fadeOut("fast");$("#modal-contact").fadeOut("fast");$("#modal-purchase").fadeOut("fast");cmdCalc_Click(document.forms["mortgage-form"],"p");$("#fullscreen-photos").css({display:"none"})});$(".close-modal").click(function(){$("form.modal").fadeOut("fast");$("form.modal-on").fadeOut("fast");$("form.mortgage").fadeOut("fast");$("#fullscreen-photos").css({display:"block"})});$(".close-modal-icon").click(function(){$("form.modal").fadeOut("fast");$("form.modal-on").fadeOut("fast");$("form.mortgage").fadeOut("fast");$("#fullscreen-photos").css({display:"block"})});$("a.media-map").click(function(){$(".primary-photo-holder").css({display:"none"});$(".details-left .map-container").css({display:"block"});$("#map_canvas").css({display:"block",position:"relative",width:"438px",height:"290px"});initialize(window.latitude,window.longitude,window.address,window.price,window.office)});$("a.language-gr").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-gr").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-ar").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-ar").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-tu").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-tu").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-ja").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-ja").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-cr").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-cr").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-ru").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-ru").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-se").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-se").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-hu").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-hu").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-ko").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-ko").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-fr").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-fr").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-ge").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-ge").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-it").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-it").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-po").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-po").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-sp").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-sp").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-he").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-he").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-du").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-du").fadeIn("fast");$(".hide-english").fadeIn("fast")});$("a.language-en").click(function(){$("[class*=lang-]:visible").fadeOut("fast");$("div.lang-en").css({height:"auto"});$("div.lang-en-more").css({display:"none"});$("div.lang-en").fadeIn("fast")});$(".print-options").hoverIntent(function(){$("ul",this).css({display:"block"})},function(){$("ul",this).css({display:"none"})});if($("#search").length>0)elem=document.getElementById("search").elements});function initAreas(a){window.areaCheck=a;if(window.areaCheck!="")areaArray=areaCheck.split(",")}function initLocations(a){window.locationCheck=a;if(window.locationCheck!="")locationArray=locationCheck.split(",")}function initVideo(a){window.homeVideo=a}function searchForm(j,i){var u="",b="",e="",g="",f="",d="",m="",r="",h="",c="",s="",t="",v=0,q=0,l="",n="",o="";switch(j){case"just-listed-properties":case"luxury-portfolio-collection":case"value-factor-properties":case"managed-properties":case"upcoming-open-houses":case"my-account":case"agents":case"about-us/recent-press/videos":case"about-us/reports-and-publications/behind-the-numbers-show":case"agents-by-video-biography":case"developments/development-video-tours":case"areas-and-towns/neighborhood-video-tours":case"about-us/customer-resources/propertv-video-library":case"about-us/recent-press/all-articles":case"about-us/recent-press/corporate-news-articles":case"developments/sales":case"developments/rentals":for(var a=0;a<elem.length;a++)if(elem[a].name!=undefined&&elem[a].value!=""){if(elem[a].type=="select-one")if(!(elem[a].name=="page"&&i=="sort"))b=b+elem[a].value+"/";if(elem[a].type=="radio"&&elem[a].checked)b=b+elem[a].value+"/";if(elem[a].type=="hidden")b=b+elem[a].value+"/";if(elem[a].type=="checkbox")if(elem[a].checked&&elem[a].value=="include-new-developments")b=b+elem[a].value+"/"}window.location=webroot+j+"/"+b;break;case"sales/properties":case"rentals/properties":for(var a=0;a<elem.length;a++)if(elem[a].name!=undefined&&elem[a].value!=""){if(elem[a].type=="select-one"){elem[a].name=="page"&&i=="sort";if(elem[a].type=="select-one")if(!(elem[a].name=="page"&&i=="sort"))if(elem[a].name=="page")b=b+elem[a].value+"/";if(elem[a].type=="select-one")if(elem[a].name=="sorted-by")b=b+elem[a].value+"/";if(elem[a].type=="select-one")if(elem[a].name=="price-low")e=e+elem[a].value+"-";if(elem[a].type=="select-one")if(elem[a].name=="price-high")e=e+elem[a].value+"/"}if(elem[a].type=="hidden")if(elem[a].name=="crit")b=b+elem[a].value+"/"}if(e=="0-no-limit/")e="";else e="price:"+e;window.location=webroot+j+"/"+e+b;break;case"neighborhoods":for(var a=0;a<elem.length;a++)if(elem[a].name!=undefined&&elem[a].value!=""){if(elem[a].type=="select-one")if(!(elem[a].name=="page"&&i=="sort"))b=b+elem[a].value+"/";if(elem[a].type=="hidden"){if(elem[a].name=="crit")b=b+elem[a].value+"/";if(elem[a].name=="neighborhood")l=elem[a].value}}window.location=webroot+l+"/"+b;break;case"agent":for(var a=0;a<elem.length;a++)if(elem[a].name!=undefined&&elem[a].value!=""){if(elem[a].type=="select-one")if(!(elem[a].name=="page"&&i=="sort"))b=b+elem[a].value+"/";if(elem[a].type=="hidden"){if(elem[a].name=="crit")b=b+elem[a].value+"/";if(elem[a].name=="agent")l=elem[a].value}}window.location=webroot+l+"/"+b+"#properties";break;case"search-listings":case"search-listings-rentals":for(var a=0;a<elem.length;a++)if(elem[a].name!=undefined&&elem[a].value!=""){if(elem[a].type=="select-one")if(elem[a].name=="price-low")e=e+elem[a].value+"-";if(elem[a].type=="select-one")if(elem[a].name=="price-high")e=e+elem[a].value+"/";if(elem[a].type=="select-one")if(elem[a].name=="beds")g=g+elem[a].value+"/";if(elem[a].type=="select-one")if(elem[a].name=="baths")f=f+elem[a].value+"/";if(elem[a].type=="text")if(elem[a].name=="keyword")h=h+elem[a].value;if(elem[a].type=="checkbox"){if(elem[a].checked&&elem[a].name=="condos")d=d+"condos-";if(elem[a].checked&&elem[a].name=="coops")d=d+"coops-";if(elem[a].checked&&elem[a].name=="condops")d=d+"condops-";if(elem[a].checked&&elem[a].name=="townhouses")d=d+"townhouses-";if(elem[a].checked&&elem[a].name=="houses")d=d+"houses-";if(elem[a].checked&&elem[a].name=="investment")d=d+"investment-";if(elem[a].checked&&elem[a].name=="new-development")d=d+"development-";if(elem[a].checked&&elem[a].name=="vacant-lot-land")d=d+"land-";if(elem[a].checked&&(elem[a].name=="attended-lobby"||elem[a].name=="concierge"||elem[a].name=="fireplace"||elem[a].name=="outdoor-space"||elem[a].name=="parking"||elem[a].name=="pet-friendly"||elem[a].name=="views"||elem[a].name=="washer-dryer"||elem[a].name=="just-listed"||elem[a].name=="open-houses"||elem[a].name=="managed-by-bhs"||elem[a].name=="penthouse"||elem[a].name=="pre-war"||elem[a].name=="post-war"||elem[a].name=="loft"||elem[a].name=="duplex-triplex"||elem[a].name=="single-family"||elem[a].name=="townhouse-apt"||elem[a].name=="no-fee"||elem[a].name=="multi-family"||elem[a].name=="featured-properties"||elem[a].name=="sponsor-units"||elem[a].name=="in-contract"))m=m+elem[a].name+"/";for(var k=0;k<areaArray.length;k++)if(elem[a].checked&&elem[a].name==areaArray[k]){c=c+elem[a].name+",";break}}}for(var a=0;a<elem.length;a++)if(elem[a].name!=undefined&&elem[a].value!="")if(elem[a].checked)for(var k=0;k<locationArray.length;k++)if(elem[a].checked&&elem[a].name==locationArray[k]){n="#"+elem[a].name;o=$(n).parent("div").parent(".choose-locations").parent(".section-wrap").find(".check").attr("checked");if(o)c=c;else c=c+elem[a].name+",";break}if(c!=""){c=c.substring(0,c.length-1)+"/";c="areas:"+c;if(c.substring(c.length,c.length-2)==",/")c=c.substring(0,c.length-2)+"/"}if(c=="areas:/")c="";if(e=="0-no-limit/")e="";else e="price:"+e;if(g=="0/")g="";else g=g;if(f=="0/")f="";else f=f;if(d!="")d=d.substring(0,d.length-1)+"/";if(h!="")h="keyword:"+trimAll(h)+"/";b=c+e+g+f+d+m+h;if(i=="preview"){$("p.count span").fadeOut("fast");if(j=="search-listings-rentals")$("p.count").fadeOut("fast").load(webroot+"search_count_rentals/"+b).fadeIn("fast");else $("p.count").fadeOut("fast").load(webroot+"search_count_sales/"+b).fadeIn("fast")}else if(c==""){var p=confirm("Your search will include properties from the Tri State area. For specific county or neighborhoods in a state, click CANCEL and select using the area checkboxes provided");if(p)if(j=="search-listings-rentals")window.location=webroot+"rentals/properties/"+b;else window.location=webroot+"sales/properties/"+b}else if(j=="search-listings-rentals")window.location=webroot+"rentals/properties/"+b;else window.location=webroot+"sales/properties/"+b}}function searchFormFooter(f,d){var r="",c="",k="",n="",j="",h="",m="",o="",i="",g="",p="",q="",s=0,l=0,e="",b=document.getElementById("searchFooter").elements;switch(f){case"just-listed-properties":case"upcoming-open-houses":case"luxury-portfolio-collection":case"value-factor-properties":case"managed-properties":for(var a=0;a<b.length;a++)if(b[a].name!=undefined&&b[a].value!=""){if(b[a].type=="select-one")if(!(b[a].name=="page"&&d=="sort"))c=c+b[a].value+"/";if(b[a].type=="radio"&&b[a].checked)c=c+b[a].value+"/";if(b[a].type=="hidden")c=c+b[a].value+"/"}window.location=webroot+f+"/"+c;break;case"sales/properties":case"rentals/properties":for(var a=0;a<b.length;a++)if(b[a].name!=undefined&&b[a].value!=""){if(b[a].type=="select-one")if(!(b[a].name=="page"&&d=="sort"))c=c+b[a].value+"/";if(b[a].type=="hidden")if(b[a].name=="crit")c=c+b[a].value+"/"}window.location=webroot+f+"/"+c;break;case"agent":for(var a=0;a<b.length;a++)if(b[a].name!=undefined&&b[a].value!=""){if(b[a].type=="select-one")if(!(b[a].name=="page"&&d=="sort"))c=c+b[a].value+"/";if(b[a].type=="hidden"){if(b[a].name=="crit")c=c+b[a].value+"/";if(b[a].name=="agent")e=b[a].value}}window.location=webroot+e+"/"+c+"#properties";break;case"neighborhoods":for(var a=0;a<b.length;a++)if(b[a].name!=undefined&&b[a].value!=""){if(b[a].type=="select-one")if(!(b[a].name=="page"&&d=="sort"))c=c+b[a].value+"/";if(b[a].type=="hidden"){if(b[a].name=="crit")c=c+b[a].value+"/";if(b[a].name=="neighborhood")e=b[a].value}}window.location=webroot+e+"/"+c}}function mapFocus(b,a,c,e,d){window.latitude=parseFloat(b);window.longitude=parseFloat(a);window.address=c;window.price=e;window.office=d}function searchDefault(a){window.startState=a}function trimAll(a){while(a.substring(0,1)==" ")a=a.substring(1,a.length);while(a.substring(a.length-1,a.length)==" ")a=a.substring(0,a.length-1);return a}function closeLabel(){$("div.map-label-click").css({display:"none"})}function detailsPN(a){document.results.action=a;document.results.submit()}function hplayer(a){$(".halstead-propertv").css({left:"140px"});$(".video-overlay").css({"margin-left":"140px"});$("#dim-lights").show();$(".video-over").show();$(".h11 a.home").css({background:"none"});$(".h11 .luxury-portfolio-affiliation").css({background:"none"});$(".video-over .video-overlay").html('<iframe src="http://www.wellcomemat.com/wm_video_u/'+a+'" scrolling="no" frameborder="0" width="676" height="452" id="IFRAMEID"></iframe>')}function mediaDisplay(b,a){$("#media-close").show();$(".media-overlay").show();$(".media-overlay").html('<img src="http://media.halstead.com/floorplans/'+a+'" border="0"/>')}function SavedSearchRemoval(){return confirm("Are you sure you want to remove this saved search?")}function SavedListingRemoval(){return confirm("Are you sure you want to remove this saved listing?")}function disableEnterKey(b){var a;if(window.event)a=window.event.keyCode;else a=b.which;if(a==13){searchForm("search-listings","submit");return false}else return true}function disableEnterKeyR(b){var a;if(window.event)a=window.event.keyCode;else a=b.which;if(a==13){searchForm("search-listings-rentals","submit");return false}else return true}function PrintListing(b,a){a=a.replace("http://media.bhsusa.com/pictures/","");a=a.replace("http://media.bhsusa.com/floorplans/","");a=a.replace(b,"");a=a.replace("_l.jpg","");a=a.replace(".jpg","");a=a.replace("-","");window.open(webroot+"print/"+b+"/","width=800,height=600,status=yes,toolbar=no,menubar=yes, scrollbars=yes")}function checkForZero(a){if(a.value==0||a.value.length==0){alert("Please enter a number greater than zero in this field.");a.focus()}else calculatePayment(a.form)}function formatCurrency(a){a=a.toString().replace(/\$|\,/g,"");if(isNaN(a))a="0";sign=a==(a=Math.abs(a));a=Math.floor(a*100+.50000000001);cents=a%100;a=Math.floor(a/100).toString();if(cents<10)cents="0"+cents;for(var b=0;b<Math.floor((a.length-(1+b))/3);b++)a=a.substring(0,a.length-(4*b+3))+","+a.substring(a.length-(4*b+3));return(sign?"":"-")+"$"+a+"."+cents}function cmdCalc_Click(a,e){var d,b,c;d=parseFloat(a.price.value);b=parseFloat(a.interest_rate.value);c=parseFloat(a.loan_term.value);if(d==0||d.length==0){alert("Please enter a price that is greater than zero.");a.price.focus()}else if(b==0||b.length==0){alert("Please enter an interest rate that is greater than zero.");a.interest_rate.focus()}else if(c==0||c.length==0){alert("Please enter a term length that is greater than zero.");a.loan_term.focus()}else calculatePayment(a,e)}function calculatePayment(a,l){var b=0,m=0,k=0,c=0,g=0,d=0,f=0,e=0,i=0,j=0,h=0;d=a.price.value;d=d.replace("$","");d=d.replace(/,/gi,"");d=parseFloat(d);if(l=="p"){b=a.percent_down.value;b=b.replace("%","");b=parseFloat(b);k=b*.01;c=d*k;c=parseFloat(c)}else{c=a.down_payment.value;c=c.replace("$","");c=c.replace(",","");c=parseFloat(c);b=parseFloat(b);b=c/d*100;b=parseFloat(b)}h=a.principle.value;h=parseFloat(h);g=a.interest_rate.value;g=g.replace("%","");g=parseFloat(g);if(a.real_estate_tax.value!=""){f=a.real_estate_tax.value;f=f.replace("$","");f=f.replace(",","");f=parseFloat(f)}if(a.maint_cc.value!=""){e=a.maint_cc.value;e=e.replace("$","");e=e.replace(",","");e=parseFloat(e)}h=d-c;intRate=g/100/12;months=a.loan_term.value*12;i=Math.floor(h*intRate/(1-Math.pow(1+intRate,-1*months))*100)/100;a.mortgage_payment.value=formatCurrency(i);a.down_payment.value=formatCurrency(c);j=i+f+e;a.total_monthly_payment.value=formatCurrency(j);a.principle.value=formatCurrency(h);b=Math.floor(b*100)/100;a.percent_down.value=b+"%"}function popup(a,c){if(!window.focus)return true;var b;if(typeof a=="string")b=a;else b=a.href;window.open(b,c,"width=720,height=550,scrollbars=yes,resizable=1 ");return false}function clickTrackTri(b,a){$("#triClick").load(webroot+"tristate-tracker?id="+b+"&c="+a+"&r="+Math.random()*99999).fadeIn("fast")}(function(a){a.fn.aeImageResize=function(b){var c=0,d=a.browser.msie&&6==~~a.browser.version;if(!b.height&&!b.width)return this;if(b.height&&b.width)c=b.width/b.height;return this.one("load",function(){this.removeAttribute("height");this.removeAttribute("width");this.style.height=this.style.width="";var f=this.height,g=this.width,h=g/f,a=b.height,d=b.width,e=c;if(!e)if(a)e=h+1;else e=h-1;if(a&&f>a||d&&g>d){if(h>e)a=~~(f/g*d);else d=~~(g/f*a);this.height=a;this.width=d}}).each(function(){(this.complete||d)&&a(this).trigger("load")})}})(jQuery)
