if(typeof hotpads=="undefined"){var hotpads={};}hotpads.text={listingFilterString:"",searcherParams:{page:1,resultsPerPage:10},locationParams:{},fullViewParams:{detailsOpen:"",previewType:"",previewId:""},loaded:false,currentResultUrl:"",currentRequest:0,currentListingIds:{},setPage:function(a){hotpads.text.searcherParams.page=a;
if(hotpads.text.loaded){hotpads.text.refresh();}},load:function(c,d,a,b){$.log("loading text search: "+c+";"+d+";"+a+";"+b);hotpads.text.loaded=true;$("#searchWindow").html(hotpads.base.loadingDiv);d=(typeof(d)!="undefined")?d:"";a=(typeof(a)!="undefined")?a:"";b=(typeof(b)!="undefined")?b:"";hotpads.text.update(c,d,a,b);
},unload:function(){hotpads.text.loaded=false;hotpads.text.currentResultUrl="";},update:function(b,c,e,a,d){hotpads.text.listingFilterString=b;if(typeof(c)!="undefined"){hotpads.text.locationParams=$.deserialize(c);}if(typeof(e)!="undefined"){hotpads.text.fullViewParams=$.deserialize(e);}if(typeof(a)!="undefined"){hotpads.text.searcherParams=$.deserialize(a);
}if(typeof(hotpads.text.searcherParams.page)=="undefined"){hotpads.text.searcherParams.page=1;}if(typeof(hotpads.text.searcherParams.resultsPerPage)=="undefined"){hotpads.text.searcherParams.resultsPerPage=10;}if(typeof(hotpads.text.currentListingIds)=="undefined"){hotpads.text.currentListingIds={};}if(hotpads.text.loaded){hotpads.text.refresh(d);
}hotpads.base.updateFullView(e);},changeLocation:function(a){hotpads.text.locationParams={};hotpads.text.locationParams.locationName=a;hotpads.text.searcherParams.page=1;if(hotpads.text.loaded){hotpads.text.refresh();}},changeOrderBy:function(a){$.log("orderByStringFunc: "+$("#orderByString").val());
var b=$.deserialize(a);hotpads.text.searcherParams.page=1;hotpads.text.searcherParams.orderBy=b.orderBy;hotpads.text.searcherParams.ascending=b.ascending;if(hotpads.text.loaded){hotpads.text.refresh();}},getOrderParams:function(){return $.param(hotpads.text.searcherParams);},getLocation:function(){return $.param(hotpads.text.locationParams);
},getFullViewParams:function(){return $.param(hotpads.text.fullViewParams);},getUrlString:function(a){var b="/search/?textFragment=true"+"&"+"appendOneListing="+a+"&"+hotpads.text.listingFilterString+"&"+$.param(hotpads.text.locationParams)+"&"+$.param(hotpads.text.searcherParams)+"&"+$.param(hotpads.text.fullViewParams)+"&"+"seed="+Math.random();
b=b.replace(/&{1,}/g,"&");return b;},refresh:function(b){var c=hotpads.text.getUrlString(false);hotpads.text.updatePermalink(b);scroll(0,0);if(hotpads.text.currentResultUrl!=c){hotpads.text.currentResultUrl="";$("#searchWindow").html(hotpads.base.loadingDiv);hotpads.base.hideFooter();hotpads.text.currentRequest++;
var a=hotpads.text.currentRequest;$.ajax({url:c,success:function(d){if(a==hotpads.text.currentRequest&&hotpads.searcher==hotpads.text){$("#searchWindow").html(d);hotpads.text.currentResultUrl=c;hotpads.base.loadFooter();}}});}},updatePermalink:function(a){if(typeof(a)!="undefined"&&!a){return;}hotpads.text.searcherParams.searcher="text";
var b=($.param(hotpads.text.searcherParams))+"&"+($.param(hotpads.text.locationParams))+"&"+($.param(hotpads.text.fullViewParams))+"&"+hotpads.text.listingFilterString;b=b.replace(/&{1,}/g,"&");setPermalink(b);setLinkVars(b);},openFullView:function(c,a){loadFullView(c);$("#resultMapDiv").hide();if($("#title_"+c).length&&!$("#title_"+c).hasClass("viewedListing")){$("#title_"+c).addClass("viewedListing");
propertyMarkViewed.markViewedListing(c);if($("#element_"+c).find(".impressionIdHolder").length){var b=$("#element_"+c).find(".impressionIdHolder").val();$.get("/featuredata/listingCampaigns.htm?submitAction=registerListingCampaignEvent&type=clicked&listingImpressionId="+b);}}hotpads.text.fullViewParams={detailsOpen:"true",previewType:"listing",previewId:c};
hotpads.text.updatePermalink(a);},closeFullView:function(a){hotpads.base.closeFullView();hotpads.text.fullViewParams={};hotpads.text.updatePermalink(a);$("#resultMapDiv").show();},setAsFavorite:function(b,a){if(a=="true"){if(!$("#title_"+b).hasClass("favoriteListing")){$("#title_"+b).addClass("favoriteListing");
}}else{if($("#title_"+b).hasClass("favoriteListing")){$("#title_"+b).removeClass("favoriteListing");}}},hide:function(b,c){$("#element_"+b).addClass("listElementHidden");var a={textSearchResultPage:c};$.getJSON("/userSearch/hidden/add/ajax/"+b,a,function(d){if("success"==d.status){hotpads.text.fetchAndAppendNewListing();
var e=1000;$("#element_"+d.listingId).slideUp(e);setTimeout(function(){hotpads.text.removeListing(d.listingId);},e);}else{alert("There was a problem on the server when hiding this listing.");}});},removeListing:function(a){$("#element_"+a).remove();hotpads.text.currentListingIds[a]=false;},fetchAndAppendNewListing:function(){var e=hotpads.text.searcherParams.page*hotpads.text.searcherParams.resultsPerPage;
var d=hotpads.text.searcherParams.page;hotpads.text.searcherParams.page=e;var b=hotpads.text.searcherParams.resultsPerPage;hotpads.text.searcherParams.resultsPerPage=1;var f=hotpads.text.searcherParams.resultsPerPage;hotpads.text.searcherParams.numFeatured=0;var a=hotpads.text.getUrlString(true);hotpads.text.currentRequest++;
var c=hotpads.text.currentRequest;var g="";for(id in hotpads.text.currentListingIds){g+=id+",";}var h={currentListingIds:g};$.getJSON(a,h,function(i){if(c==hotpads.text.currentRequest&&hotpads.searcher==hotpads.text&&typeof(i)!="undefined"&&typeof(i.listingId)!="undefined"&&typeof(i.htmlListing)!="undefined"){hotpads.text.currentListingIds[i.listingId]=true;
$("#results").append(i.htmlListing);document.getElementById("totalResults").innerHTML=i.totalResults;$("#element_"+i.listingId).hover(function(){$(this).addClass("listElementHover");},function(){$(this).removeClass("listElementHover");});}});hotpads.text.searcherParams.page=d;hotpads.text.searcherParams.resultsPerPage=b;
hotpads.text.searcherParams.numFeatured=f;},hover:function(a){$.log("hover "+"#element_"+a);$("#element_"+a).addClass("listHover");},unhover:function(a){$.log("unhover "+"#element_"+a);$("#element_"+a).removeClass("listHover");}};