﻿var appState={gMap:null,properties:{},synch:null,tabPane:{visible:!1},filter:new LocationSearch.Filter,user:{loggedIn:!1,favorites:{}}};
function initMapManager(){var a=new google.maps.LatLng(30.2240897,-92.0198427);appState.gMap=new LocationSearch.Map.MapManager($("#map_pane")[0],a);appState.gMap.addListener(appState.gMap.getPanorama(),"visible_changed",function(){!appState.gMap.getPanorama().getVisible()&&!$("#btnStreetView").data("doOpen")&&$("#btnStreetView > span.ui-button-text").html("View in Street View").trigger("clickToggle")});$("div.divOverlayCtrl").hover(function(){$(this).find(".mapControlOptionsContainer").show()},function(){$(this).find(".mapControlOptionsContainer").hide()});
$("div.divOverlayCtrl input:checkbox").eq(0).change(function(){$(this).is(":checked")?appState.gMap.hasOverlay("GeoAreas")?appState.gMap.setOverlayVisibility("GeoAreas",!0):loadGeoAreas():appState.gMap.setOverlayVisibility("GeoAreas",!1)});navigator.geolocation&&$("div.geolocate").show().click(function(){appState.gMap.geolocateUser()});isiPad()&&($("div.mapControlCategory, li.mapControlOption").css({padding:".3em .6em","font-size":"14px"}),$("div.mapControlOptionsContainer").css("top",32));$("div.divOverlayCtrl").each(function(){appState.gMap.addControl($(this).detach()[0])});appState.gMap.loadControls();appState.gMap.addMarkerSet("property",
{coord:[3,34,5,23,0,19,0,14,4,12,5,5,5,0,11,0,17,4,17,7,15,9,14,17,16,21,12,25,8,24],type:"poly"},new google.maps.MarkerImage("Images/pinshad.png",new google.maps.Size(40,40),new google.maps.Point(0,0),new google.maps.Point(0,39)));$.each({RES:"Images/blupin.png",LND:"Images/grnpin.png",MUL:"Images/yelpin.png",CIB:"Images/redpin.png"},function(a,c){appState.gMap.addMarkerVariant("property",a,new google.maps.MarkerImage(c,new google.maps.Size(18,35),new google.maps.Point(0,0),new google.maps.Point(4,
34)))})}function buildRepromptFunc(a){return function(){$("#div_mvstatus").empty().show().css({height:80,width:236}).append($("<p></p>").html(a+"<br />Refresh nearby properties?")).append($("<div></div>").css({"text-align":"center","margin-top":12}).append($("<button></button").html("Show Me!").button({icons:{primary:"ui-icon-search"}}).addClass("ui-button-text-icon").click(function(a){a.preventDefault();appState.synch.call()})))}}
function pinNearbyProperties(){var a={};a.lat=appState.gMap.getMap().getCenter().lat();a.lng=appState.gMap.getMap().getCenter().lng();$.ajax({url:"default.aspx/GetNearbyProperties",data:JSON.stringify(a),success:function(a){var c=a.length;if(c==0)return appState.synch.release(),!1;var d=0,e=function(){++d==c?(appState.synch.release(),appState.gMap.clusterMarkers(!0,function(a){return appState.filter.meetsCriteria(a)})):($("#div_mvstatus > p").html("Retrieving properties that meet your criteria: ("+
d+"/"+c+")"),$("#div_mvstatus > div.progressbar").progressbar("value",d*100/c))},f=function(a){return function(){addToPropertyList(a,"#ul_nearby");e()}};$("#ul_nearby").empty();$.each(a,function(a,c){var b=f(c);appState.properties[c]?b():pinProperty(c,b)})}})}
function pinProperty(a,b){$.ajax({url:"default.aspx/GetParedRecord",data:"{mls:'"+a+"'}",success:function(c){if(c){appState.properties[a]=c;var b=new Date;b.setTime(appState.properties[a].list_date);appState.properties[a].list_date=b;appState.properties[a].isComplete=!1;appState.gMap.pinMarker(a,"property",categoryLookup(c.category),new google.maps.LatLng(c.geo_lat,c.geo_long),c.address,createItemContent(a))}else alert("A property could not be retrieved for MLS # "+a+". We may not have a map location for it, it may have sold, or its listing has expired.")},
complete:function(){b&&typeof b=="function"&&b()}})}function retrieveRecord(a,b){$.ajax({url:"default.aspx/GetPropertyRecord",data:"{mls:'"+a+"'}",success:function(c){appState.properties[a]=c;c=new Date;c.setTime(appState.properties[a].list_date);appState.properties[a].list_date=c;appState.properties[a].isComplete=!0},complete:function(){b&&typeof b=="function"&&b()}})}
function loadGeoAreas(){$.ajax({url:"default.aspx/GetGeoAreaCoords",data:"{}",success:function(a){$.each(a,function(a,c){appState.gMap.addPolyToOverlay("GeoAreas",c.id,c.coords,c.color)})}})}
function createItemContent(a){var b=$("#div_infotemplate > table.infoWindow").clone();b.find("td.photo img").attr("src",function(c,b){return b+a});if(!appState.properties[a]){return b[0]}b.find("td.address").html(appState.properties[a].address);b.find("tr.city > td").html(appState.properties[a].city+", "+appState.properties[a].state+" "+appState.properties[a].zip);appState.properties[a].subdivision!=""?b.find("tr.subdiv > td > strong").after(" "+appState.properties[a].subdivision):b.find("td.more").parent().before(b.find("tr.subdiv > td").empty().parent());
appState.properties[a].prop_type!=""?b.find("tr.prop_type > td > strong").after(" "+appState.properties[a].prop_type):b.find("td.more").parent().before(b.find("tr.prop_type > td").empty().parent());appState.properties[a].status=="PENDING"?b.find("tr.list_price > td > strong").html("Under Contract:").addClass("pending"):appState.properties[a].status=="CONTINGENT"?b.find("tr.list_price > td > strong").html("Contingent:").addClass("contingent"):b.find("tr.list_price > td > strong").html(appState.properties[a].can_lease?
"For Lease:":"For Sale:");b.find("tr.list_price > td > strong").after(" $"+(appState.properties[a].can_lease?addCommas(appState.properties[a].lease_price)+"/"+appState.properties[a].lease_price_per:addCommas(appState.properties[a].list_price)));switch(appState.properties[a].category){case 1:b.find("tr.details > td").eq(0).html("<strong>Beds:</strong> "+appState.properties[a].num_beds);b.find("tr.details > td").eq(1).html("<strong>Baths:</strong> "+appState.properties[a].num_baths_full+"/"+appState.properties[a].num_baths_half);
b.find("tr.details > td").eq(2).html("<strong>Sqft:</strong> "+addCommas(appState.properties[a].sqft)+"&nbsp;sqft");break;case 2:b.find("tr.details > td").eq(0).html("<strong>Acreage:</strong> "+appState.properties[a].acreage);break;case 3:b.find("tr.details > td").eq(0).html("<strong>Number of Units:</strong> "+appState.properties[a].num_units);break;case 4:b.find("tr.details > td").eq(0).html("<strong>Sqft:</strong> "+addCommas(appState.properties[a].sqft)+" sqft")}appState.properties[a].reduced_price||
b.find("img.ico_np").hide();appState.properties[a].vt_url||b.find("img.ico_vt").hide();appState.properties[a].photo_list.length<=1&&b.find("img.ico_mp").hide();appState.properties[a].lo_code=="L000050"&&b.find("img.ico_br").hide();b.find("td.more > span").click(function(){displayProperty(a,function(){$(".verticaltab:contains(Detail View)").parent().click()})});return b[0]}
function displayProperty(a,b){var c=function(){$.ajax({url:"default.aspx/AddHit",data:'{"mls":"'+a+'", "hitType":'+hitType.homepage+"}"});redrawPropertyTab(a);b&&typeof b=="function"&&b()};appState.properties[a].isComplete?c():retrieveRecord(a,c)}
function redrawPropertyTab(a){$("#div_noprop").hide();$("#div_propdetails, #div_albumoverlay").show();var b=$("#div_albumstage > div").empty().css("width",0).scrollLeft(0),c=$("#div_albumviewer > div.thumbnails > div").empty().css("width",0),d=0,e=appState.properties[a].photo_list.length,f=function(){$.ajax({url:"default.aspx/AddHit",data:'{"mls":"'+a+'", "hitType":'+hitType.photo+"}"})},g=function(){++d>=e&&($("#div_albumoverlay").hide(),$(this).closest("div").find("img").click(function(a){if(a.srcElement==
this){f();var b=$("#div_albumviewer > div.photoStage").empty();b.siblings("div.thumbnails").find("img").removeClass("selected");$(this).clone(!1).appendTo(b).hide().bind("load error",function(){$(this).fadeIn("slow")}).attr("src",function(a,c){return c.replace(/maxw=\d+/,"maxw=640").replace(/maxh=\d+/,"maxh=480")});a=$(this).parent().index();c.children().eq(a).children("img").addClass("selected");$("#div_modallayer").fadeIn("slow",function(){$(this).css("opacity",0.35);b.parent().show()})}}))},h=
function(d){var e=$("<span></span>").addClass("photoContainer");b.css("width",function(a,c){return parseInt(c)+380}).append(e);c.css("width",function(a,c){return parseInt(c)+206});$("<img />").bind("load error",g).attr("src","photo.ashx?maxw=380&maxh=234&compress=true&mls="+a+(d?"&id="+d:"")).appendTo(e);e.clone(!1).appendTo(c).children("img").click(function(){if($(this).hasClass("selected"))return!1;f();$(this).addClass("selected").parent().siblings().children("img").removeClass("selected");var a=
this.src.replace(/maxw=\d+/,"maxw=640").replace(/maxh=\d+/,"maxh=480");$("#div_albumviewer > div.photoStage > img").fadeOut("slow",function(){$(this).attr("src",a)})})};appState.properties[a].photo_list.length==0?h():$.each(appState.properties[a].photo_list,function(a){h(a)});$("#h1_pdAddress").html(appState.properties[a].address);appState.properties[a].lo_code!="L000050"?$("#tr_pdBrokerRecip").show():$("#tr_pdBrokerRecip").hide();$("#td_pdMLS").html(a);$("#td_pdCity").html(appState.properties[a].city+
", "+appState.properties[a].state+" "+appState.properties[a].zip);appState.properties[a].subdivision!=""?$("#td_pdSubdiv").html(appState.properties[a].subdivision):$("#tr_pdSubdiv").hide();$("#td_pdArea").html(appState.properties[a].area);appState.properties[a].prop_type!=""?$("#td_pdType").html(appState.properties[a].prop_type):$("#tr_pdType").hide();$("#td_pdBeds").html(appState.properties[a].num_beds);$("#td_pdBaths").html(appState.properties[a].num_baths_full+" Full / "+appState.properties[a].num_baths_half+
" Half");$("#td_pdSqft").html(addCommas(appState.properties[a].sqft)+" sqft");$("#td_pdStyle").html(appState.properties[a].style);$("#td_pdUnits").html(appState.properties[a].num_units);$("#td_pdAcreage").html(appState.properties[a].acreage==0?"Not Available":appState.properties[a].acreage);appState.properties[a].status=="PENDING"?$("#td_pdStatus").html("Under Contract:").addClass("pending"):appState.properties[a].status=="CONTINGENT"?$("#td_pdStatus").html("Contingent:").addClass("contingent"):$("#td_pdStatus").html(appState.properties[a].can_lease?
"For Lease:":"For Sale:");$("#td_pdPrice").html("$"+(appState.properties[a].can_lease?addCommas(appState.properties[a].lease_price)+"/"+appState.properties[a].lease_price_per:addCommas(appState.properties[a].list_price)));$("#td_pdDescrip").html(appState.properties[a].remarks);$("table.propertyDetails tr.variable").hide();switch(appState.properties[a].category){case 1:$("table.propertyDetails tr.res").show();break;case 2:$("table.propertyDetails tr.lnd").show();break;case 3:$("table.propertyDetails tr.mul").show();
break;case 4:$("table.propertyDetails tr.cib").show()}var i=function(){appState.gMap.openStreetView([appState.properties[a].geo_lat,appState.properties[a].geo_long]);$(this).children("span.ui-button-text").html("Close Street View").trigger("clickToggle")},j=function(){appState.gMap.closeStreetView()};$("#btnStreetView").unbind().bind("clickToggle",function(){var a=!$(this).data("doOpen");$(this).data("doOpen",a);if(a)$(this).one("click",i);else $(this).one("click",j)}).trigger("clickToggle");appState.gMap.ifStreetView([appState.properties[a].geo_lat,
appState.properties[a].geo_long],function(){$("#btnStreetView").button("enable").children("span.ui-button-text").html("View in Street View")},function(){$("#btnStreetView").button("disable").children("span.ui-button-text").html("Street View Unavailable")});appState.properties[a].vt_url?$("#btnVirtualTour").button("enable").children("span.ui-button-text").html("View VERtual Tours"):$("#btnVirtualTour").button("disable").children("span.ui-button-text").html("VERtual Tour Unavailable");$("#btnVirtualTour").unbind().click(function(){appState.gMap.closeStreetView();
$("#div_vtcontainer, #div_modallayer, #div_vtcontainer *").removeAttr("style");$("#div_modallayer").fadeIn("slow",function(){$.browser.msie&&$(this).css("opacity",0.35);var c=$("#div_vtcontainer").show();$.ajax({url:"default.aspx/GetVirtualTours",data:'{"mls":"'+a+'"}',success:function(b){var d=c.width(),e=c.height(),f=c.children("div.thumbnails"),g=c.children("div.player");b.length==2?d*=2:b.length>=3&&b.length<=9?d*=3:b.length>9&&(d=d*3+20,f.css("overflow-y",scroll),isiPad()&&f.jScrollTouch());
b.length>=7?e*=3:b.length>=4&&(e*=2);c.find("button").unbind().click(function(){c.children("div.thumbnails").hide().children("img.tourtn").removeAttr("style");g.children("div").animate({left:650},"fast",function(){$(this).parent().andSelf().removeAttr("style");c.animate({"margin-left":d/-2,"margin-top":e/-2,width:d,height:e},"slow",function(){c.children("div.thumbnails").fadeIn("slow")})})});c.css("background-image","none").animate({"margin-top":e/-2,height:e},600).animate({"margin-left":d/-2,width:d},
300,function(){$(this).children("img.close").show();$.each(b,function(b,d){$("<img />").prependTo(f).attr({src:"http://vt.vaneatonromero.com/"+a+"/"+d.replace("_","_TN_")+".jpg",alt:"Virtual Tour "+d,title:"Click to see this VERtual Tour","class":"tourtn"}).click(function(){$.ajax({url:"default.aspx/AddHit",data:'{"mls":"'+a+'", "hitType":'+hitType.virtualTour+"}"});g.find("div.movie").html('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="512" width="640"><param name="src" value="http://vt.acadianavirtualtours.com/'+
a+"/"+d+'.mov"><param name="autoplay" value="true"><param name="type" value="video/quicktime"><embed src="http://vt.acadianavirtualtours.com/'+a+"/"+d+'.mov" height="512" width="640" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></object>');var b=$(this).clone().wrap("<span></span>").parent().appendTo(f).css({position:"absolute",top:$(this).position().top,left:$(this).position().left,"background-color":"Black",width:$(this).outerWidth(!0),height:$(this).outerHeight(!0)});
$(this).css("opacity",0);f.find("img").fadeOut("slow");b.animate({top:18,left:10},"slow",function(){c.animate({"margin-top":-256,"margin-left":-320,width:640,height:550},"slow",function(){g.show()});$(this).animate({width:640,height:496},{duration:"slow",queue:!1,complete:function(){$(this).remove()}})})})})})}})})});$("#div_vtcontainer > img.close").click(function(){$(this).parent().find("*").andSelf().removeAttr("style").filter("div.thumbnails").empty();$("#div_modallayer").fadeOut("slow")});appState.user.favorites[a]?
$("#btnFavorite").button("option","icons",{primary:"ui-icon-closethick"}).children("span.ui-button-text").html("Remove from Favorites"):$("#btnFavorite").button("option","icons",{primary:"ui-icon-heart"}).children("span.ui-button-text").html("Add to Favorites");$("#btnFavorite").unbind().click(function(){if(appState.user.loggedIn){$(this).button("disable");var c,b,d=this;appState.user.favorites[a]?(c=-1,b=function(){delete appState.user.favorites[a];$(d).button("enable").button("option","icons",{primary:"ui-icon-heart"}).children("span.ui-button-text").html("Add to Favorites");
redrawFavorites()}):(c=1,b=function(){appState.user.favorites[a]=!0;$(d).button("enable").button("option","icons",{primary:"ui-icon-closethick"}).children("span.ui-button-text").html("Remove from Favorites");redrawFavorites()});$.ajax({url:"default.aspx/UpdateFavorite",data:'{"mls":"'+a+'","operation":'+c+"}",success:b})}else alert("You must first log in to your account to add a favorite property.")});$("#div_loggedin a").eq(1).data("redrawFn",function(){redrawPropertyTab(a)});$("#inpRasMls").val(a)}
function redrawFavorites(){$("#ul_favorites").empty();$.each(appState.user.favorites,function(a){addToPropertyList(a,"#ul_favorites")})}
function addToPropertyList(a,b){newContent=createItemContent(a);$(newContent).find("td.more").parent().add("td.icons",newContent).remove();$("<li></li>").addClass("propertyItem").append(newContent).appendTo(b).click(function(){appState.gMap.goTo([appState.properties[a].geo_lat,appState.properties[a].geo_long],17);$.ajax({url:"default.aspx/AddHit",data:'{"mls":"'+a+'", "hitType":'+hitType.searchClick+"}"});displayProperty(a,function(){$(".verticaltab:contains(Detail View)").parent().click()})})}
function initLogin(){$("#div_loggedout > button").button({icons:{primary:"ui-icon-person"}}).click(function(){var a=$(this).button("disable"),d={};d.email=$(this).siblings("input").eq(0).val();d.password=$(this).siblings("input").eq(1).val();$.ajax({url:"default.aspx/LogIn",data:JSON.stringify(d),success:function(d){a.button("enable");(appState.user.loggedIn=d.success)?(a.siblings("input").val("").blur(),b(d.message)):alert("You entered an invalid e-mail and password combination.")}})});var a=function(){$(this).children("input").each(function(a,
b){$("span.inputOver").eq(a).css({left:$(b).position().left+3,top:$(b).position().top+2}).click(function(){$(b).focus()})}).unbind().focus(function(){$(this).prev("span.inputOver").hide()}).blur(function(){$(this).val()==""&&$(this).prev("span.inputOver").show()}).blur().eq(1).keydown(function(a){if(a.which||a.keyCode)(a.which==13||a.keyCode==13)&&$("#div_loggedout > button").click()})};$("#div_loggedin > ul a").eq(0).click(function(a){a.preventDefault();$(".verticaltab:contains(Favorites)").click()}).end().eq(1).click(function(c){c.preventDefault();
if($(this).data("activeRequest"))return!1;else $(this).data("activeRequest",!0);var b=this;$.ajax({url:"default.aspx/LogOut",success:function(){$("#ul_favorites").empty();appState.user.favorites={};appState.user.loggedIn=!1;$("#div_loggedin").hide();$("#div_loggedout").show(0,a);$(b).data("activeRequest",!1);$(b).data("redrawFn")&&$(b).data("redrawFn")()}})});var b=function(a){$("#div_loggedout").hide();$("#div_loggedin").show().children("p").html("Welcome, "+a+"!");appState.user.loggedIn&&$.ajax({url:"default.aspx/GetFavorites",
success:function(a){var c=a.length;if(!appState.user.loggedIn||c==0)return $("#ul_favorites").empty(),appState.user.favorites={},!1;var b=0,g=function(a){return function(){addToPropertyList(a,"#ul_favorites");++b==c&&appState.gMap.clusterMarkers(!0,function(a){return appState.filter.meetsCriteria(a)})}};$.each(a,function(a,c){appState.user.favorites[c]=!0;var b=g(c);appState.properties[c]?b():pinProperty(c,b)})}})};$.ajax({url:"default.aspx/GetLoginStatus",success:function(c){(appState.user.loggedIn=
c.loggedIn)?b(c.message):$("#div_loggedout").show(0,a)}})}
function initTabs(){var a=function(){google.maps.event.trigger(appState.gMap.getPanorama(),"resize");google.maps.event.trigger(appState.gMap.getMap(),"resize")},b=$("#div_albumoverlay");$("#td_tabs > div").not(".minimize").click(function(){if(!appState.tabPane.visible)$("#td_tabs").parents("div").animate({width:"+=400"},{duration:"slow",step:function(a){b.css("margin-left",-1*a+36)},complete:a}),appState.tabPane.visible=!0;$(".tab_content").hide();$(this).is(":contains(Detail View)")?$("#tbl_propdetails").show():
$(this).is(":contains(List View)")?$("#div_nearbylist").show():$(this).is(":contains(Favorites)")?$("#div_favorites").show():$(this).is(":contains(Criteria)")?$("#div_criteria").show():$(this).is(":contains(Navigation)")?$("#div_navigation").show():$(this).is(":contains(?)")&&$("#div_help").show()});$("#td_tabs > div.minimize").click(function(){if(appState.tabPane.visible)$("#td_tabs").parents("div").animate({width:"-=400"},{duration:"slow",step:function(a){b.css("margin-left",-1*a+36)},complete:a}),
appState.tabPane.visible=!1});$("#td_tabs > div").click(function(){$("#td_tabs > div.selected").removeClass("selected");$(this).addClass("selected")})}
function initPropertyDetails(){$("#div_propdetails button").button().filter("#btnStreetView, #btnVirtualTour").button("disable");$("#div_vtcontainer button").button({icons:{primary:"ui-icon-arrowthick-1-w"}});$("#div_albumnav > div").hover(function(){isiPad()||$(this).children("span").stop().fadeIn("slow",function(){$(this).css("opacity",0.85)})},function(){isiPad()||$(this).children("span").stop().fadeOut("slow")}).filter(".albumPrev").click(function(){$("#div_albumstage").animate({scrollLeft:"-=380"},
"slow")}).end().filter(".albumNext").click(function(){$("#div_albumstage").animate({scrollLeft:"+=380"},"slow")});$("#div_albumviewer > img.close").click(function(){$(this).parent().hide();$("#div_modallayer").fadeOut("slow")});$("#btnRequestShowing").click(function(){$("#div_modallayer").fadeIn("slow",function(){$.browser.msie&&$(this).css("opacity",0.35);$("#div_reqshowing").show()})}).button("option","icons",{primary:"ui-icon-mail-open"});$("#div_reqshowing input:checkbox").button();var a=["ui-icon-mail-closed",
"ui-icon-refresh"];$("#div_reqshowing button").each(function(c){$(this).button({icons:{primary:a[c]}})}).eq(0).click(function(a){a.preventDefault();var c=!0;$("#div_reqshowing").find("p.validationAlert").remove().end().find("input.required").each(function(){if($(this).val()=="")return c=!1,$(this).after('<p class="validationAlert">This field requires an entry.</p>'),!1;else if($(this).hasClass("email")&&(c=/[-\.\w]+@[-a-z0-9](.[-a-z0-9])+$/.test($(this).val()),!c))return $(this).after('<p class="validationAlert">Please enter a valid e-mail address.</p>'),
!1});if(!c)return!1;$(this).button("disable").closest("form").submit()}).end().eq(1).click(function(a){a.preventDefault();$(this).closest("form")[0].reset()});var b=function(a){a.preventDefault();var c=this,d={};$.each($(this).serializeArray(),function(a,c){d[c.name]=c.value});$.ajax({url:"default.aspx/RequestShowing",data:JSON.stringify({data:d}),success:function(a){a?(alert("Your request for a showing has sent successfully. An agent will be in touch with you in the near future."),$("#div_reqshowing > img.close").click()):
alert("We were unable to submit your request at this time. Please try again later.")},complete:function(){$(c).one("submit",b).find("button").first().button("enable")}})};$("#div_reqshowing").closest("form").one("submit",b);$("#div_reqshowing img.close").click(function(){$(this).parent().hide();$("#div_modallayer").fadeOut("slow")});var c=["January","February","March","April","May","June","July","August","September","October","November","December"],d=new Date;$.each(c.slice(d.getMonth()),function(a,
c){var b=c+" "+d.getFullYear();$("#ddlRasMoveIn").append($("<option></option>").html(b).val(b))});$.each(c.slice(0,d.getMonth()),function(a,c){var b=c+" "+(d.getFullYear()+1);$("#ddlRasMoveIn").append($("<option></option>").html(b).val(b))});$("#div_reqshowing input.phone").mask("(999) 999-9999? x99999")}
function initFilters(){$("#div_criteria input[name='radFilterActive']").change(function(){if(!$(this).is(":checked"))return!1;switch($(this).val()){case "true":$("#div_criteriaControls").show();break;case "false":$("#div_criteriaControls").hide()}});$("#div_criteria input[name='radFilterCat']").change(function(){if(!$(this).is(":checked"))return!1;var a=parseInt($(this).val());$("#div_criteria label.variable").hide();switch(a){case 1:$("#div_criteria label.res").show();$('label[for="chkFilterSqft"]').removeClass("ui-corner-left");
break;case 4:$("#div_criteria label.cib").show(),$('label[for="chkFilterSqft"]').addClass("ui-corner-left")}$("#div_criteria div.variable").hide();$("#div_criteria label.variable:visible").each(function(){$("#"+$(this).attr("for")).change()})});$("div.criteria > input:checkbox").change(function(){var a=$(this).attr("id").split("chk")[1];$(this).is(":checked")?$("#sld"+a).parent().show().css("background-color","#f66").animate({"background-color":"#fff"},"slow"):$("#sld"+a).parent().hide()}).change();
$("div.slider").each(function(){var a={animate:!0};switch($(this).attr("id").split("sldFilter")[1]){case "Radius":a.step=0.1;a.min=0.5;a.max=5;a.range="min";a.value=1;a.slide=a.change=function(a,c){$(this).prev().html("Search Radius: "+c.value.toFixed(1)+" miles")};$(this).prev().html("Search Radius: "+a.value.toFixed(1)+" miles");break;case "Price":a.step=25E3;a.min=0;a.max=1E6+a.step;a.range=!0;a.slide=a.change=function(a,c){var d=c.values[1]!=$(this).slider("option","max")?"$"+addCommas(c.values[0])+
" - $"+addCommas(c.values[1]):"$"+addCommas(c.values[0])+"+";$(this).siblings("h2").html("List Price: "+d)};$(this).siblings("h2").html("List Price: $0 - $0");break;case "Acreage":a.step=0.5;a.min=0;a.max=20+a.step;a.range=!0;a.slide=a.change=function(a,c){var d=c.values[1]!=$(this).slider("option","max")?c.values[0].toFixed(1)+" acres - "+c.values[1].toFixed(1)+" acres":c.values[0].toFixed(1)+"+ acres";$(this).siblings("h2").html("Acreage: "+d)};$(this).siblings("h2").html("Acreage: 0.0 acres - 0.0 acres");
break;case "ListDate":a.step=5;a.min=a.value=5;a.max=365;a.range="min";a.slide=a.change=function(a,c){$(this).siblings("h2").html("List Date: Within the last "+c.value+" days")};$(this).siblings("h2").html("List Date: Within the last "+a.value+" days");break;case "Beds":a.step=1;a.min=a.value=1;a.max=6;if(!isiPad())a.range="max";a.slide=a.change=function(a,c){$(this).siblings("h2").html(function(a,b){return b.replace(/\d/,c.value)})};$(this).siblings("h2").html("Bedrooms: 1 <span class='compare'></span> bed(s)");
break;case "Baths":a.step=1;a.min=a.value=1;a.max=6;if(!isiPad())a.range="max";a.slide=a.change=function(a,c){$(this).siblings("h2").html(function(a,b){return b.replace(/\d/,c.value)})};$(this).siblings("h2").html("Bathrooms: 1 <span class='compare'></span> bath(s)");break;case "Sqft":a.step=250,a.min=0,a.max=1E4+a.step,a.range=!0,a.slide=a.change=function(a,c){var d=c.values[1]!=$(this).slider("option","max")?addCommas(c.values[0])+" sqft - "+addCommas(c.values[1])+" sqft":addCommas(c.values[0])+
"+ sqft";$(this).siblings("h2").html("Square Footage: "+d)},$(this).siblings("h2").html("Square Footage: 0 sqft - 0 sqft")}$(this).slider(a)});$("div.criteriaCompare > input:radio").change(function(){var a="",b=$(this).attr("id").substring($(this).attr("id").length-2),c=$(this).parent().siblings("div.slider")[0];switch(b){case "Gt":a="or more";isiPad()||$(c).slider("option","range","max");break;case "Lt":a="or fewer";isiPad()||$(c).slider("option","range","min");break;case "Eq":isiPad()||$(c).slider("option",
"range",!1)}$(this).parent().siblings("h2").children("span.compare").html(a)}).filter(":checked").change();$("#div_filterConfirm > button").each(function(a){var b={icons:{primary:null}};b.icons.primary=a==0?"ui-icon-disk":"ui-icon-cancel";$(this).button(b).click(a==0?function(a){a.preventDefault();appState.filter.setFilter("active",$("#radFilterOn").is(":checked"));appState.filter.setFilter("category",{active:$("#radFilterOn").is(":checked"),value:parseInt($('input[name="radFilterCat"]:checked').val())});
appState.filter.setFilter("beds",{active:$("#chkFilterBeds").is(":checked"),value:$("#sldFilterBeds").slider("value"),compare:parseInt($('input[name="radFilterBedsComp"]:checked').val())});appState.filter.setFilter("baths",{active:$("#chkFilterBaths").is(":checked"),value:$("#sldFilterBaths").slider("value"),compare:parseInt($('input[name="radFilterBathsComp"]:checked').val()),fullOnly:!1});appState.filter.setFilter("price",{active:$("#chkFilterPrice").is(":checked"),minvalue:$("#sldFilterPrice").slider("values",
0),maxvalue:$("#sldFilterPrice").slider("values",1)!=$("#sldFilterPrice").slider("option","max")?$("#sldFilterPrice").slider("values",1):-1});appState.filter.setFilter("sqft",{active:$("#chkFilterSqft").is(":checked"),minvalue:$("#sldFilterSqft").slider("values",0),maxvalue:$("#sldFilterSqft").slider("values",1)!=$("#sldFilterSqft").slider("option","max")?$("#sldFilterSqft").slider("values",1):-1});appState.filter.setFilter("acres",{active:$("#chkFilterAcreage").is(":checked"),minvalue:$("#sldFilterAcreage").slider("values",
0),maxvalue:$("#sldFilterAcreage").slider("values",1)!=$("#sldFilterAcreage").slider("option","max")?$("#sldFilterAcreage").slider("values",1):-1});appState.filter.setFilter("listdate",{active:$("#chkFilterListDate").is(":checked"),value:$("#sldFilterListDate").slider("value")});appState.filter.setFilter("radius",$("#sldFilterRadius").slider("value"));$.ajax({url:"default.aspx/SetFilter",data:'{"newFilter":'+appState.filter.getSerializedState()+"}",success:function(){appState.synch.requestCall(buildRepromptFunc("Your search criteria have changed."))}})}:
function(a){a.preventDefault();var a=$("#div_criteria"),b={};$('input[name="radFilterActive"]',a).eq(appState.filter.getFilter("active")?0:1).attr("checked",!0);$('input[name="radFilterCat"][value="'+appState.filter.getFilter("category").value+'"]',a).attr("checked",!0);b=appState.filter.getFilter("beds");$("#chkFilterBeds").attr("checked",b.active);$("#sldFilterBeds").slider("value",b.value);$('input[name="radFilterBedsComp"][value="'+b.compare+'"]',a).attr("checked",!0);b=appState.filter.getFilter("baths");
$("#chkFilterBaths").attr("checked",b.active);$("#sldFilterBaths").slider("value",b.value);$('input[name="radFilterBathsComp"][value="'+b.compare+'"]',a).attr("checked",!0);b=appState.filter.getFilter("price");$("#chkFilterPrice").attr("checked",b.active);$("#sldFilterPrice").slider("values",[b.minvalue,b.maxvalue!=-1?b.maxvalue:$("#sldFilterPrice").slider("option","max")]);b=appState.filter.getFilter("sqft");$("#chkFilterSqft").attr("checked",b.active);$("#sldFilterSqft").slider("values",[b.minvalue,
b.maxvalue!=-1?b.maxvalue:$("#sldFilterSqft").slider("option","max")]);b=appState.filter.getFilter("acres");$("#chkFilterAcreage").attr("checked",b.active);$("#sldFilterAcreage").slider("values",[b.minvalue,b.maxvalue!=-1?b.maxvalue:$("#sldFilterAcreage").slider("option","max")]);b=appState.filter.getFilter("listdate");$("#chkFilterListDate").attr("checked",b.active);$("#sldFilterListDate").slider("value",b.value);$("#sldFilterRadius").slider("value",appState.filter.getFilter("radius"));$("input",
a).change()})})}
function initNavigation(){navigator.geolocation&&$("div.geolocate").show().click(function(){appState.gMap.geolocateUser()});$.ajax({url:"default.aspx/GetCities",success:function(a){$.each(a,function(a,c){$("<option></option>").text(c).val(c).appendTo("#selNavCity")})}});$("#div_navigation input[name='radNavigation']").change(function(){$(this).is(":checked")&&($("#div_navigation div.navControl").hide(),$("#div"+$(this).attr("id").split("rad")[1]).show())}).filter(":checked").change();$("#div_navigation button:contains(Go)").click(function(a){a.preventDefault();
switch($("#div_navigation input[name='radNavigation']:checked").val()){case "addr":$("#inpNavStreet").val()!=""&&($("#inpNavCity").val()==""||$("#inpNavState").val()=="")?appState.gMap.geocode(appState.gMap.getMap().getCenter(),function(a,b){var e=$("#inpNavCity").val(),f=$("#inpNavState").val();b==google.maps.GeocoderStatus.OK?($.each(a[0].address_components,function(a,b){if(e==""&&$.inArray("locality",b.types)!=-1)e=b.long_name;if(f==""&&$.inArray("administrative_area_level_1",b.types)!=-1)f=b.short_name;
if(e!=""&&f!="")return!1}),appState.gMap.goTo($("#inpNavStreet").val()+", "+e+", "+f,17)):b==google.maps.GeocoderStatus.ZERO_RESULTS?alert("The information you provided could not be converted to a location on the map. Please edit your entry and try your search again."):alert("We were not able to process your request. Our attempt to turn the address into a latitude and longitude on the map resulted in the following error from Google:\n\n"+b)}):appState.gMap.goTo($("#inpNavStreet").val()+", "+$("#inpNavCity").val()+
", "+$("#inpNavState").val(),17);break;case "city":$("#selNavCity").val()!=""?appState.gMap.goTo($("#selNavCity").val(),15):alert("Please select a city from the drop down menu.");break;case "mls":var b=$("#inpNavMLS").val();pinProperty(b,function(){appState.gMap.goTo([appState.properties[b].geo_lat,appState.properties[b].geo_long],17);appState.gMap.clusterMarkers();displayProperty(b,function(){$(".verticaltab:contains(Detail View)").parent().click()})})}}).button({icons:{primary:"ui-icon-check"}})}
function initDynamicView(){appState.gMap.addListener(appState.gMap.getMap(),"center_changed",function(){appState.synch.requestCall(buildRepromptFunc("The map has been repositioned."));var a=appState.gMap.getMap().getCenter();appState.filter.setLocation(a.lat(),a.lng())});appState.synch=new LocationSearch.SynchManager(function(){$("#div_mvstatus").css({height:62,width:372}).html("<p>Searching for new properties that meet your criteria&hellip;</p>").append($("<div></div>").addClass("progressbar").progressbar().css({"background-color":"#444",
"background-image":"none"}));pinNearbyProperties()},function(){$("#div_mvstatus").hide()});appState.synch.requestCall()}
function initStaticView(){$("#td_tabs > div:contains(Criteria)").hide();$("#div_nearbylist h1.tab_header").html("All Properties");$("#div_mvstatus").css({height:62,width:372}).html("<p>Retrieving your result set&hellip;</p>").append($("<div></div>").addClass("progressbar").progressbar().css({"background-color":"#444","background-image":"none"}));$.ajax({url:"default.aspx/GetMapView",data:'{"id":'+location.queryString.mapView+"}",success:function(a){var b=0,c=0;$.each(a.groups,function(a,c){b+=c.listings.length});
$.each(a.groups,function(d,e){$.each(e.listings,function(f,g){pinProperty(g,function(){$("#div_mvstatus > p").html("Retrieving properties from your result set: ("+ ++c+"/"+b+")").siblings("div.progressbar").progressbar("value",c*100/b);addToPropertyList(g,"#ul_nearby");if(d+1==a.groups.length&&f+1==e.listings.length){appState.gMap.clusterMarkers();var h=new google.maps.LatLngBounds(new google.maps.LatLng(a.bounds.southwest.lat,a.bounds.southwest.lng),new google.maps.LatLng(a.bounds.northeast.lat,
a.bounds.northeast.lng));appState.gMap.getMap().fitBounds(h);$("#div_mvstatus").hide();$("#td_tabs > div:contains(List View)").click()}})})})}})}
$(document).ready(function(){$.ajaxSetup({type:"POST",data:"{}",contentType:"application/json; charset=utf-8",dataType:"json",dataFilter:function(a){a=$.parseJSON(a);return a.hasOwnProperty("d")?a.d:a},timeout:15E3});$.browser.msie&&$.browser.version=="7.0"?$(window).resize(function(){$("#table_mapview").css("height",$(window).height());$("#map_pane").parent().css("height",$(window).height()-70)}):$.browser.mozilla&&$(window).resize(function(){$("#map_pane").css("height",$(window).height()-70)});
$(window).resize(function(){$("#tab_pane").css("height",$(window).height()-70);$("#td_propdetails").css("height",$(window).height()-305)}).resize();initMapManager();$("div.buttonset").buttonset();initLogin();initTabs();initPropertyDetails();initFilters();initNavigation();isiPad()&&$(".scrollable").jScrollTouch();location.queryString.mapView?initStaticView():initDynamicView()});
function addCommas(a){a+="";x=a.split(".");x1=x[0];x2=x.length>1?"."+x[1]:"";for(a=/(\d+)(\d{3})/;a.test(x1);)x1=x1.replace(a,"$1,$2");return x1+x2}function isiPad(){return/iPad/.test(navigator.userAgent)}hitType={searchResult:1,searchClick:2,featuredResult:3,similarResult:4,openHouse:5,geoSearch:6,homepage:7,photo:8,virtualTour:9};function categoryLookup(a){switch(a){case 1:return"RES";case 2:return"LND";case 3:return"MUL";case 4:return"CIB";default:return"NIL"}};
