/* results
 
@author Jacob at Goby
 @version 03/10/10
@svn 120
*/

function ResultSteps(parameters)
{this.resultData=null;this.parameters=parameters;}
ResultSteps.prototype={initialize:function()
{this.init();this.loadMap();this.loadAds();},loadAds:function()
{var adParams={'key':GOOGLE_ADS_KEY,'query':this.parameters.categoryName+" "+this.parameters.fullLocationName};google.load('ads.search','1');$(function(){var dynamicAd=new google.ads.search.Ad({'pubId':adParams.key,'query':adParams.query,'container':'google_adcontainer','number':3,'format':'narrow',colorText:'#343434',colorTitleLink:'#337ca5',colorDomainLink:'#b2b2b2',colorBackground:'#ffffff'});});},loadMap:function()
{},displayLoader:function()
{this.resultSet.initLoader();},init:function()
{this.resultSet=new resultSet(this.parameters);var mapLoader=Goby.get("MapLoader");mapLoader.loadMap({object:this.resultSet,method:"activateMap"});mapLoader.addExtra(JS_PATH+"/gmlocalsearch.js");mapLoader.init();Goby.set("resultSet",this.resultSet);window.setParameters();return this.resultSet;},resultsLoaded:function()
{if(this.resultData!=null)
return true;else
return false;},loadResultData:function(resultData)
{this.resultData=resultData;},displayResults:function()
{var resultData=this.resultData;var resultObject=this.resultSet;if(!window.getParameter("page").isDeclared())
{(resultData.forced?window.setParameter(new Parameter('page',null,resultObject.pageID)):resultObject._parameter=new Parameter('page',null,resultObject.pageID));}
if(!window.getParameter("filters").isDeclared())
{if(resultData.modules!=null)
this.loadCustomParameters(resultData.modules[resultObject.categoryID]);}
var filterParams={page:(window.getParameter("page")),sort:(window.getParameter("sort")),filters:(window.getParameter("filters"))};resultObject.initResults(filterParams,resultData);$(document).ready(function()
{resultObject.updateLoader();window.makeAnchorsCompatable();window.setHistoryStorage();_initKeywordSearch(resultObject);});},loadCustomParameters:function(module)
{if(module==null)
return false;if(module.misc.parameters!=null)
{var params=module.misc.parameters;for(var i in params)
{var node=params[i];var array=[];for(var j in node)
array.push(node[j]);params[i]=array;}
var filter=new Parameter("filters",true,params);filter.declared=true;window.setParameter(filter);}}}
Number.prototype.toRad=function()
{return this*Math.PI/180;}
var ResultGroup={ALL:0,FILTER:1,PG:2}
var ResultStatus={COMPLETE:1,INIT:2,PROCESSING:2,REQUERY:4,PENDING:0,ERROR:9}
if(navigator.isBrowser(browser.IE))
{var SORTIE={up:-1,same:0,down:1,more:2};}
else
{var SORTIE={up:1,same:0,down:-1,more:2};}
function resultSet(params)
{if(params!=null)
{this._construct(params);this.updateTitle({location:{name:this.locationName,id:this.locationID,type:this.locationType},category:{name:this.categoryName,id:this.categoryID}});objects.push(this);}}
resultSet.prototype={_construct:function(params)
{this.coordinates=null;if(params.lat&&params.lng&&params.locationName)
this.setCenterCoor({lat:params.lat,lng:params.lng,locationName:params.locationName});this.chain={};this.setCategoryID(params.categoryID);this.useMap=USE_MAP;this.setLocationID(params.locationID);this.setDateID(params.dateID);this.nudged=false;this.filterActive=false;this.errorbox=null;this.stream=0;this.resultIndex=[];this.mapOkay=true;this.index=0;this.categorySet=[];this.entryContainer=(params.entryContainer!=null?params.entryContainer:null);this.sortContainer=null;this.displayable=false;this.onloadQueue=[];this.pageCnt=0;this.results=[];this.map={};this.filterSet=[];this.init=false;this.locationName=params.locationName;this.categoryName=params.categoryName;this.locationType=params.locationType;this.dateName=params.dateName;this.searchTitle=params.searchTitle;this.pageID=(params.pageID?params.pageID:0);this.status=ResultStatus.PENDING;this.mapActive=false;this.modules=[];this.REQUEST_URL=AJAX_PATH+"result_requests.php";this.parameters={};this.activeFilters=[];this.resultGroups={};this.resultGroups[ResultGroup.ALL]=[];this.resultGroups[ResultGroup.FILTER]=[];this.resultGroups[ResultGroup.PG]=[];},initLoader:function()
{this.resultLoader=null;this.resultLoader=new SearchLink({type:'mimic',url:window.location.href,label:this.searchTitle,'loader':1,'parent':document.getElementById("_resultLoader")});this.resultLoader.resultSet=this;this.resultLoader.getTitle=function(){return this.resultSet.searchTitle;}
this.resultLoader.open();},getLocationType:function(){return(this.locationType!=null?this.locationType:false);},initEvents:function(){},activateMap:function()
{if((this.mapActive!=true))
{this.mapActive=true;if(this.getCenterCoor()&&(this.isDisplayable()))
this.initMap();}},getCenterCoor:function()
{return(this.coordinates?this.coordinates:false);},isMapActive:function()
{return this.mapActive;},setMap:function(map,type)
{this.map['small']=map;this.map['small'].resultSet=this;this.selectMap(type);this.map_init=true;},getMap:function(type)
{if(this.map['small']!=undefined)
return this.map['small'];else
return false;},toggleQuery:function()
{if(this.query==true)
{this.query=false;for(index in this.map)
{this.map[index].toggleQuery(false);}}
else
{for(index in this.map)
{this.map[index].toggleQuery(true);}}},addCategories:function(data)
{for(var i in data)
{this.categorySet[i]=data[i];}},setCategoryID:function(categoryID)
{this.categoryID=categoryID;},setLocationID:function(locationID)
{this.locationID=locationID;},setDateID:function(dateID)
{this.dateID=dateID;},_destruct:function()
{var count=0;this.unsetResultGroup(ResultGroup.PG);for(var i in this)
{if(this[i]!=null)
{if(this[i]._destruct)
this[i]._destruct();else
this[i]=null;count++;}}
killself(this);},fetchResults:function(params)
{var data={'action':(params.action),'categoryID':this.categoryID,'locationID':this.locationID,'date':this.dateID,'encode':1,'limit':params.limit,'offset':params.offset,'status':params.status,'stream':this.stream,'popular':(params.popular!=null?1:0),'display':(params.display!=null?params.display:false),'categoryName':this.categoryName,'locationName':this.locationName,'lng':(params.lng!=undefined?params.lng:false),'lat':(params.lat!=undefined?params.lat:false),'radius':(params.radius!=undefined?params.radius:false)}
var callbackParams={object:this,method:(params.callback!=null?params.callback:"checkPointResult")}
if(this.currentRequest!=null)
{this.currentRequest.terminateRequest();this.currentRequest=null;}
this.currentRequest=new AjaxRequest(this.REQUEST_URL,callbackParams,data,"GET");if(params.ajaxParams)
this.currentRequest.makeRequest(params.ajaxParams);else
this.currentRequest.makeRequest();},setResults:function(resultParams)
{this.fetchResults({});},getContainer:function()
{if(!this.container)
return this.entryContainer;else
return this.container;},startLoadWrapper:function(type)
{switch(type)
{case"wrapper":var cls="loader_wrapper";$(".entry").remove();var iteratorData={title:"searching the web for information about <strong>"+this.categoryName.toLowerCase()+" "+(this.locationName?((this.locationType=="STATE"||this.locationType=="REGION"||this.locationID==LOC_US)?"in":"near")+" "+this.locationName.toLowerCase()+(this.dateID?' for '+this.dateName:''):'')+"</strong>",data:getWrappers(),interval:50}
return{useLoader:true,loaderParent:this.entryContainer,loaderClass:cls,append:false,loaderIterator:iteratorData}
break;case"mini":var loadWrapper=this.getContainer();var cls="loader_widget";return{useLoader:true,loaderParent:loadWrapper,loaderClass:cls,append:false,matchParentHeight:true}
break;default:var loadWrapper=document.getElementById("_loadWrapper");if(loadWrapper==null)
loadWrapper=this.container;var minusData=parseInt($("#header_info").outerHeight())+
parseInt($("#filterContent").outerHeight())+
parseInt($("#filterToggleWrapper").outerHeight())+120;if(navigator.isIE())
{$(loadWrapper).css("height","303");$(loadWrapper).show();this.wipeOutResults();var cls="loader_new_results_ie";}
else
{$(loadWrapper).css("height",$("#entries").innerHeight()-minusData);$(loadWrapper).show();var cls="loader_new_results";}
return{useLoader:true,loaderParent:loadWrapper,loaderClass:cls,append:false,matchParentHeight:true}}},fetchNewResults:function()
{this.stream=0;this.index=0;var adtlParams=this.startLoadWrapper();if(this.errorbox!=null)
this.destroyError();this.pg.resetPages(0);this.pg.hide();this.sortMgr.hide();for(var i in this.activeFilters)
{var filter=this.filterSet[i];if(filter!=null)
if(filter.queryFormat==queryFormat.POST)
this.activeFilters[i]=null;}
for(var fi in this.filterSet)
{var filter=this.filterSet[fi];if(filter.queryFormat==queryFormat.POST)
{}}
var map=this.getMap();if(map!=null)
{for(var i in this.results)
map.rmDot(this.results[i]);if(map.mapRadius!=null)
map.mapRadius.deactivateRadius();}
this.status=ResultStatus.REQUERY;this.fetchResults({offset:0,status:ResultStatus.REQUERY,limit:(this.stream?15:-1),ajaxParams:adtlParams,action:"initResults",callback:"reloadResults"});},initResults:function(resultParams,resultData)
{this.entryContainer=document.createElement("div");this.entryContainer.resultSet=this;this.index=0;this.sortContainer=document.getElementById("sort");for(var index in resultParams)
if(resultParams[index]!=null)
this._setParameter(resultParams[index]);if(resultData.error)
{this.stream=1;}
else if
((this.getParameter('page').isDeclared())||(this.getParameter('sort').isDeclared())||(this.getParameter('filters').isDeclared())||(resultData.forced))
{this.stream=0;}
else
{this.stream=1;}
if(!this.resultLoader)
var adtlParams=this.startLoadWrapper('wrapper');else
var adtlParams={};if(this.stream==0)
{this.fetchResults({offset:0,status:ResultStatus.INIT,limit:-1,ajaxParams:adtlParams,action:"initResults"});return true;}
else
this.checkPointResult(resultData);},setDisplayable:function()
{this.displayable=true;},isDisplayable:function()
{return this.displayable;},updateLoader:function()
{if(this.isDisplayable())
return false;this.setDisplayable();var entryCtr=document.getElementById("entries");var loaderCtr=document.getElementById("main_header");if(entryCtr!=null)
{loaderCtr.appendChild(this.entryContainer);this.entryContainer=entryCtr;this.displayable=true;this.loader;if(this.status==ResultStatus.COMPLETE)
{var queue=this.getQueue();for(var i in queue)
this.loadResults(queue[i]);}
else if(this.status==ResultStatus.PROCESSING)
{var queue=this.getQueue();for(var i in queue)
this.loadResults(queue[i]);}}},updateAccordingly:function()
{var page=this.getParameter('page').serialize();var pageStart=(page*this.pg.resultsPerPage)+1;var pageEnd=pageStart+this.pg.resultsPerPage-1;if(pageEnd>this.pg.resultMax)
pageEnd=this.pg.resultMax;this.pg.resetPages(this.pg.resultMax);this.pg.setDrilldown(this.pg.resultMax,{start:pageStart,end:pageEnd});},completeSettings:function(data)
{if(this.sortMgr!=null)
this.sortMgr.show();this.status=ResultStatus.COMPLETE;if(this.isMapActive()&&(!this.getMap()))
this.initMap();else
this.loadDots();if(this.stream==1)
{this.updateAccordingly();try
{this.pg.selectPage(this.getParameter('page').serialize());}
catch(e)
{}
var sortObj=this.sortMgr.getCurrent();if(sortObj!=null)
{sortObj.results=this.getResultGroup(ResultGroup.ALL);this.sortMgr.sortResults(sortObj);}}},updateSettings:function(data)
{if(data.location.lat!=null)
{this.getMap().resetCenter(data.location);this.setCenterCoor(data.location);this.getMap().addReferencePoint();}
this.pg.resultMax=this.getResultGroup(ResultGroup.ALL).length;this.pg.resetPages(this.getResultGroup(ResultGroup.ALL).length);this.pg.setDrilldown(this.getResultGroup(ResultGroup.ALL).length,{start:1,end:this.pg.resultsPerPage});this.pg.show();this.setParameter(0,'page');for(var i in this.sortMgr.data)
if(!data.pagination.sort[i])
this.sortMgr.removeSort(this.sortMgr.data[i]);for(index in data.pagination.sort)
{var sortData=data.pagination.sort[index];if(!this.sortMgr.getSort(index))
{data.pagination.sort[index].node_id=index;var sortItem=new ResultSortItem(data.pagination.sort[index],this);this.sortMgr.addSort(sortItem);if(sortData.isDefault)
{if(sortItem.forced)
sortItem.select(sortItem.dir);else
{sortItem.reset();sortItem.update();}}}
else if(sortData.isDefault)
{var sortItem=this.sortMgr.getSort(index);if(sortItem.forced)
{sortItem.select(sortItem.dir);}
else
{sortItem.reset();sortItem.update();}}
else
{var node=this.sortMgr.getSort(index);if((node.isHidden())&&(sortData.isHidden==null))
node.display();else if((!node.isHidden())&&(sortData.isHidden))
node.hide();}}
this.sortMgr.show();for(var i in this.filterSet)
{var filter=this.filterSet[i];if(filter.queryFormat==queryFormat.PRE)
filter._update();}},setDateObjects:function(date)
{if(date)
{this.startDate=new Date(date.start*1000);this.endDate=new Date(date.end*1000);}
else
{this.startDate=new Date();this.endDate=null;}},loadSettings:function(data)
{$("#headerinfo_wrapper").show();$("#footer").show();$("#entries").show();$(".entry").remove();data.location.locationName=this.locationName;if(this.coordinates.isCustom)
{data.location.lat=this.coordinates.lat;data.location.lng=this.coordinates.lng;}
this.setDateObjects(data.date);if(data.location!=undefined)
this.setCenterCoor(data.location);else
this.setCenterCoor({lat:45,lng:-71,locationName:"Somewhere"});this.sortMgr=new ResultSortMgr({resultSet:this,hidden:true,container:document.getElementById("sortContent")});data.pagination.headContainer=document.getElementById("pgHead");this.pg=new pagination(document.getElementById("pgFoot"),data.pagination,this)
for(index in data.pagination.sort)
{var sortData=data.pagination.sort[index];data.pagination.sort[index].node_id=index;var sortItem=new ResultSortItem(sortData,this);this.sortMgr.addSort(sortItem);if((sortData.isDefault)&&(!this.getParameter("sort").isDeclared()))
{this.sortMgr.setCurrent(sortItem);this._setParameter(sortItem.getParameters(1).sort,"sort");window.setParameter(sortItem.getParameters(1).sort,"sort");}}
if(!this.sortMgr.getSort("distance"))
{var distanceObject=new ResultSortItem
({method:"distance",dir:"ASC",label:"distance",node_id:"distance",hidden:true,noreverse:true},this);this.sortMgr.addSort(distanceObject);}
this.sortMgr.addSort(new ResultSortItem
({method:"keywordRelevance",dir:"ASC",label:"keywordRelevance",node_id:"keywordRelevance",hidden:true,noreverse:true},this));this.initFilters(data.pagination.filterSet);this.sortMgr.show();},checkPointResult:function(data)
{if(this.isDisplayable())
{this.loadResults(data);}
else
{if(data.complete)
this.status=ResultStatus.COMPLETE;else if(data.display)
this.status=ResultStatus.PROCESSING;this.addQueue(data);}},addQueue:function(data)
{this.onloadQueue.push(data);},getQueue:function()
{return this.onloadQueue;},wipeOutResults:function()
{var results=this.getResultGroup(ResultGroup.ALL);this.unsetResultGroup(ResultGroup.PG);this.setResultGroup(ResultGroup.ALL,[]);this.setResultGroup(ResultGroup.PG,[]);this.setResultGroup(ResultGroup.FILTER,[]);this.results=[];this.resultIndex=[];},reloadResults:function(data)
{$("#_loadWrapper").hide();if(!navigator.isIE())
this.wipeOutResults();if(data==null)
{this.displayError();return false;}
this.addCategories(data.categories);this.addModules(data.modules);for(var index in data.entries)
{if(data.entries[index].facets!=undefined)
{var r=new result(data.entries[index],this);r.DEFAULT_SORT=this.index++;this.results.push(r);this.resultIndex[r.id]=r;}}
this.setResultGroup(ResultGroup.ALL,this.results);this.setResultGroup(ResultGroup.FILTER,this.getResultGroup(ResultGroup.ALL));this.loadDots();this.updateSettings(data);this.getResults({},'_reload');},loadResults:function(data)
{if(this.resultLoader!=null)
this.resultLoader.close();if(data==null)
return false;if(this.stream!=1)
this.index=0;if((data.error)&&(this.results.length<1))
{var style=document.getElementById("js-style");if(style!=null)
style.parentNode.removeChild(style);var tandem=data.error.tandem;if(!tandem)
{$("#entries").html("");$("#entries").show();data.entries=null;this.mapOkay=false;$("#miniMapWrapper").remove();$("#map").remove();this.status=ResultStatus.ERROR;}
this.exception=new Exception(data.error);this.exception.display(document.getElementById("entries"));$("#entries").show();}
else
{var tandem=1;}
if((data.entries)&&(!data.error))
{if(data.init)
this.loadSettings(data);this.addCategories(data.categories);this.addModules(data.modules);for(var index in data.entries)
{if(data.entries[index].facets!=undefined)
{var r=new result(data.entries[index],this);if((this.stream==1)&&(this.resultIndex[r.id]))
{var r=this.resultIndex[r.id];r.DEFAULT_SORT=index;}
else
{this.results.push(r);this.resultIndex[r.id]=r;r.DEFAULT_SORT=this.index++;}
for(var i in this.filterSet)
this.filterSet[i].indexResult(r);}}
this.setResultGroup(ResultGroup.ALL,this.results);this.setResultGroup(ResultGroup.FILTER,this.getResultGroup(ResultGroup.ALL));this.init=true;if(data.complete)
{this.completeSettings(data);try
{for(var i in this.filterSet)
this.filterSet[i].display();}
catch(e)
{}
if(this.stream==0)
{this.getResults({page:this.getParameter("page").serialize(),sort:this.getParameter("sort").serialize(),filters:this.getParameter("filters").serialize()},true);}
else if(data.display==true)
{if(this.isMapActive()&&(!this.getMap()))
this.initMap();this.getResults({},true);if(this._parameter!=null)
{this.results=this.getResultGroup(ResultGroup.ALL);window.setParameter(this._parameter,"page");this._setParameter(this._parameter);}}
if(!navigator.isIE())
window.startComparing(this);else
window.setResultSet(this);}
else if((this.status!=ResultStatus.COMPLETE)&&(this.stream==1))
{var offsetLen=(this._parameter.serialize()>0?0:this.results.length);this.fetchResults({offset:offsetLen,limit:-1,display:false,status:ResultStatus.COMPLETE,action:"streamResults"});if(this.isMapActive()&&(!this.getMap()))
this.initMap();this.blank=true;this.getResults({},true);if(this._parameter!=null)
{window.setParameter(this._parameter,"page");this._setParameter(this._parameter);window.setParameter(this.getParameter("sort"),"sort");this._setParameter(this.getParameter("sort"));}
this.updateAccordingly();}}
else if((this.results.length>=1))
{}
else if((data.error)&&(tandem!=1))
{$("#miniMap").hide();$("#miniMapWrapper").hide();$("#headerinfo_wrapper").hide();$("#drill_current").text('0');$("#drill_max").text('0');$("#filterToggle").hide();$("#pgFoot").hide();$("#sort").hide();$("#entries").show();}},rmDot:function(result)
{this.getMap().rmDot(result);},loadDots:function()
{for(var index in this.results)
{if(this.getMap())
{var r=this.results[index];if((r.facets.location!=null)&&(r.facets.location))
{this.getMap().addDot(r);}}}},initMap:function()
{if(this.exception!=null)
return false;if((!this.isMapActive())||(this.getMap()))
return false;$("#miniMap").show();$("#miniMapWrapper").show();var miniMap=new mapHandler('small',"TESTmap",this.coordinates,{small:['toggle'],big:['toggle']});this.setMap(miniMap,"small");this.loadDots();var map=this.getMap();map.initBounds(map.centerPt);var resultGroup=this.getResultGroup(ResultGroup.PG);for(var index in resultGroup)
{map.setPoint(resultGroup[index]);}
_initMapRadius(this.getMap());_initMapActions(this);_initMapToggle(this);var mui=_initSlidableObject({container:document.getElementById("main_content"),area:document.getElementById("miniMapWrapper"),offset:24});mui.init();map.showAllPoints(2);},getCategory:function(id)
{if(this.categorySet[id]!=null)
return this.categorySet[id];},displayError:function()
{if(this.errorbox==null)
{this.errorbox=document.createElement("div");this.errorbox.innerHTML="no results found for your search query&nbsp;&nbsp;&nbsp;&nbsp;";resetButton=document.createElement("input");resetButton.type="button";resetButton.value="Reset Filters";resetButton.resultSet=this;resetButton.onclick=function()
{this.resultSet.pg.selectPage(0);this.resultSet.clearFilters();}
this.errorbox.appendChild(resetButton);this.entryContainer.appendChild(this.errorbox);}},destroyError:function()
{if(this.errorbox!=null)
{this.entryContainer.removeChild(this.errorbox);delete this.errorbox;this.errorbox=null;}},updateTitle:function(params)
{if(params.category!=null)
{urlParams={locationID:this.locationID,locationName:this.locationName,categoryID:(params.category.id),categoryName:params.category.name}
$category=$("#title-category");var node=document.createElement("a");$(node).insertBefore($category);$category.remove();node.innerHTML=params.category.name.toLowerCase();node.setAttribute("href",getFormattedUrl(urlParams,"search"));node.id="title-category";}
if(params.location!=null)
{urlParams={locationID:(params.location.id),locationName:params.location.name}
$location=$("#title-location");var node=document.createElement("a");$(node).insertBefore($location);$location.remove();node.innerHTML=params.location.name.toLowerCase();node.setAttribute("href",getFormattedUrl(urlParams,"location"));node.id="title-category";}},loadFilter:function(_filter)
{if(_filter==null)
{return false;}
else if(this.filterSet[_filter.label]!=null)
{}
else
{if(_filter.object)
{this.filterSet[_filter.label]=eval("new "+_filter.object+"(_filter,this)");}
else
this.filterSet[_filter.label]=new ResultFilter(_filter,this);return true;}},updateFilters:function()
{},initFilters:function(filters)
{var hideToggle=0;var valid=false;var forceHide=false
for(var i in filters)
{valid=true;if(this.loadFilter(filters[i]))
{if((filters[i].object=="HeirarchyFilter")&&((this.locationID!=LOC_US)&&(this.locationID!=null)))
forceHide=true;}}
if(filters['price']!=null)
{$("#filterToggle").show();this.filterActive=true;return toggleFilters('show');}
if((!valid))
{$("#filterToggle").hide();$("#filters").hide();this.filterActive=false;return false;}
else
{$("#filterToggle").show();$("#filters").show();if((this.locationID==LOC_US))
{this.filterActive=true;return toggleFilters('show');}
if((($.cookie("filterToggle")=="hide")&&(this.categoryID!=CAT_KEYWORD))||((forceHide)))
toggleFilters('hide');else
toggleFilters('show');this.filterActive=true;}},clearFilter:function(label)
{if((label)&&(this.activeFilters[label]))
{this.activeFilters[label]=false;delete this.activeFilters[label];}},clearFilters:function(label)
{if(this.activeFilters.length>0)
return false;var results=this.getResultGroup(ResultGroup.ALL);if((label)&&(this.activeFilters[label]))
{this.activeFilters[label]=false;delete this.activeFilters[label];results=this.applyFilters(results);}
else if(label==null)
{for(var index in this.activeFilters)
{var filter=this.activeFilters[index];filter.resetInputs(1);delete this.activeFilters[index];}}
else
return false;this.setResultGroup(ResultGroup.FILTER,results);this.pg.resetPages(results.length);this.setParameter(0,'page');var parameters={"filters":this.serializeFilters(this),"page":this.getParameter('page')};window.bookmarkPage(parameters);this.getResults({page:this.getParameter("page").serialize()});return true;},applyFilters:function(_results)
{for(var f in this.activeFilters)
{var filter=this.activeFilters[f];_results=filter.filterResults(_results);}
this._setParameter(this.serializeFilters());return _results;},_setParameter:function(parameter)
{this.parameters[parameter.type]=parameter;},setParameter:function(data,type)
{this._setParameter(new Parameter(type,null,data));},getParameter:function(type)
{if(this.parameters[type]!=null)
return this.parameters[type];switch(type)
{case"page":return new Parameter("page",null,0);break;case"sort":return new Parameter("sort",null,{label:"relevance",dir:"ASC"});break;case"filters":return new Parameter("filters",null,[]);break;}},setParameters:function(params)
{var date=new Date();var currentTime=date.getTime();if(this.stamp==null)
this.stamp=0;if(currentTime-this.stamp<1000)
return false;try
{if(!params)
this.getResults({page:0});var sort=params.sort.serialize();var page=params.page.serialize();var currentPage=this.getParameter("page").serialize();var currentSort=this.getParameter("sort").serialize();if((params.page.diff(this.getParameter("page")))||(params.sort.diff(this.getParameter("sort")))||(params.filters.diff(this.getParameter("filters"))))
{this.stamp=currentTime;this.getResults({sort:params.sort.serialize(),page:params.page.serialize(),filters:params.filters.serialize(),noreverse:true,wash:true});}}
catch(e)
{}},serializeFilters:function(filter)
{var dset=[];for(var i in this.activeFilters)
{if(this.activeFilters[i]!=null)
{try
{var value=this.activeFilters[i].serialize();if((value!=null)&&(value))
dset[this.activeFilters[i].field]=value;}
catch(e)
{}}}
if((filter!=null))
{if(filter.serialize!=null)
{try
{var value=filter.serialize();if((value!=null)&&(value))
dset[filter.field]=value;}
catch(e)
{}}}
return new Parameter("filters",null,dset);},getResults:function(params,isInit)
{if(this.errorbox!=null)
this.destroyError();try{this.unsetResultGroup(ResultGroup.PG);}
catch(e){}
if(params.filters!=null)
{for(var fi in this.filterSet)
{var filterObject=this.filterSet[fi];if(params.filters[filterObject.field])
{filterObject.updateFilter(params.filters[filterObject.field]);this.activeFilters[filterObject.getLabel()]=filterObject;}
else if(this.activeFilters[filterObject.getLabel()])
{this.clearFilters(filterObject.getLabel());filterObject.resetInputs(1);}}
var currentResults=this.applyFilters(this.getResultGroup(ResultGroup.ALL));this.pg.resetPages(currentResults.length);this.setResultGroup(ResultGroup.FILTER,currentResults);}
else if(params.filter)
{if(!params.sort)
params.sort=this.getParameter("sort").serialize();if(params.page==null)
{var page=this.pg.selectPage(0);this.setParameter(page,'page');params.page=this.getParameter("page").serialize();window.setParameter(this.getParameter("page"));}
this.activeFilters[params.filter.getLabel()]=params.filter;var currentResults=this.applyFilters(this.getResultGroup(ResultGroup.ALL));this.pg.resetPages(currentResults.length);this.setResultGroup(ResultGroup.FILTER,currentResults);}
else
{var currentResults=this.getResultGroup(ResultGroup.FILTER);}
if((params.sort))
{this.setParameter(params.sort,'sort');var sortObj=this.sortMgr.getSort(params.sort.label);if(sortObj)
{if(sortObj.isHidden()&&(sortObj.node_id=="distance"))
{this.nudged=true;sortObj.display();}
if(sortObj.isHidden())
{this.setParameter(this.pg.selectPage(0).page,'page');sortObj.select((params.sort.dir!=null?params.sort.dir:"ASC"));}
else
{sortObj.select((params.sort.dir!=null?params.sort.dir:"ASC"));}
sortObj.results=this.getResultGroup(ResultGroup.FILTER);this.sortResults(sortObj);}}
if(params.page!=null)
{this.setParameter(this.pg.selectPage(params.page),"page");}
if(this.map)
for(index in this.map)
{var map=this.map[index];map.resetMarkers();map.initBounds(map.centerPt);}
this.setResultGroup(ResultGroup.PG,this.pg.getPageResults(this.getResultGroup(ResultGroup.FILTER),this.getParameter('page').serialize()));if(this.getResultGroup(ResultGroup.PG).length<1)
{this.displayError();this.pg.hide();}
else
{this.pg.show();}
var resultGroup=this.getResultGroup(ResultGroup.PG);if(resultGroup!=null)
for(var index in resultGroup)
{this.displayResult(resultGroup[index]);}
this.clearXFacets();if(this.getMap())
this.getMap().showAllPoints(isInit);},clearXFacets:function(){this.chain={};},getXFacet:function(type)
{if(this.chain[type])
return this.chain[type];return false;},setXFacet:function(type,facet)
{this.chain[type]=facet;},getResultGroup:function(label)
{return this.resultGroups[label];},setResultGroup:function(label,resultList)
{this.resultGroups[label]=resultList;return this.resultGroups[label];},unsetResultGroup:function(label)
{while(this.resultGroups[label].length>0)
{var result=this.resultGroups[label].pop();result.remove();}},setCurrentPage:function(page)
{this.currentPage=page;},addModules:function(modules)
{for(var i in modules)
this.modules[i]=modules[i];},getModule:function(id)
{if((this.modules!=undefined)&&(this.modules[id]!=undefined))
{var result=this.modules[id];}
else
{result={tabs:{"general":"more info","photos":"photos"},tpl:{body:false},misc:{className:false},structure:{className:'entry_content',children:{'title':{'facet':true},'facets':{'className':'facets','facets':{0:FACET_DISTANCE,1:FACET_MAP,2:FACET_ADDRESS,3:FACET_PHONE}},'photo':{'className':"facet_photo",'facets':{0:FACET_PHOTO}},'main':{'className':'entry_main','facets':{0:FACET_DESCRIPTION,1:FACET_CATEGORIES,2:FACET_FACEBOOK}}}}};}
result.structure.alias="entryContent";var scaffold={alias:'resultTemplate',className:"entry"+(result.misc.className?" "+result.misc.className:'')}
scaffold.children={};scaffold.children[FACET_INDEX]={facet:true};scaffold.children['content']=result.structure;result.scaffold=scaffold;return result;},setTemplate:function(template)
{this.template=template;},getTemplate:function(categoryID)
{if(this.template[categoryID]!=null)
return this.template[categoryID];else
return this.template['main'];},getLast:function(){return(this.last!=null?this.last:false)},displayResult:function(result)
{if(result.display())
{if(result.facets.location!=null&&result.facets.location)
if(this.getMap())
this.getMap().setPoint(result);}},sortResults:function(sort)
{if(sort!=null)
{sort.coordinates=this.coordinates;for(index in this.map)
this.map[index].displayCenter();return this.sortMgr.sortResults(sort);}},setCenterCoor:function(data,isCustom)
{this.coordinates=data;this.coordinates.isCustom=isCustom;if(this.map!=undefined)
{for(index in this.map)
{this.map[index].setCenter(data.lat,data.lng);this.map[index].hasCenter=true;}}},setResultCoor:function(id,point)
{if(this.results[id]!=undefined)
this.results[id].facets.location={lat:point.lat(),lng:point.lng()};},addReferencePoint:function(mapType)
{this.getMap().addReferencePoint();},getSortMethod:function(method)
{return this.sortStg[method];},selectPoint:function(result)
{this.getMap().selectPoint(result.showieIndex);},selectMap:function(label)
{var mapHdlr=this.getMap();if(mapHdlr)
{switch(label)
{case"small":$("#miniMapWrapper").show();var map=document.getElementById("_mapBase");$(map).appendTo("#miniMap");$("#adblock").hide();$("#map").hide();$("#miniMap").focus();break;case"big":default:$("#map").show();$("#adblock").show();var map=document.getElementById("_mapBase");$(map).appendTo("#mapContent");$("#miniMapWrapper").hide();break;}
mapHdlr.reformat(label);}}}
function MiniResultSet(params)
{this._construct(params);}
MiniResultSet.prototype=new resultSet(null);MiniResultSet.prototype._destruct=function()
{while(this.results.length>0)
{var result=this.results.pop();result.remove();}}
MiniResultSet.prototype.loadResults=function(data)
{if((data.error))
{this.exception=new Exception(data.error);this.exception.display(this.container,true);this.portal.dateSet.innerHTML="";}
else if(data.entries)
{this.addCategories(data.categories);for(var index in data.entries)
{if(data.entries[index].facets!=undefined)
{var r=new result(data.entries[index],this);r.prev=last;this.results.push(r);this.entryContainer=this.container;var last=r;}}
this.setResultGroup(ResultGroup.FILTER,this.results);this.sortMgr=new ResultSortMgr({resultSet:this,hidden:true,container:null});var dateSort=new ResultSortItem
({method:"date",type:FACET_NUM_SPAN,dir:"ASC",label:"date",facet:"date",node_id:"date",hidden:true,noreverse:true},this);this.sortMgr.addSort(dateSort);this.sortMgr.setCurrent(dateSort);dateSort.results=this.results;var results=this.sortMgr.sortResults(dateSort);for(var i in results)
{results[i].prev=(results[i-1]?results[i-1]:false);results[i].displayTeaser();}}
else
{this.portal.dateSet.innerHTML="";}}
function Facet(name,result)
{if(result)
this._construct(name,result);}
Facet.prototype={_construct:function(name,result)
{if(result)
{this.name=name;this.result=result;this.value=(typeof this.result.facets[name]!="undefined"?this.result.facets[name]:'');objects.push(this);}},value:null,_destruct:function()
{this.close();for(var i in this)
this[i]=null;killself(this);},setNode:function(node)
{this.node=node;},close:function()
{if(this.node!=null&&this.node.parentNode!=null)
this.node.parentNode.removeChild(this.node);},getFormatted:function()
{if(!this.value)
{return'';}
else if(this.value.replace!=null)
return this.value;else if(this.value.toPrecision!=null)
return this.value;else if(this.value.formatted!=undefined)
return this.value.formatted;},render:function(node)
{if(node)
$(node).html(this.getFormatted());else
{var node=document.createElement("span");node.className="facet_"+this.name;node.innerHTML=this.getFormatted();return node;}
return node;},getName:function()
{return this.name;},getValue:function()
{if(this.value!=null)
return this.value;},getNode:function()
{return this.node;},setValue:function(value)
{this.value=value;this.result.facets[this.name]=value;}}
function FacetPrice(result)
{this._construct('price',result);}
FacetPrice.prototype=new Facet(null);FacetPrice.prototype.render=function(node)
{var value=this.getValue();if(!value)
return false;if(!node)
{var node=document.createElement("div");node.className="facet_price";this.setNode(node);}
if(value.hi>value.lo)
{$(node).html("<span>from</span><h5 class=\"price_span\">"+value.lo.formatPrice()+"&nbsp;-&nbsp;"+value.hi.formatPrice()+"</h5>");}
else
{$(node).addClass("price_single");$(node).html("<span>from</span><h5 class=\"price_single\">"+value.lo.formatPrice()+"</h5>");}
return node;}
function FacetCategorySet(result)
{this._construct('categorySet',result);}
FacetCategorySet.prototype=new Facet(null);FacetCategorySet.prototype.render=function(node,amt)
{if(!node)
{var node=document.createElement("div");node.className="facet_category_container";var label=document.createElement("label");var area=document.createElement('span');label.appendChild(document.createTextNode("category:"));area.className="facet_category";node.appendChild(label);node.appendChild(area);}
else
{var area=node;}
var amt=(amt?amt:4);var j=0;if(this.getValue())
{var values=this.getValue();for(var i in values)
{if((j>=amt))
break;j++;var category=this.result.resultSet.getCategory(values[i]);if(category==null)
continue;var link=new Link({href:"#",text:category.name,fnc:function()
{new SearchLink(this.urlParams).open();trackEvent(["search_result","category"]);}});link.urlParams={locationID:this.result.resultSet.locationID,locationName:this.result.resultSet.locationName,categoryID:(category.id?category.id:this.result.resultSet.categoryID),categoryName:category.name};link.title=category.name;var delimeter=document.createTextNode(", ");area.appendChild(link);area.appendChild(delimeter);}
if(delimeter)
delimeter.parentNode.removeChild(delimeter);}
return node;}
function FacetDescription(result)
{this.strlen=-1;this._construct('description',result);}
FacetDescription.prototype=new Facet(null);FacetDescription.prototype.truncate=function(amt)
{this.strlen=amt;}
FacetDescription.prototype.strlen=-1;FacetDescription.prototype.render=function(node)
{if(node)
node.html((this.strlen!=-1?this.getValue().substring(0,this.strlen):this.getValue())+"&nbsp;");else
{node=document.createElement("p");node.className="facet_description";if(this.getValue())
node.innerHTML=(this.strlen!=-1?this.getValue().toString().substring(0,this.strlen):this.getValue().toString())+"&nbsp;";}
var linkOutside=document.createElement("a");var sourceURL=this.result.displayFacet("source_url");var displayURL=this.result.displayFacet("display_url");if(sourceURL!=undefined)
{linkOutside.href=sourceURL;$(linkOutside).text("from "+(displayURL?displayURL:sourceURL));linkOutside.target="_blank";linkOutside.result=this.result;$(linkOutside).click(function(){trackOffsite(this.result);trackEvent(["search_result","source"]);});}
$(node).append(linkOutside);return node;}
function FacetTitle(result,header)
{this.header=(header?header:false);this._construct('title',result);}
FacetTitle.prototype=new Facet(null);FacetTitle.prototype.render=function(node)
{if(!node)
{var node=document.createElement((this.header?this.header:"h2"));node.className="facet_title";}
if(!this.getValue())
return node;var sourceURL=this.result.displayFacet("source_url");var title=this.getValue();var link=(sourceURL!=undefined?document.createElement("a"):document.createElement("span"));link.href=sourceURL;link.target="_blank";link.result=this.result;$(link).click(function()
{trackOffsite(this.result);trackEvent(["search_result","title"]);});$(link).html(title.htmlentities());$(link).attr("title",this.getValue());$(node).append(link);return node;}
function FacetPhoto(result)
{this._construct('photo',result);}
FacetPhoto.prototype=new Facet(null);FacetPhoto.prototype.getGoogleImage=function()
{if(!this.result.facets.title)
return false;var location=this.result.facets.location;var stateCode=(location!=null&&location.state!=null?location.state:"");var title=this.result.facets.title.urlEncode();var data={"action":"getThumbnail","stateCode":stateCode,"text":title};var sizeParams=TB_SIZE.result.split("x");data.thumbnail=IMG_SERVER+"getGoogleImage_"+sizeParams[0]+"x"+sizeParams[1]+"/"+data.text+"/"+data.stateCode;return data.thumbnail;}
FacetPhoto.prototype.setlbl=function(data)
{var div=document.createElement("div");div.className="facet_photo_source";$(this.getNode()).prepend(div);}
FacetPhoto.prototype.render=function(node)
{if(node==null)
{node=document.createElement("div");node.className="facet_photo";}
this.setNode(node);if(!this.getValue()&&(!this.result.module.misc.services))
{return node;}
if(this.result.tabs[TABS.PHOTOS])
{node.result=this.result;node.onclick=function()
{this.result.opentab(TABS.PHOTOS);}
$(node).css("cursor",(navigator.isIE()?"hand":"pointer"));node.title="Click to View More Photos!";}
var sizeParams=TB_SIZE.result.split("x");var params={loaderStyle:"loader_thumbnail",width:sizeParams[0],height:sizeParams[1]}
if(!this.getValue())
{this.setValue(this.getGoogleImage());this.google=true;params.isBG=false;}
else
{}
if(this.google)
{params.callback={object:this,method:"setlbl"}}
this.imgPreloader=ImagePreloader((this.google?this.getValue():compileThumbnail(this.getValue(),'result')),this.getNode(),params);return node;}
function FacetRating(result,header)
{this.header=(header?header:false);this._construct('rating',result);}
FacetRating.prototype=new Facet(null);FacetRating.prototype.render=function(node)
{if(!node)
{var node=document.createElement("div");node.className="facet_rating";}
var set=document.createElement("div");for(var i=5;i>0;i--)
{var star=document.createElement("div");$(star).addClass("star");if(this.getValue()>=i)
$(star).addClass("star_on");else
$(star).addClass("star_off");set.appendChild(star);}
var string=document.createElement("div");string.className="facet_rating_string";string.innerHTML="avg guest rating: <strong>"+parseInt(this.getValue())+".0</strong>";$(node).append(set);$(node).append(getClear());$(node).append(string);return node;}
function FacetDate(result)
{this._construct('date',result);this.dateLo=new Date(this.value.lo*1000);this.dateLo.startDate=new Date()
this.dateHi=new Date(this.value.hi*1000);this.dateHi.startDate=new Date();}
FacetDate.prototype=new Facet;FacetDate.prototype.isLike=function(facet)
{var sort=this.result.resultSet.sortMgr.getCurrent();if((sort.node_id=="date"||sort.node_id=="relevance"))
return(this.dateLo.sameDay(facet.dateLo)?true:false)
else
{if((this.dateHi.sameDay(facet.dateHi))&&(this.dateLo.sameDay(facet.dateLo)))
return true;else
return false;}}
FacetDate.prototype.getFormatted=function(format)
{var data=this.getValue();var DAY=86400;var dateLo=this.dateLo;var dateHi=this.dateHi;if(data.hi>=(data.lo+86400))
{var sort=this.result.resultSet.sortMgr.getCurrent();data.text=(sort.node_id=="date"||sort.node_id=="relevance")?dateLo.format(format):dateLo.format(format)+"&nbsp;-&nbsp;"+dateHi.format(format);}
else
data.text=dateLo.format(format);this.value.label=data.text;this.value.weekday=data.weekend;return this.value.label;}
FacetDate.prototype.renderBar=function(format)
{if((!this.result.resultSet.getXFacet("date"))||(!this.isLike(this.result.resultSet.getXFacet("date"))))
{var node=document.createElement("h5");$(node).html(this.getFormatted(format));node.className="entry-date";if(this.result.resultTemplate)
{try
{this.result.resultSet.getContainer().insertBefore(node,this.result.resultTemplate);}
catch(e)
{alert(e.message);}}
else
{this.result.resultSet.getContainer().appendChild(node);}
this.setNode(node);}
this.result.resultSet.setXFacet('date',this);}
FacetDate.prototype.render=function(node,format)
{if(!node)
{var node=document.createElement("div");node.className="facet_date";}
var data=this.getValue();var dateLo=this.dateLo;var dateHi=this.dateHi;if(data.hi>=(data.lo+86400))
data.oldway=dateLo.format('oldway')+" - "+dateHi.format('oldway');else
data.oldway=dateLo.format('oldway');var label=document.createElement("h5");label.innerHTML=data.oldway.toUpperCase();$(node).append(label);$(node).append(this.renderTime());this.renderBar("%D, %m %d");return node;}
FacetDate.prototype.renderOldWay=function(node)
{return node;}
FacetDate.prototype.renderTime=function()
{var node=document.createElement("span");node.innerHTML=this.dateLo.getWeekday();return node;}
function PsudoFacet(name,result)
{}
PsudoFacet.prototype=new Facet(null);PsudoFacet.prototype._construct=function(name,result)
{if(result)
{this.result=result;objects.push(this);}}
function FacetFacebook(result)
{this._construct('facebook',result);}
FacetFacebook.prototype=new PsudoFacet(null);FacetFacebook.prototype.render=function()
{if(!FACEBOOK_ON)
return document.createElement("div");var facebookIcon=document.createElement("span");var facebookLink=document.createElement("a");facebookLink.appendChild(document.createTextNode('share on facebook'));facebookLink.result=this.result;facebookLink.onclick=function()
{postToNewsFeed(this.result);}
facebookIcon.innerHTML="f";var facebookContainer=document.createElement("div");facebookContainer.appendChild(facebookIcon);facebookContainer.appendChild(facebookLink);facebookContainer.className="facebook";return facebookContainer;}
function FacetIndex(result)
{this._construct('index',result);}
FacetIndex.prototype=new PsudoFacet(null);FacetIndex.prototype.render=function()
{var node=document.createElement("div");node.className="entry_index";$(node).addClass("pin_normal");node.innerHTML=(this.result.showieIndex);return node;}
function FacetDistance(result)
{this._construct('distance',result);}
FacetDistance.prototype=new PsudoFacet(null);FacetDistance.prototype.render=function(node)
{var location=this.result.facets.location;var resultSet=this.result.resultSet;if((location!=null)&&(location.lat!=null)&&(((resultSet.locationID!=LOC_US)&&(resultSet.getLocationType()!="STATE"))||(resultSet.nudged==false))&&(resultSet.locationID!=null)&&(location.lat!=0&&location.lng!=0))
{var d=getDistance(location,resultSet.coordinates);if(d>=0)
{var node=document.createElement('div');node.className="entry_distance";node.innerHTML=(Math.round(d*10)/10)+" mi";return node;}}
else
return false;}
function FacetMap(result)
{this._construct('map',result);}
FacetMap.prototype=new PsudoFacet(null);FacetMap.prototype.render=function(node)
{var location=this.result.facets.location;if(location!=null&&(location.lat!=0&&location.lng!=0&&this.result.resultSet.useMap))
{var node=new Link({fnc:function()
{trackEvent(["search_result","map"]);this.result.resultSet.selectPoint(this.result);},text:"map"});node.className="entry_map";node.result=this.result;$(node).hover(function()
{$(this).addClass("lite");},function()
{$(this).removeClass("lite");});return node;}
else if(node!=null)
{node.parentNode.removeChild(node);}
else
return false;}
function ResultSortItem(params,resultMgr)
{this.forced=false;this.resultHandler=resultMgr;this.hidden=false;for(var i in params)
this[i]=params[i];this.sortContainer=null;this.default_dir=this.dir.toString();this.parameters={"sort":new Parameter("sort",null,{label:this.node_id,dir:this.dir})};}
ResultSortItem.prototype.reset=function()
{if(!this.isHidden())
{$(this.dirbox).removeClass(this.dir);$(this.link).removeClass("sel");}
this.dir=this.default_dir.toString();}
ResultSortItem.prototype.hide=function()
{if(this.sortContainer!=null)
{this.mgr.container.removeChild(this.sortContainer);this.sortContainer=null;this.link=null;this.hidden=true;}}
ResultSortItem.prototype.display=function()
{var sortContainer=document.createElement("li");sortContainer.appendChild(this.createLink());sortContainer.appendChild(this.dirbox);if(navigator.isBrowser(browser.IE))
{var sortRightBorder=document.createElement("div");sortRightBorder.className="sort_ie_right";$(sortRightBorder).appendTo(this.mgr.container);}
$(sortContainer).appendTo(this.mgr.container);this.sortContainer=sortContainer;this.hidden=false;return sortContainer;}
ResultSortItem.prototype.invert=function()
{var dir=(this.dir=="ASC"?"DESC":"ASC");this.update(dir);}
ResultSortItem.prototype.select=function(dir)
{this.update(dir);$(this.dirbox).addClass(this.dir);}
ResultSortItem.prototype.updateDirection=function()
{var currentObj=this.mgr.getCurrent();$(this.link).addClass("sel");if(currentObj==null)
{this.mgr.setCurrent(this);}
else if((currentObj===this))
{this.invert();}
else if(currentObj!==this)
{if(currentObj!=null)
currentObj.reset();this.mgr.setCurrent(this);}}
ResultSortItem.prototype.update=function(dir)
{var currentObj=this.mgr.getCurrent();if(currentObj!==this)
{if(currentObj!=null)
currentObj.reset();this.mgr.setCurrent(this);}
if(!dir)
dir=this.dir;if(!this.isHidden())
{$(this.dirbox).removeClass(this.dir);$(this.dirbox).addClass(dir);}
this.dir=dir;this.parameters.sort=new Parameter("sort",null,{label:this.node_id,dir:this.dir});}
ResultSortItem.prototype.getParameters=function(format)
{switch(format)
{case 2:var params={};for(var i in this.parameters)
params[i]=this.parameters[i].serialize();params.raw=this.parameters.sort;return params;break;case 1:default:return this.parameters;}}
ResultSortItem.prototype.isHidden=function()
{if((this.hidden!=null)&&(this.hidden))
return true;else
return false;}
ResultSortItem.prototype.createLink=function()
{var sortLink=document.createElement("a");sortLink.dirbox=document.createElement("a");sortLink.dirbox.href="#sort="+this.node_id+":"+this.dir;sortLink.href="#sort="+this.node_id+":"+this.dir;sortLink.dirbox.className="dir";sortLink.dirbox.innerHTML="";$(sortLink).text(this.label.toLowerCase());sortLink.object=this;sortLink.dirbox.object=this;this.dirbox=sortLink.dirbox;this.dirbox.link=sortLink;sortLink.getHandler=function()
{return this.object;}
sortLink.select=function(dir)
{this.object.select(dir);}
$(sortLink).click(function()
{this.object.updateDirection();var param=window.compileLink(this.object.getParameters(1),this);this.hash=param.hash;this.href=param.hash;trackEvent(["sort_box",$(this).val()]);this.object.resultHandler.getResults(this.object.getParameters(2));})
$(this.dirbox).click(function()
{this.link.click();})
this.link=sortLink;return this.link;}
function ResultSortMgr(params)
{this.resultSet=params.resultSet;if(params.container!=null)
{this.container=params.container;this.container.innerHTML='';}
$("#sort").hide();}
ResultSortMgr.prototype={data:[],container:null,currentSort:null,removeSort:function(obj)
{if(obj==null)
return false;if((this.data[obj.node_id])&&(!obj.isHidden()))
{obj.hide();if(this.getCurrent()==obj)
this.currentSort=null;this.data[obj.node_id]=null;}},addSort:function(obj)
{obj.mgr=this;if(!obj.isHidden())
obj.display();if(obj.isDefault)
{if(this.getCurrent()==null)
{if(obj.forced)
{obj.select(obj.dir);}
else
obj.update();this.setCurrent(obj);}}
this.data[obj.node_id]=obj;},close:function()
{for(var i in this.data)
this.data[i].hide();$("sort").html('');},_destruct:function()
{this.close();for(var i in this.data)
this.removeSort(this.data[i]);for(var i in this)
this[i]=null;},setCurrent:function(obj)
{this.currentSort=obj;},hide:function()
{$("#sort").hide();},show:function()
{$("#sort").show();},getCurrent:function()
{if(this.currentSort!=null)
return this.currentSort;else
return null;},getSort:function(node_id)
{if(this.data[node_id]!=null)
{var obj=this.data[node_id];return obj;}
else
{return null;}},sortResults:function(sort)
{myCor=sort.coordinates;resultset=sort.results;resultset.sort(function(a,b)
{switch(sort.method)
{case"relevance":case"Relevance":var a=parseInt(a.DEFAULT_SORT);var b=parseInt(b.DEFAULT_SORT);break;case"keywordRelevance":var a=parseInt(a.relevance);var b=parseInt(b.relevance);break;case"distance":if((a.facets.location==null)&&(b.facets.location==null))
return 0;else if(b.facets.location==null)
return-1;else if(a.facets.location==null)
return 1;else if((a.facets.location.lat==null)||(a.facets.location.lat==0.0))
return 1;else if((b.facets.location.lat==null)||(b.facets.location.lat==0.0))
return-1;d1=getDistance(a.facets.location,myCor);d2=getDistance(b.facets.location,myCor);a=d1;b=d2;break;default:if((a.facets[sort.facet]==null)&&(b.facets[sort.facet]==null))
return 0;else if(b.facets[sort.facet]==null)
return-1;else if(a.facets[sort.facet]==null)
return 1;var aData=a.facets[sort.facet];var bData=b.facets[sort.facet];if(aData.type==null)
aData.type=FACET_STRING;switch(aData.type)
{case FACET_PRICE:case FACET_NUM_SPAN:if((sort.dir=="DESC")&&(sort.node_id!="date"))
{if((!aData.hi)&&(bData.hi))return 0;if(!aData.hi)return 1;if(!bData.hi)return-1;a=parseInt(aData.hi);b=parseInt(bData.hi);a_2=parseInt(aData.lo);b_2=parseInt(bData.lo);}
else
{if((!aData.lo)&&(bData.lo))return 0;if(!aData.lo)return 1;if(!bData.lo)return-1;a=parseInt(aData.lo);b=parseInt(bData.lo);a_2=parseInt(aData.hi);b_2=parseInt(bData.hi);}
if(sort.dir=="DESC")
{if(sort.node_id=="date")
return((a>b)?-1:((a<b)?1:((a_2>b_2)?1:((a_2<b_2)?-1:0))));else
return((a>b)?-1:((a<b)?1:((a_2>b_2)?-1:((a_2<b_2)?1:0))));}
else
return((a>b)?1:((a<b)?-1:((a_2>b_2)?1:((a_2<b_2)?-1:0))));break;case FACET_STRING:if(aData.replace!=null)
a=aData.toLowerCase();if(aData.replace!=null)
b=bData.toLowerCase();break;case FACET_NUMBER:a=aData.value;b=bData.value;break;default:a=aData;b=bData;if(aData.replace!=null)
a=a.toLowerCase();if(aData.replace!=null)
b=b.toLowerCase();break;}}
try
{if(sort.dir=="DESC")
return((a>b)?-1:((a<b)?1:0));else
return((a<b)?-1:((a>b)?1:0));}
catch(e)
{return 0;}});return resultset;}}
var squishies=new Object;squishies.PHONE={label:"Phone",key:"phone"};squishies.WEBSITE={label:"Website",key:"website"};var facetObjects={};facetObjects[FACET_PHOTO]="FacetPhoto";facetObjects[FACET_TITLE]="FacetTitle";facetObjects[FACET_DESCRIPTION]="FacetDescription";facetObjects[FACET_CATEGORIES]="FacetCategorySet";facetObjects[FACET_RATING]="FacetRating";facetObjects[FACET_PRICE]="FacetPrice";facetObjects[FACET_DATE]="FacetDate";facetObjects[FACET_INDEX]="FacetIndex";facetObjects[FACET_MAP]="FacetMap";facetObjects[FACET_FACEBOOK]="FacetFacebook";facetObjects[FACET_DISTANCE]="FacetDistance";var facetAlias={};facetAlias[FACET_PHOTO]="photo";facetAlias[FACET_TITLE]="title";facetAlias[FACET_DESCRIPTION]="description";facetAlias[FACET_CATEGORIES]="categorySet";facetAlias[FACET_RATING]="rating";facetAlias[FACET_PRICE]="price";facetAlias[FACET_DATE]="date";facetAlias[FACET_INDEX]="index";facetAlias[FACET_MAP]="map";facetAlias[FACET_FACEBOOK]="facebook";facetAlias[FACET_CATEGORIES]="categorySet";facetAlias[FACET_ADDRESS]="address";facetAlias[FACET_PHONE]="phone";function result(resultJson,resultSet)
{this.tpl=[];this.facetObjects=new List();for(index in resultJson)
this[index]=resultJson[index];objects.push(this);this.resultTabs=null;if(resultSet)
this.setResultSet(resultSet);}
result.prototype={getDistance:function()
{if(this.facets.location!=null)
return getDistance(this.facets.location,this.resultSet.coordinates);else
return 0;},addFacetObject:function(object)
{this.facetObjects.add(object.getName(),object);},fetchFacet:function(id)
{if(this.getFacetObject(id))
{return this.getFacetObject(id);}
else
{if(facetObjects[id])
var node=eval("new "+facetObjects[id]+"(this);");else
var node=new Facet(facetAlias[id],this);this.addFacetObject(node);return node;}},getFacetObject:function(index)
{if(this.facetObjects.get(index)!=null)
return this.facetObjects.get(index);else
return false;},setResultSet:function(set)
{this.resultSet=set;},getKeywordRelevance:function(word)
{matchCnt=0;for(var i in this.facets)
{if((this.facets[i]!=null)&&(this.facets[i].replace))
{var matches=this.facets[i].match(eval("/"+word+"/gi"));if(matches!=null)
{if(i=="title")
matchCnt=matchCnt+matches.length+2;else
matchCnt=matchCnt+matches.length;}}}
this.relevance=matchCnt;return matchCnt;},getFacet:function(name)
{if(this.facets[name])
return new Facet(name,this);},displayTeaser:function(node)
{var container=(node!=null?node:this.resultSet.getContainer());this.resultTemplate=document.createElement("div");this.resultTemplate.className="entry-teaser";var content=this.resultTemplate;container.appendChild(content);container.appendChild(getClear());var titleObject=new FacetTitle(this,'h4');content.appendChild(titleObject.render());var facets=document.createElement('p');var address=this.getFacet('address');if(this.facets.date!=null)
{var date=new FacetDate(this);this.addFacetObject(date);facets.appendChild(date.renderTime());try
{if(address)
{var delimeter=document.createElement("span");delimeter.innerHTML="&nbsp;@&nbsp;"
facets.appendChild(delimeter);facets.appendChild(address.render());}}
catch(e)
{}
date.renderBar();this.resultSet.setXFacet('date',this.getFacetObject('date'));}
else
{facets.appendChild(address.render());}
content.appendChild(facets);var categorySet=new FacetCategorySet(this);content.appendChild(categorySet.render(null,1));var sourceObj=new FacetDescription(this);sourceObj.truncate(0);content.appendChild(sourceObj.render());return this.resultTemplate;},renderNode:function(entry)
{var node=document.createElement((entry.tag!=null?entry.tag:'div'));node.className=(entry.className?entry.className:'');if(entry.children)
{for(var i in entry.children)
{if(entry.children[i].facet)
{var facet=this.fetchFacet(i);var _node=facet.render();(_node?node.appendChild(_node):'');}
else
node.appendChild(this.renderNode(entry.children[i]));}}
if(entry.facets)
{for(var f in entry.facets)
{var facet=this.fetchFacet(entry.facets[f]);var _node=facet.render();(_node?node.appendChild(_node):'');}}
if(entry.alias)
this[entry.alias]=node;return node;},displayObject:function()
{this.module=this.resultSet.getModule((this.facets.categoryID?this.facets.categoryID:false));this.resultTemplate=this.renderNode(this.module.scaffold);this.resultTemplate.result=this;this.resultTemplate.id=this.id;var photo=this.fetchFacet('photo');if((!this.facets.description)&&(!photo.getValue()))
$(this.entryContent).addClass("noilism");else if(!photo.getValue())
$(this.entryContent).addClass("nophoto");else if(!this.facets.description)
$(this.entryContent).addClass("nocontent");if(this.module.misc.className)
$(this.resultTemplate).addClass(this.module.misc.className);this.resultTabs=new ResultTabMgr(this);this.resultTabs.displayLinks();this.resultSet.getContainer().appendChild(this.resultTemplate);},display:function()
{this.displayObject();return true;if((this.facets.location!=null)&&(this.facets.location.lat!=null))
{}
else
{this.facets.location=null;$(this.resultTemplate).find(".entry_map").hide();$(this.resultTemplate).find(".entry_street").hide();$(this.resultTemplate).find(".entry_index").addClass("pin_none");}},opentab:function(label)
{var tab=this.resultTabs.getTab(label);if(tab!=null)
tab.open();},remove:function()
{if(this.module!=null)
{if(this.resultSet.getMap())
this.resultSet.getMap().rmDot(this);this.module=null;this.facetObjects.reset();while(this.facetObjects.valid())
{var cur=this.facetObjects.getCurrent();if(cur.name!="photo")
cur.close();this.facetObjects.next();}
$(this.resultTemplate).remove();if(this.resultTabs!=null)
this.resultTabs._destruct();this.resultTemplate=null;return true;}
else
{return false;}},displayFacet:function(facetID)
{var value=this.facets[facetID];try
{if(value==null)
return"";if((value!=null)&&((value.replace)||(value.toPrecision)))
{return value;}
else if(value.formatted!=undefined)
{return value.formatted;}
else
return"";}
catch(e)
{return"";}},displayMapTab:function(type)
{this.module=this.resultSet.getModule((this.facets.categoryID?this.facets.categoryID:false));var container=document.createElement("div");container.className="infowin";var info=document.createElement("div");info.className="info";var header=document.createElement("h3");header.innerHTML=this.facets.title;var dateFacet=this.getFacetObject("date");var address=document.createElement("div");address.className="address";address.innerHTML=(this.facets.location.streetAddress?this.facets.location.streetAddress+'<br />':'')+
(this.facets.location.city?this.facets.location.city+', ':'')+
(this.facets.location.state?this.facets.location.state:'')+"<br />"+"<a href=\""+(this.facets.source_url)+"\" class=\"website\" target=\"_blank\">"+(this.facets.display_url)+"</a>";var anchor1=document.createElement("a");var anchor2=document.createElement("a");anchor1.result=this;preserveParameters(anchor1);anchor1.onclick=function()
{var result=this.result;window.open('http://google.com/maps?source=uds&daddr='+(escape(result.facets.address+' ('+result.facets.title+') @'+result.facets.location.lat+','+result.facets.location.lng))+'&iwstate1=dir%3Bto',"_new");}
anchor1.innerHTML="to here";preserveParameters(anchor1);anchor2.result=this;anchor2.onclick=function()
{var result=this.result;window.open('http://google.com/maps?source=uds&daddr='+(escape(result.facets.address+' ('+result.facets.title+') @'+result.facets.location.lat+','+result.facets.location.lng))+'&iwstate1=dir%3Afrom',"_new");}
anchor2.innerHTML="from here";var directions=document.createElement("div");directions.appendChild(document.createTextNode("get directions:"));directions.appendChild(anchor1);directions.appendChild(document.createTextNode("-"));directions.appendChild(anchor2);directions.className="directions";tabholder=null;switch(type)
{case"big":var tabholder=document.createElement("div");tabholder.className="links";var first=true;for(var id in this.resultTabs.tabs)
{if(this.resultTabs.tabs[id]==null)
continue;var tabName=this.module.tabs[id];var tab=document.createElement("a");tab.code=id;tab.result=this;tab.innerHTML=tabName;tab.onclick=function()
{this.result.opentab(this.code);this.result.resultSet.getMap().changeSize();$(window).scrollTop($(this.result.resultTemplate).offset().top);}
if(!first)
{tabholder.appendChild(document.createTextNode("-"));}
tabholder.appendChild(tab);first=false;}
case"big_dot":if(this.facets.photo)
{$(container).addClass("restrict");var imgholder=document.createElement('div');imgholder.className='pict';imgholder.style.width="128px";imgholder.style.height="128px";var photo=this.getFacetObject('photo');if(photo)
{photo.render(imgholder);container.appendChild(imgholder);}}
$(container).addClass("big");container.appendChild(info);info.appendChild(header);info.appendChild(address);if(tabholder!=null)
info.appendChild(tabholder);info.appendChild(directions);break;case"small":default:$(container).addClass("small");container.appendChild(info);info.appendChild(header);info.appendChild(address);info.appendChild(directions);break;}
return container;}}
var OPTION_ALL=-1;var OPTION_NONE=0;queryFormat={"POST":1,"PRE":2,"EWIG":3}
function formatFacet(value,format)
{switch(format)
{case FACET_DATE:var date=new Date(value*1000);return date.getMonth()+"/"+date.getDate()+"/"+date.getFullYear();break;case FACET_PRICE:return"$"+value;break;}}
function ResultFilter(module,resultSet)
{if(resultSet!=null)
{this._construct(module,resultSet);}}
ResultFilter.prototype={_construct:function(module,resultSet)
{this.resultSet=resultSet;for(i in module)
this[i]=module[i];objects.push(this);if(this.type=="radius")
this.queryFormat=queryFormat.EWIG;var optionSet=document.createElement("div");optionSet.options=[];optionSet.values=[];optionSet.field=this.field;optionSet.type=this.type;optionSet.resultSet=this.resultSet;optionSet.hldr=this;this.resultIndex=new BinaryTree(this.field);this.resultIndex.hldr=this;this.resultIndex.doIteration=function(node){this.result=this.result.concat(node.data);}
this.optionSet=optionSet;if(this.method!="radius")
this.init(this.optionSet);},queryFormat:queryFormat.POST,update:function(module)
{},init:function()
{},indexResult:function(result)
{switch(this.type)
{case"num_span":case"radius":case"distance":break;default:if(this.resultIndex)
{result[this.field]=result.facets[this.field];this.resultIndex.add(result);}
break;}},setValues:function(data)
{this.value=data;},deserialize:function()
{if(this.type=="radius")
return false;var value=null;if(this.value.join!=null)
var value=this.value.join(",");else if((this.value.replace!=null)||(this.value.toPrecision!=null))
var value=this.value;if(value!=null)
return this.field+":"+value;},serialize:function()
{if(this.type=="radius")
return null;if(this.value!=null)
{if(this.value.replace!=null)
return this.value.toString();else
{valueSet=[];for(var i in this.value)
{if(this.value[i])
valueSet.push(this.value[i]);}
return valueSet;}}
else
return null;},display:function()
{switch(this.method)
{case"radius":return false;break;}
fs=document.createElement("fieldset");$(fs).addClass(this.type);var moreLink=document.createElement("a");label=document.createElement("label");label.appendChild(document.createTextNode(this.label));if(this.byline)
{var small=document.createElement("small");small.innerHTML="&nbsp;"+"("+this.byline+")";label.appendChild(small);}
fs.appendChild(label);if(!this.optionSet)
return false;fs.appendChild(this.optionSet);this.fieldset=fs;$("#filterContent").append(fs);},filterResult:function(result)
{switch(this.type)
{case"radius":var distance=getDistance(result.facets.location,result.resultSet.coordinates);return(distance<this.value?true:false);break;}},filterResults:function(results)
{switch(this.type)
{case"num_span":break;case"radius":case"distance":var currentResults=[];for(var index in results)
{var result=results[index];if(this.filterResult(result))
currentResults.push(result);}
break;case"enum":var currentResults=new Array();var finalResults=new Array();for(var eVal in this.optionSet.values)
{var params={value:eVal,type:"eq"};currentResults=currentResults.concat(this.resultIndex.iterator(params));}
for(var index in currentResults)
{var valid=false;var result=currentResults[index];for(var resultIndex in results)
{if(results[resultIndex].id==result.id)
{valid=true;break;}}
if(valid)
finalResults.push(result);}
currentResults=finalResults;break;default:var params={value:this.optionSet.value,type:"eq"};var currentResults=new Array();currentResults=currentResults.concat(this.resultIndex.iterator(params));break;}
return currentResults;},getLabel:function()
{return(this.label?this.label:this.field);},resetInputs:function(fromResult)
{switch(this.method)
{case"keyword":this.input.setValue('');break;case"enum":case"radio":for(var index in this.optionSet.options)
{var option=this.optionSet.options[index];if(index==OPTION_ALL)
option.checked=true;else
option.checked=false;}
this.optionSet.values=[];this.optionSet.all_selected=true;break;case"num_span":break;}
if(!fromResult)
this.setParameters();},clearFilter:function(fromResult)
{if(this.optionSet.values==null)
return false;if(!fromResult)
{if(this.optionSet.values!=null)
{this.optionSet.values=null;this.optionSet.values=[];this.setValues(this.optionSet.values);}
this.resetInputs();this.resultSet.clearFilters(this.getLabel());}},applyToResults:function()
{switch(this.method)
{case"enum":this.setValues(this.optionSet.values);if((this.optionSet.all_selected==true)||(this.value.length<1))
this.clearFilter();this.resultSet.getResults({filter:this});break;default:this.resultSet.getResults({filter:this});}},setParameters:function()
{var anchor=document.createElement("a");document.body.appendChild(anchor);var param=window.compileLink(this.getParameters(),anchor);window.open(param.hash,"_self");document.body.removeChild(anchor);},updateData:function()
{values=this.value;this.inputs.top.innerHTML=formatFacet(values.max,this.format);this.inputs.bot.innerHTML=formatFacet(values.min,this.format);},_update:function()
{},updateFilter:function(values)
{switch(this.method)
{case"radius":break;case"radio":this.optionSet.options[values].click();break;case"num_span":this.setValues({min:values[0],max:values[1]});this.displaySlider();this.updateData();break;case"link":break;case"category":break;case"enum":default:if(values.replace!=null)
var values=[values];this.resetInputs(1);for(var i in values)
{if(this.optionSet.options[values[i]]!=null)
{this.optionSet.options[values[i]].select();}}
break;}},getParameters:function()
{var parameters={"filters":this.resultSet.serializeFilters(this),"page":new Parameter('page',null,this.resultSet.pg.selectPage(0))};return parameters;},_destruct:function()
{var count=0;if((this.fieldset!=null)&&(this.fieldset.parentNode!=null))
this.fieldset.parentNode.removeChild(this.fieldset);for(var i in this)
{if(this[i]!=null)
{if(this[i]._destruct!=null)
this[i]._destruct();else
this[i]=null;count++;}}
killself(this);}}
function pagination(container,data,handler)
{this.container=container;this.container.innerHTML="";this.data=data;this.currentPage=this.data.currentPage;this.resultCnt=this.data.resultCnt;this.resultMax=this.data.resultCnt;this.viewscopeAmt=3;if(this.data.headContainer)
{this.data.headContainer.innerHTML='';this.pgHead=this.data.headContainer;}
this.resultsPerPage=this.data.resultsPerPage;this.resultHandler=handler;this.setPages();this.show();}
pagination.prototype.getResultsPerPage=function()
{return this.resultsPerPage;}
pagination.prototype.hide=function()
{$(this.container).hide();}
pagination.prototype.show=function()
{$(this.container).show();}
pagination.prototype.selectPage=function(page)
{var page=parseInt(page);var pgHead=[];if(this.pages[page])
{$(this.container).children().remove();var finalPage=(this.pages.length-1);var currentSet={};var prevPage=this.pageAct.prev;prevPage.value=(this.pages[page-1]?page-1:"NULL");var nextPage=this.pageAct.next;nextPage.value=(this.pages[page+1]?page+1:"NULL");var _chromePrev=prevPage;var viewscope={base:this.viewscopeAmt};var offset={};offset.right=page-viewscope.base;offset.left=finalPage-(page+viewscope.base);viewscope.right=(offset.left<0?viewscope.base+Math.abs(offset.left):(offset.right<0?viewscope.base-Math.abs(offset.right):viewscope.base));viewscope.left=(offset.right<0?viewscope.base+Math.abs(offset.right):(offset.left<0?viewscope.base-Math.abs(offset.left):viewscope.base));for(var i=viewscope.right;i>0;i--)
{var index=page-i;if(this.pages[index])
currentSet[index]=this.pages[index];}
for(var i=0;i<=viewscope.left;i++)
{var index=page+i;if(this.pages[index])
currentSet[index]=this.pages[index];}
this.currentPage=this.pages[page];if((this.pages[finalPage])&&(page!=finalPage))
{if((!currentSet[finalPage])&&(!currentSet[finalPage-1]))
currentSet['elipseNext']=this.elipse;currentSet[finalPage]=this.pages[finalPage];}
currentSet['next']=nextPage;var node=this.constructNode(_chromePrev);this.container.appendChild(node);if(currentSet[0]==null)
{this.container.appendChild(this.constructNode(this.pages[0]));if(!currentSet[1])
this.container.appendChild(this.constructNode(this.elipse));}
for(index in currentSet)
{var node=this.constructNode(currentSet[index]);this.container.appendChild(node);}
if(this.pgHead)
{_chromePrev.bulletLeft="&#171;&nbsp;";this.setHeaderNode(_chromePrev);if(!this.pgHead.spacer)
{var li=document.createElement("li");li.appendChild(document.createTextNode("-"));this.pgHead.appendChild(li);this.pgHead.spacer=li;}
currentSet.next.bulletRight="&nbsp;&#187;";this.setHeaderNode(currentSet.next);_chromePrev.bulletLeft=null;currentSet.next.bulletRight=null;}
this.currentPage=page;return this.currentPage;}
else
{return page;}}
pagination.prototype.setHeaderNode=function(node)
{var node=this.constructNode(node,1);if(this.pgHead[node.pageData.label])
this.pgHead.replaceChild(node,this.pgHead[node.pageData.label]);else
this.pgHead.appendChild(node);this.pgHead[node.pageData.label]=node;}
pagination.prototype.updateHeader=function(nodes)
{}
pagination.prototype.resetPages=function(len,pg)
{len=(len!=null?len:this.resultMax);this.resultCnt=len;this.setPages();this.selectPage(pg);}
pagination.prototype.setPages=function()
{var pageCnt=Math.ceil(this.resultCnt/this.resultsPerPage);pages=new Array();this.pageAct=new Object;this.pageAct.next={label:"next",value:"next",className:"pg_next"};this.pageAct.prev={label:"prev",value:"prev",className:"pg_prev"};this.elipse={value:"NULL",label:"...",className:"pg_elipse"}
for(j=0;j<pageCnt;j++)
{pages[j]={label:j+1,value:j,className:"pg_item"};}
this.pages=pages;}
pagination.prototype.setDrilldown=function(cnt,drilldata)
{this.resultCnt=cnt;if(this.resultMax!=this.resultCnt)
$("#drill_max").addClass("fltr");else
$("#drill_max").removeClass("fltr");try
{if(drilldata!=null)
var txt=(drilldata.start)+" - "+(drilldata.end);else
var txt="1 - "+this.resultCnt;}
catch(e)
{var txt="1 - "+(this.resultCnt>this.resultsPerPage?this.resultsPerPage:this.resultCnt);}
$("#drill_current").text(txt);$("#drill_max").text(this.resultCnt);}
pagination.prototype.getPageResults=function(results,page)
{startIndex=this.resultsPerPage*page;var resultSet=new Array();for(var j=0;j<this.resultsPerPage;j++)
{var index=j+startIndex;if(results[index])
{resultSet[j]=results[index];resultSet[j].showieIndex=j+1;}}
if(resultSet.length>0)
{var drilldata={start:resultSet[0].showieIndex+startIndex,end:resultSet[resultSet.length-1].showieIndex+startIndex}}
else
{var drilldata={start:0,end:0};}
this.setDrilldown(this.resultCnt,drilldata);return resultSet;}
pagination.prototype.constructNode=function(pageData)
{if(!pageData)
return false;pgItem=document.createElement("li");if((pageData.value=="NULL"))
pgItem.innerHTML="<span>"+(pageData.bulletLeft!=null?pageData.bulletLeft:'')+pageData.label+(pageData.bulletRight!=null?pageData.bulletRight:'')+"</span>";else
{var anchor=document.createElement("a");var span=document.createElement("span");span.innerHTML=pageData.label;anchor.href="#page="+pageData.value;anchor.appendChild(span);pgItem.anchor=anchor;anchor.pgItem=pgItem;var b1=document.createElement("span")
b1.innerHTML=pageData.bulletLeft;(pageData.bulletLeft!=null?pgItem.appendChild(b1):'');pgItem.appendChild(anchor);var b2=document.createElement("span")
b2.innerHTML=pageData.bulletRight;(pageData.bulletRight!=null?pgItem.appendChild(b2):'');}
pgItem.myResultHandler=this.resultHandler;$(pgItem).attr("label",pageData.label);$(pgItem).attr("value",pageData.value);pgItem.pageData=pageData;pgItem.label=pageData.label;pgItem.parameters={"page":new Parameter("page",null,pageData.value)};if(pageData.className!=undefined)
$(pgItem).addClass(pageData.className);if(pageData===this.currentPage)
{$(pgItem).removeClass("inert");$(pgItem).addClass("sel");}
else if(pageData.value=="NULL")
{$(pgItem).addClass("inert");$(pgItem).attr("class","inert"+" "+(pageData.className?pageData.className:''));$(pgItem).attr("className","inert"+" "+(pageData.className?pageData.className:''));}
else
{$(pgItem).removeClass("inert");$(pgItem).removeClass("sel");if(pageData.label!="prev"&&pageData.label!="next")
{$(pgItem).hover(function(){$(this).addClass("hover");},function()
{$(this).removeClass("hover");});}
$(pgItem.anchor).click(function()
{var params=window.compileLink(this.pgItem.parameters,this);this.href=params.href;this.hash=params.hash;});$(pgItem).click(function(){var myResultHandler=$(this).attr("myResultHandler");var pageLabel=$(this).attr("label");var pageValue=$(this).attr("value");switch(pageLabel)
{case"next":case"prev":trackEvent(["pagination",pageLabel],true);break;default:trackEvent(["pagination","numbers"],true);}
window.scrollTo(0,$("#header_info").position().top);var params={};for(var i in this.parameters)
params[i]=this.parameters[i].serialize();myResultHandler.getResults(params);});}
return pgItem;}
function preserveParameters(anchor)
{$(anchor).mouseover(function(e)
{var data=window.compileLink(null,this);this.href=data.href;this.hash=data.hash;});}
function toggleFilters(action)
{switch(action)
{case"show":$("#filters").show();$("#filterToggle").addClass("activeFT");$("#filterToggle").removeClass("inactiveFT");$("#filterToggle").text("hide options");break;case"hide":default:$("#filters").hide();$("#filterToggle").removeClass("activeFT");$("#filterToggle").addClass("inactiveFT");$("#filterToggle").text("show options");break;}}
$(document).ready(function()
{preserveParameters($("#filterToggle"));$("#filterToggle").click(function()
{if($("#filters").is(":visible"))
{toggleFilters('hide');$.cookie("filterToggle","hide",{expires:1});trackEvent(["filters","hide_filters"]);}
else
{toggleFilters('show');$.cookie("filterToggle","show",{expires:1});trackEvent(["filters","show_filters"]);}});});var geocoder=[];function _initKeywordSearch(resultSet)
{resultSet.loadFilter({method:"keyword",type:"keyword",object:"KeywordFilter",label:"keywords",field:"keyword",queryFormat:queryFormat.EWIG});}
function _initResults(resultData)
{}
var TABS={PHOTOS:"2",GENERAL:"1",DIRECTIONS:"3",REVIEWS:"6",NEARBY:"7"}
function triggerScroll(item,mgr)
{}
function ResultTabMgr(result)
{objects.push(this);this.result=result;this.tabs=this.result.tabs;this.module=this.result.module;this.tabObjects=[];this.pointer=null;this.reflinks=[];}
ResultTabMgr.prototype.displayLinks=function()
{this.links=document.createElement("ul");$(this.links).addClass("entry_links");set=[];for(var tabID in this.module.tabs)
{set.push(tabID);}
while(set.length>0)
{tabID=set.pop();if((this.tabs!=null)&&(this.tabs[tabID]))
{try
{var tabName=this.module.tabs[tabID];var item=document.createElement("li");item.className=tabID;this.reflinks[tabID]=item;this.links.appendChild(item);item.tabID=tabID;item.mgr=this;item.open=function()
{if(this.mgr.activeLink!=null)
{this.mgr.closeResultTab(this.mgr.activeLink.tabID);$(this.mgr.activeLink).removeClass("active");}
$(this.mgr.result.resultTemplate).addClass("noborder");$(this).addClass("active");this.mgr.activeLink=this;this.mgr.displayResultTab(this.tabID);}
item.close=function()
{$(this.mgr.squishbox).slideUp(500,$(this.mgr.squishWrapper).hide());$(this.mgr.result.resultTemplate).removeClass("noborder");$(this).removeClass("active");this.mgr.closeResultTab(this.tabID);this.mgr.activeLink=null;}
item.select=function()
{if(this.mgr.currentRequest!=null)
{this.mgr.currentRequest.terminateRequest();this.mgr.currentRequest=null;}
if(this.mgr.activeLink==this)
{this.close();this.mgr.activeLink=null;return false;}
else
{triggerScroll(this,this.mgr);this.open();}
var result=this.mgr.result;var resultInfo=result.id+"_"+result.showieIndex;var formattedLabel=$(this.link).text();trackEvent(["search_result",formattedLabel.replaceAll(" ","_")+"_tab",resultInfo]);}
item.link=document.createElement("a");item.appendChild(item.link);item.link.href="#__"+this.result.id.toString();item.link.name=this.result.id.toString()+"_"+tabID;item.link.innerHTML=tabName.toLowerCase();item.link.item=item;item.link.onclick=function(e)
{var data=window.compileLink(null,this);this.href=data.href;this.hash=data.hash;this.item.select();}}
catch(e)
{}}}
this.result.resultTemplate.appendChild(this.links);}
ResultTabMgr.prototype.getTab=function(id)
{if(this.reflinks[id]!=null)
return this.reflinks[id];}
ResultTabMgr.prototype.displayResultTab=function(tabID)
{if(this.tabObjects[tabID]!=null)
{this.tabObjects[tabID].reinit();this.displayContainer();}
else
this.fetchResultTab(tabID);}
ResultTabMgr.prototype.fetchResultTab=function(tabID)
{this.displayContainer();if(this.result.facets.location!=null)
{var loc=this.result.facets.location;var lat=(loc.lat!=null?loc.lat:0);var lng=(loc.lng!=null?loc.lng:0);}
else
{var lat=0;var lng=0;}
var data={action:"getSquishies",resultID:this.result.id,type:tabID,lat:(lat!=null?lat:0),lng:(lng!=null?lng:0),categoryID:this.result.facets.categoryID,locationID:this.result.resultSet.locationID}
this.pointer=tabID;var callbackParams={object:this,method:"loadResultTab"}
switch(this.pointer)
{case TABS.PHOTOS:var text="<img src=\"getImg=loaders/fish_load.png\" alt=\"loading...\" />";text+="<p>searching the web for images related to<br /><strong>&quot;"+this.result.facets.title+"&quot;</strong></p>"
var adtlParams={useLoader:true,loaderParent:this.squishbox,loaderClass:"loader_photo",loaderText:text}
$(this.squishbox).css("height",147);break;default:var text="<img src=\"getImg=loaders/fish_load.png\" alt=\"loading...\" />";text+="<p>thinking...</p>"
var adtlParams={useLoader:true,loaderParent:this.squishbox,loaderClass:"loader_squishie",loaderText:text}
$(this.squishbox).css("height",(111*2)+36);break;}
$(this.squishWrapper).show();$(this.squishbox).slideDown(500);this.currentRequest=new AjaxRequest(this.result.resultSet.REQUEST_URL,callbackParams,data,"GET");this.currentRequest.makeRequest(adtlParams);}
ResultTabMgr.prototype.loadResultTab=function(data)
{if(data.js)
Goby.get("scriptLoader").importCode(data.js,data.object);this.currentRequest=null;data.result=this.result;data.mgr=this;data.container=this.squishbox;data.id=this.pointer;if(data.object)
this.addResultTab(eval("new "+data.object+"(data);"));else
this.addResultTab(new ResultTab(data));}
ResultTabMgr.prototype.addResultTab=function(resultTab)
{this.tabObjects[resultTab.id]=resultTab;this.pointer=null;}
ResultTabMgr.prototype.closeResultTab=function(tabID)
{if(this.tabObjects[tabID]!=null)
this.tabObjects[tabID].close();}
ResultTabMgr.prototype.displayContainer=function()
{if(this.squishbox!=null)
{$(this.squishWrapper).show();$(this.squishbox).slideDown(300);return this.squishbox;}
var squishWrapper=document.createElement("div");$(squishWrapper).addClass("squishWrapper");var header=document.createElement("hr");var closer=document.createElement("div");var squishbox=document.createElement("div");$(squishbox).addClass("squishbox");var link=document.createElement("a");var span=document.createElement("span");span.appendChild(document.createTextNode("close"));link.appendChild(span);closer.className="closer";closer.appendChild(link);closer.mgr=this;closer.onclick=function()
{if(this.mgr.activeLink!=null)
{if($(this.squishbox).is(":hidden"))
{$(this.squishWrapper).show();$(this.squishbox).slideDown(500);}
else
{this.mgr.activeLink.close();}}}
this.squishbox=squishbox;squishWrapper.appendChild(header);squishWrapper.appendChild(squishbox);squishWrapper.appendChild(closer);this.squishWrapper=squishWrapper;this.result.resultTemplate.appendChild(squishWrapper);}
ResultTabMgr.prototype._destruct=function()
{for(var i in this.tabObjects)
this.tabObjects[i]=null;this.tabObjects=null;this.links=null;killself(this);}
function slideScroll(time)
{var t=time/50;setInterval(t,function()
{});}
function ResultTab(data)
{this._construct(data);}
ResultTab.prototype={_construct:function(data)
{if(data)
{for(var i in data)
this[i]=data[i];if(this.result!=null)
this.facets=this.result.facets;this.content=this.init();this.container.appendChild(this.content);this.resize(-1);objects.push(this);}},reinit:function()
{this.content=this.init();this.resize(-1);this.container.appendChild(this.content);},close:function()
{this.container.removeChild(this.content);},display:function()
{this.init();},resize:function(val)
{var height=(val==-1?(111*2)+36:val);$(this.container).css({"height":height,"overflow":"auto"});},init:function()
{if(this.tpl==null)
return false;var template=this.tpl;for(index in this.facets)
if((this.facets[index]!=null)&&(this.facets[index].replace))
template=template.replace("["+index+"]",this.result.displayFacet(index));template=template.replaceAll(/\[(.+?)\]/,"");var div=document.createElement("div");div.innerHTML=template;return div;},_destruct:function()
{if(this.content!=null)
this.content.parentNode.removeChild(this.content);for(var i in this)
this[i]=null;}}
function mapHandler(type,containerID,coor){this.containerID=containerID;this.type=type;this.ewindows=[];this.ico=[];this.icons=[];this.bookmarks=[];this.stack=[];this.stackLinks=[];this.openStack=[];this.localBookmarks=[];this.scrollable=false;this.dots={hidden:new Array(),visible:new Array()};this.bookmarkList=document.getElementById("small_map_marker");this.map=this.initMap(coor);this.map.mapHandler=this;objects.push(this);}
mapHandler.prototype._destruct=function()
{GUnload();for(var i in this)
{if(this[i]!=null)
{if(this[i]._destruct!=null)
this[i]._destruct();else
this[i]=null;}}
delete this;}
mapHandler.prototype.showAllPoints=function(isInit)
{if((this.bounds!=undefined)&&(this.bounds))
{this.getFurthestPt();this.bounds.extend(this.refPt.getLatLng());var zoomlevel=this.map.getBoundsZoomLevel(this.bounds);this.map.setCenter(this.bounds.getCenter(),zoomlevel);}}
mapHandler.prototype.getFurthestPt=function()
{var current=null;if(this.marker.length<1)
return false;for(var f in this.marker)
{var marker=this.marker[f];if(marker.result!=null)
{if((current==null)||(marker.result.getDistance()>current.result.getDistance()))
current=marker;}}
if(current==null)
return false;var pt=current.getPoint()
var pt2=this.refPt.getLatLng();var _lat=pt2.lat()-(pt.lat()-pt2.lat());var _lng=pt2.lng()-(pt.lng()-pt2.lng());var anchor=new GLatLng(_lat,_lng);this.bounds.extend(anchor);}
mapHandler.prototype.showPoint=function(point)
{if(!this.bounds.containsLatLng(point))
{this.bounds.extend(point);}}
mapHandler.prototype.setPoint=function(result)
{index=result.showieIndex;if((result.facets.location!=undefined)&&(result.facets.location.lng)&&(result.facets.location.lat))
{if(this.isDot(result))
{this.point[index]=this.getDot(result).getPoint();this.hideDot(result);}
else
{var dot=this.addDot(result);this.point[index]=dot.getPoint();this.hideDot(result);}
this.plotPoint(this.point[index],result);}}
mapHandler.prototype.initBounds=function(point)
{if(!point)
var point=this.centerPt;this.bounds=new GLatLngBounds(point);}
mapHandler.prototype.toggleSearch=function()
{if(!this.localsearch)
{this.reshowMap();var options={suppressZoomToBounds:true,onSearchCompleteCallback:function(searcher){},onGenerateMarkerHtmlCallback:function(p1,p2,p3){var html=this.mapHandler.addLocalBookmark(p1,p2,p3);return html;},onSearchCompleteCallback:function(searcher){}};this.localsearch=new google.maps.LocalSearch();this.localsearch.mapHandler=this;this.map.addControl(this.localsearch,new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(10,20)));this.localsearch.focus();}
else
{this.map.removeControl(this.localsearch);this.localsearch=false;delete this.localsearch;}}
mapHandler.prototype.setCenter=function(lat,lng)
{this.centerPt=new GLatLng(lat,lng);this.map.setCenter(this.centerPt,10);}
mapHandler.prototype.displayCenter=function()
{}
mapHandler.prototype.clearStreetView=function()
{try
{this.controls.big.extLg.clearStreet();}
catch(e)
{}}
mapHandler.prototype.showStreetView=function(result)
{var dot=this.getDot(result);if(dot)
var point=dot.getPoint();else
return false;if(this.type=="small")
{this.resultSet.selectMap("big");}
this.controls.big.extLg.showStreetView(point);}
mapHandler.prototype.closeEWindows=function()
{while(this.ewindows.length>0)
{var win=this.ewindows.pop();win.remove();}}
mapHandler.prototype.reformat=function(type)
{this.type=type;this.format=type;try
{this.closeEWindows();}
catch(e)
{}
this.map.checkResize();this.showAllPoints();try
{switch(type)
{case"small":this.clearStreetView();for(var index in this.controls.big)
{try{this.map.removeControl(this.controls.big[index]);}
catch(e){}}
for(var index in this.controls.small)
{this.map.addControl(this.controls.small[index]);}
$("#fullMapContent").hide();if(this.localsearch)
this.toggleSearch();break;case"big":for(var index in this.controls.small)
(index=="menumaptypecontrol"?this.controls[index]=false:this.map.removeControl(this.controls.small[index]));for(var index in this.controls.big)
{this.map.addControl(this.controls.big[index]);}
break;}}
catch(e)
{alert(e.message);}}
mapHandler.prototype.getGhostIcon=function()
{var baseIcon=new GIcon(null,null);baseIcon.iconSize=new GSize(0,0);baseIcon.shadowSize=new GSize(0,0);baseIcon.iconAnchor=new GPoint(0,0);baseIcon.infoWindowAnchor=new GPoint(0,0);var centerIcon=new GIcon(baseIcon);return centerIcon;}
mapHandler.prototype.resetCenter=function(coor)
{this.map.removeOverlay(this.centerMarker);this.map.setCenter(new GLatLng(coor.lat,coor.lng),10);this.centerMarker=new GMarker(this.map.getCenter(),this.getGhostIcon());this.map.addOverlay(this.centerMarker);this.addBookmark(coor.locationName,this.centerMarker);}
mapHandler.prototype.initMap=function(coor)
{var lat=coor.lat;var lng=coor.lng;var map=new GMap2(document.getElementById(this.containerID));this.map=map;map.setCenter(new GLatLng(lat,lng),10);this.centerMarker=new GMarker(map.getCenter(),{icon:this.getGhostIcon()});map.addOverlay(this.centerMarker);this.addBookmark(coor.locationName,this.centerMarker);map.mapHandler=this;GEvent.addListener(map,"dblclick",function()
{map.mapHandler.currentMarker=undefined;map.mapHandler.setCurrent(null);while(this.mapHandler.openStack.length>0)
{var stack=this.mapHandler.openStack.pop();try{if(openStack.pop!=null)
openStack.close();}
catch(e)
{}}});GEvent.addListener(map,"click",function(overlay)
{if(!overlay)
map.mapHandler.setCurrent(null);});this.controls={};this.controls.small={"menumaptypecontrol":new GMenuMapTypeControl(),"mapCtrl":new mapCtrl()};this.controls.big={"extLg":new ExtLargeMapControl(),"maptypecontrol":new GMapTypeControl()};map.addMapType(G_HYBRID_MAP);map.addMapType(G_PHYSICAL_MAP);try
{}
catch(e)
{alert(e.message);}
this.points=[];this.marker=[];this.point=[];try
{$("#miniMapWrapper").show();this.addReferencePoint();return map;}
catch(e)
{}}
mapHandler.prototype.selectPoint=function(id)
{if(this.point[id])
{this.map.panTo(this.point[id]);this.point[id];$(this.marker[id]).click();while(this.openStack.length>0)
{try
{this.openStack.pop().close();}
catch(e)
{}}
switch(this.type)
{case"small":if(this.stackLinks[id])
{this.stackLinks[id].stackWindow.display(id);this.openStack.push(this.stackLinks[id]);}
else
{this.marker[id].displayTemplate();}
break;case"big":if(this.stackLinks[id])
{this.stackLinks[id].stackWindow.display(id);this.openStack.push(this.stackLinks[id]);}
else
{this.marker[id].displayTemplate();}
break;}}
else
{}}
mapHandler.prototype.setCoor=function(result)
{return false;}
mapHandler.prototype.plotAddress=function(result)
{return false;}
mapHandler.prototype.resetMarkers=function()
{if((this.marker)&&(this.bounds))
{for(index in this.marker)
{var marker=this.marker[index];if(marker.stackWindow!=undefined)
{marker.stackWindow.close();}
this.map.removeOverlay(marker);this.showDot(marker.result);this.marker[index]=false;this.point[index]=false;}
while(this.openStack.length>0)
{var stack=this.openStack.pop();if(stack.close!=null)
stack.close();}
while(this.stackLinks.length>0)
{var stackLink=this.stackLinks.pop();if(stackLink)
stackLink.remove();}
this.stack=false;this.stack=[];delete this.bounds;this.bounds=false;}}
mapHandler.prototype.addStack=function(marker)
{var point=marker.getPoint();var lat=point.lat();var lng=point.lng();if((this.stack[lat]==undefined)||((this.stack[lat]==null)))
this.stack[lat]=[];this.stack[lat][lng]=marker;}
mapHandler.prototype.getStack=function(point)
{var lat=point.lat();var lng=point.lng();if(this.stack[lat]!=undefined)
{if(this.stack[lat][lng]!=undefined)
if(this.stack[lat][lng])
return this.stack[lat][lng];}
return false;}
mapHandler.prototype.isStack=function(point)
{var lat=point.lat();var lng=point.lng();if(this.stack[lat]!=undefined)
{if(this.stack[lat][lng]!=undefined)
if(this.stack[lat][lng])
return true;}
return false;}
mapHandler.prototype.isDot=function(result)
{if(this.dots.visible[result.id])
return true;else if(this.dots.hidden[result.id])
return true;else
return false;}
mapHandler.prototype.getDot=function(result)
{if(this.dots.visible[result.id])
return this.dots.visible[result.id];else if(this.dots.hidden[result.id])
return this.dots.hidden[result.id];else
return false;}
mapHandler.prototype.addDot=function(result)
{if(!result)
return false;if(this.dots.hidden[result.id])
{this.showDot(result);}
else if(!this.dots.visible[result.id])
{var letteredIcon=new GIcon(this.getIcon('dot'));var point=new GLatLng(result.facets.location.lat,result.facets.location.lng);var dot=new GMarker(point,{icon:letteredIcon,clickable:true});dot.mapHandler=this;dot.result=result;this.map.addOverlay(dot);dot.fetchTemplate=function(type)
{return this.result.displayMapTab(type);}
dot.displayTemplate=function()
{this.openInfoWindowHtml(this.fetchTemplate(this.mapHandler.type=="big"?"big_dot":"small_dot"));}
GEvent.addListener(dot,"click",function()
{this.displayTemplate();});this.dots.visible[result.id]=dot;return dot;}}
mapHandler.prototype.rmDot=function(result)
{if(!result)
return false;if(this.dots.visible[result.id])
var dot=this.dots.visible[result.id];else if(this.dots.hidden[result.id])
var dot=this.dots.hidden[result.id];else
return false;this.map.removeOverlay(dot);}
mapHandler.prototype.hideDot=function(result)
{if(!result)
return false;if(this.dots.visible[result.id])
{var dot=this.dots.visible[result.id];this.dots.visible[result.id]=false;this.dots.hidden[result.id]=dot;dot.hide();}}
mapHandler.prototype.showDot=function(result)
{if(!result)
return false;if(this.dots.hidden[result.id])
{var dot=this.dots.hidden[result.id];this.dots.hidden[result.id]=false;this.dots.visible[result.id]=dot;dot.show();}}
mapHandler.prototype.appendStack=function(point,result)
{var marker=this.getStack(point);if(!marker.isStack)
{var icon=this.getIcon((result.facets.location.streetAddress?'stack-street':'stack-generic'),marker.result.showieIndex,marker.getIcon());marker.remove();marker.icon=icon;marker.initialize(this.map);marker.redraw(true);marker.data=[];marker.isStack=true;marker.mapHandler=this;marker.stackWindow=new StackWindow(marker,this.map);marker.stackWindow.add(marker.result);this.stackLinks[marker.result.showieIndex]=marker;GEvent.clearListeners(marker,"click");GEvent.addListener(marker,"click",function(){this.mapHandler.setCurrent(marker);while(this.mapHandler.openStack.length>0){this.mapHandler.openStack.pop().close();}
if(this.stackWindow.isOpen==false){this.ewindow=new EWindow(this.map,SUMMARY_BOX);this.stackWindow.display();}else{this.stackWindow.close();this.stackWindow.display();}});}
this.stackLinks[result.showieIndex]=marker;marker.stackWindow.add(result);}
mapHandler.prototype.getBaseIcon=function(type)
{if(this.icons[type]!=null)
return this.icons[type];switch(type)
{case"single-street":var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.iconSize=new GSize(18,26);baseIcon.shadow=IMG_PATH+"/map_icons/oPin_Single/single-shadow.png";baseIcon.shadowSize=new GSize(31,26);baseIcon.iconAnchor=new GPoint(10,26);baseIcon.infoWindowAnchor=new GPoint(9,2);break;case"single-generic":var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.iconSize=new GSize(18,18);baseIcon.shadow=IMG_PATH+"/map_icons/oPin_Single/single-shadow.png";baseIcon.shadowSize=new GSize(31,26);baseIcon.iconAnchor=new GPoint(10,18);baseIcon.infoWindowAnchor=new GPoint(9,2);break;case"bookmark":var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.iconSize=new GSize(18,26);baseIcon.shadow=IMG_PATH+"/map_icons/addr/add_shadow.png";baseIcon.shadowSize=new GSize(31,26);baseIcon.iconAnchor=new GPoint(9,32);baseIcon.infoWindowAnchor=new GPoint(7,6);baseIcon.transparent=IMG_PATH+"/map_icons/addr/add_shadow.png";break;default:return new GIcon(G_DEFAULT_ICON);}
this.icons[type]=baseIcon;return this.icons[type];}
mapHandler.prototype.getIcon=function(type,index,icon)
{switch(type)
{case"single-street":var node=new GIcon(this.getBaseIcon(type));node.sprite={image:PIN_MAP_SRC,width:18,height:26,top:0,left:(parseInt(index)*18)-18}
node.iconAnchor=new GPoint(18,26);node.shadowSize=new GSize(31,26);node.iconAnchor=new GPoint(10,18);node.infoWindowAnchor=new GPoint(9,2);return node;break;case"single-generic":var node=new GIcon(this.getBaseIcon(type));node.sprite={image:PIN_MAP_SRC,width:18,height:18,top:26,left:(parseInt(index)*18)-18}
node.iconAnchor=new GPoint(18,18);node.infoWindowAnchor=new GPoint(5,5);return node;break;case"pin":var pinIcon=new GIcon(this.getBaseIcon(type));pinIcon.iconSize=new GSize(31,25)
pinIcon.shadow='';pinIcon.iconAnchor=new GPoint(10,30);pinIcon.infoWindowAnchor=new GPoint(5,5);pinIcon.sprite={image:PIN_MAP_SRC,width:31,height:25,top:0,left:370}
this.ico[type]=pinIcon;break;case"bookmark":var icon=new GIcon(this.getBaseIcon('bookmark'));var params={image:PIN_MAP_SRC,width:18,height:24,top:92}
params.left=(parseInt(index)*params.width)-params.width;icon.sprite=params;return icon;break;case"marker":var baseIcon=new GIcon(null,IMG_PATH+"/map_icons/bPin_Single/bPin_Single_1.png");baseIcon.shadow=IMG_PATH+"/map_icons/addr/add_shadow.png";baseIcon.shadowSize=new GSize(31,26);baseIcon.iconSize=new GSize(18,18);baseIcon.iconAnchor=new GPoint(0,0);baseIcon.infoWindowAnchor=new GPoint(18,2);this.ico[type]=baseIcon;break;case"dot":var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.sprite={image:PIN_MAP_SRC,width:10,height:10,top:0,left:360}
baseIcon.iconSize=new GSize(10,10);baseIcon.shadowSize=new GSize(0,0);baseIcon.iconAnchor=new GPoint(4,4);baseIcon.infoWindowAnchor=new GPoint(9,2);this.ico[type]=baseIcon;break;case"stack-street":if(!icon)
var icon=new GIcon(icon);icon.iconSize=new GSize(22,28);var params={image:PIN_MAP_SRC,width:22,height:28,top:44};params.left=(parseInt(index)*params.width)-params.width;icon.sprite=params;icon.shadow=IMG_PATH+"/map_icons/oPin_Single/single-shadow.png";icon.shadowSize=new GSize(41,36);icon.iconAnchor=new GPoint(12,28);return icon;break;case"stack-generic":if(!icon)
var icon=new GIcon(icon);var params={image:PIN_MAP_SRC,width:22,height:20,top:71};params.left=(parseInt(index)*params.width)-params.width;icon.sprite=params;icon.iconSize=new GSize(22,20);icon.shadow=IMG_PATH+"/map_icons/oPin_Single/single-shadow.png";icon.shadowSize=new GSize(41,36);icon.iconAnchor=new GPoint(12,20);return icon;break;default:return null;}
return this.ico[type];}
mapHandler.prototype.plotPoint=function(point,searchResult)
{var index=searchResult.showieIndex;if(this.isStack(point))
{this.appendStack(point,searchResult);return true;}
var icon=this.getIcon((searchResult.facets.location.streetAddress?'single-street':'single-generic'),searchResult.showieIndex);this.point[index]=point;var marker=new GMarker(point,{icon:icon,clickable:true});marker.result=searchResult;marker.mapHandler=this;marker.isStack=false;marker.dot=this.getDot(searchResult);marker.displayTemplate=function()
{this.mapHandler.setCurrent(this);this.openInfoWindowHtml(this.result.displayMapTab(this.mapHandler.type));}
this.map.addOverlay(marker);var _map=this,_idx=index;GEvent.addListener(this.point[index],"click",function()
{_map.currentMarker=_idx;_map.setCurrent(null);this.displayTemplate();});GEvent.addListener(marker,"click",function()
{_map.currentMarker=_idx;_map.setCurrent(null);this.displayTemplate();});GEvent.addListener(this.map.getInfoWindow(),'closeclick',function(){_map.currentMarker=undefined;_map.setCurrent(null);});this.marker[searchResult.showieIndex]=marker;this.addStack(this.marker[index]);this.showPoint(this.point[index]);}
mapHandler.prototype.addReferencePoint=function(){this.reshowMap();if(this.mapRadius!=null)
{var mapRad=this.mapRadius;if(mapRad.active)
mapRad.deactivateRadius();}
while(this.ewindows.length>0)
{var win=this.ewindows.pop();win.remove();}
if(this.refPt!=undefined)
{this.removeBookmark("my pin");this.map.removeOverlay(this.refPt);if(this.refPt.ewindow!=null)
this.refPt.ewindow.remove();delete this.refPt;}
var pinIcon=this.getIcon("pin");function orderOfCreation(marker,b){return 1;}
var marker=new GMarker(this.centerMarker.getPoint(),{draggable:true,bouncy:true,bounceGravity:2,icon:pinIcon,zIndexProcess:orderOfCreation});marker.mapHandler=this;if($.cookie("dragme")!="seen")
{var ewindow=new EWindow(this.map,SUMMARY_BOX);ewindow.initialize(this.map);ewindow.openOnMarker(marker,"Drag me!");this.map.ewindow=ewindow;marker.ewindow=ewindow;this.ewindow=ewindow;GEvent.addListener(this.map,"click",function()
{if(this.ewindow!=null)
{this.ewindow.remove();$.cookie("dragme","seen",{expires:86400});}});}
this.refPt=marker;this.addBookmark("my pin",this.refPt);GEvent.addListener(marker,"click",function(){var infoHTML='<div id="pin-home" class="infowin" >'+'<div class="info-icon"></div>'+'<div class="info">'+'<h3>You searched here!</h3>'+'<div class="address">'+'Drag this pin to explore your search location.'+'</div></div></div>';marker.openInfoWindowHtml(infoHTML);});GEvent.addListener(marker,"dragstart",function()
{marker.closeInfoWindow();if(marker.ewindow!=null)
try{marker.ewindow.remove();}catch(e){}
$.cookie("dragme","seen",{expires:86400});this.mapHandler.currentMarker=undefined;});GEvent.addListener(marker,"dragend",function()
{var point=marker.getLatLng();if(this.mapHandler.resultSet!=undefined)
{this.mapHandler.resultSet.nudged=true;this.mapHandler.bounds.extend(point);this.mapHandler.resultSet.setCenterCoor({lat:point.lat(),lng:point.lng()});this.mapHandler.resultSet.getResults({sort:{label:"distance",dir:"ASC"}});this.mapHandler.bounds.extend(point);}
if(this.mapHandler.mapRadius!=null)
{var mapRad=this.mapHandler.mapRadius;if(mapRad.active)
mapRad.activateRadius(mapRad.currentOption);}});this.map.addOverlay(marker);this.map.setCenter(this.centerMarker.getPoint());}
mapHandler.prototype.createCircle=function(marker,radius)
{if(marker.geoQuery)
marker.geoQuery.remove();var point=marker.getPoint();marker.geoQuery=createCircle(point,radius*1609.344,this);var radiusMI=radius/70;this.initBounds(point);var southwest=new GLatLng(point.lat()-radiusMI,point.lng()-radiusMI);var northeast=new GLatLng(point.lat()+radiusMI,point.lng()+radiusMI);this.bounds.isRadius=1;this.bounds.extend(southwest);this.bounds.extend(northeast);this.showAllPoints();return marker;}
function setDistance(point,d)
{point.lat();point.lng();return d/70;}
mapHandler.prototype.hideRadius=function()
{delete this.radialSearch;}
mapHandler.prototype.addBookmark=function(id,point)
{this.bookmarks[id]=point;if(this.bookmarkList)
{var j=this.bookmarkList.options.length;var index=this.bookmarkList.add(new Option(id,id),(navigator.isBrowser(browser.IE)||navigator.isBrowser(browser.IE_SIX)||navigator.isBrowser(browser.IE_SEVEN)||navigator.isBrowser(browser.IE_EIGHT)?(j):null));this.bookmarkList.selectedIndex=this.bookmarkList.options.length-1;}}
mapHandler.prototype.getBookmark=function(id)
{if(this.bookmarks[id]!=undefined)
return this.bookmarks[id];else
return false;}
mapHandler.prototype.removeBookmark=function(id)
{if(navigator.isBrowser(browser.IE)||navigator.isBrowser(browser.IE_SIX)||navigator.isBrowser(browser.IE_SEVEN)||navigator.isBrowser(browser.IE_EIGHT))
return false;if(this.bookmarkList)
{var options=this.bookmarkList.options;if(options)
{for(index in options)
{if(options[index]==undefined)
continue;if(options[index].value==id)
this.bookmarkList.remove(index);}}
if(this.bookmarks[id].geoQuery)
this.bookmarks[id].geoQuery.remove();delete this.bookmarks[id];}}
mapHandler.prototype.loadBookmark=function(id,radius)
{this.reshowMap();for(index in this.bookmarks)
if(this.bookmarks[index].geoQuery!=undefined)
this.bookmarks[index].geoQuery.remove();var marker=this.bookmarks[id];var point=marker.getPoint();if(this.radiusFilter==undefined)
{var module={method:"radius",type:"radius",field:"radius",label:"radius"}
this.radiusFilter=new ResultFilter(module,this.resultSet);}
if(point==null)
return false;this.resetMarkers();if(radius>0)
{var marker=this.createCircle(marker,radius);marker.geoQuery.updateCircle(1,marker.getPoint());if(this.resultSet!=undefined)
{this.resultSet.setCenterCoor({lat:point.lat(),lng:point.lng()});this.radiusFilter.setValues(radius);this.resultSet.getResults({filter:this.radiusFilter,boundIsInit:false});}
var radiusMI=radius/70;var southwest=new GLatLng(point.lat()-radiusMI,point.lng()-radiusMI);var northeast=new GLatLng(point.lat()+radiusMI,point.lng()+radiusMI);this.bounds.extend(southwest);this.bounds.extend(northeast);this.bounds.isRadius=1;this.showAllPoints();}
else
{this.initBounds(point);if(this.resultSet!=undefined)
{this.resultSet.setCenterCoor({lat:point.lat(),lng:point.lng()});if(this.radiusFilter)
this.radiusFilter.clearFilter();}}}
mapHandler.prototype.toggleQuery=function(activate)
{if(!this.scrollable)
{this.reshowMap();this.scrollable=true;GEvent.addListener(this.map,"dragend",function()
{var bounds=this.getBounds();var distance=bounds.toSpan();var center=this.getCenter();var radius=(distance.distanceFrom(center)*0.000621371192);var params={lat:center.lat(),lng:center.lng(),radius:radius};if(this.mapHandler.resultSet!=undefined)
this.mapHandler.resultSet.initResults(params);});}
else
{GEvent.clearListeners(this.map,"dragend");this.scrollable=false;}}
mapHandler.prototype.runNewQuery=function()
{this.reshowMap();var bounds=this.map.getBounds();var distance=bounds.toSpan();var center=bounds.getCenter();var radius=(distance.distanceFrom(center)/5280);params={lat:center.lat(),lng:center.lng(),radius:radius};if(this.resultSet!=undefined)
this.resultSet.initResults(params);}
mapHandler.prototype.addLocalBookmark=function(marker,html,result)
{if(!this.getBookmark(result.titleNoFormatting))
{markerOptions={icon:this.getIcon('bookmark',(this.localBookmarks!=undefined?this.localBookmarks.length+1:1))};var point=marker.getPoint();var betterMarker=new GMarker(point,markerOptions);this.localBookmarks.push(betterMarker);this.map.addOverlay(betterMarker);betterMarker.id=result.titleNoFormatting;betterMarker.mapHandler=this;betterMarker.index=this.localBookmarks.length;GEvent.addListener(betterMarker,"click",function(){betterMarker.openInfoWindowHtml(betterMarker.id);});this.addBookmark(betterMarker.id,betterMarker);}
this.map.removeOverlay(marker);return html;}
mapHandler.prototype.reshowMap=function()
{this.clearStreetView();}
mapHandler.prototype.getCurrent=function()
{return(this.curMrk!=null?this.curMrk:null);}
mapHandler.prototype.setCurrent=function(marker)
{this.curMrk=marker;}
mapHandler.prototype.changeSize=function()
{if(this.type=="small")
{window.scrollTo(0,$("#title").position().top);this.resultSet.selectMap("big");}
else
{this.resultSet.selectMap("small");}
var marker=this.getCurrent();if(marker!=null)
{if(marker.isStack)
{marker.stackWindow.close();marker.stackWindow.display();}
else
{marker.displayTemplate(this.type);}}}
mapHandler.prototype.makeMarker=function(point)
{var point=point;var marker=new GMarker(point,{icon:this.getIcon('marker'),clickable:true});this.map.addOverlay(marker);return marker;}
function _initMapToggle(resultSet)
{$(".mapToggle").data("resultSet",resultSet);$(".mapToggle").click(function()
{$(this).data("resultSet").getMap().changeSize();});preserveParameters($(".mapToggle"));}
function makeOption(value,text)
{var option=document.createElement("option");option.value=value;option.text=text;return option;}
function _initMapActions(resultObject)
{$(".mapActions").show();preserveParameters($(".mapReference"));$(".mapReference").data("resultSet",resultObject);$(".mapReference").click(function(){var resultRef=$('.mapReference').data("resultSet");resultRef.addReferencePoint('small');});$(".mapCustom").data("resultSet",resultObject);preserveParameters($(".mapCustom"));$(".mapCustom").click(function()
{var resultSet=$(this).data("resultSet");var mapHandler=resultSet.getMap();if(mapHandler.getCurrent())
{if(mapHandler.getCurrent().isStack)
mapHandler.getCurrent().stackWindow.close();mapHandler.setCurrent(null);}
if(mapHandler.type=="small")
mapHandler.changeSize();mapHandler.toggleSearch();});}
function _initMapLock(mui)
{var locker=new Link({text:"lock map",fnc:function()
{if(mui.locked)
{mui.toggleLock(false);this.innerHTML="lock map";}
else
{mui.toggleLock(true);this.innerHTML="unlock map";}}});locker.mui=mui;$("#miniMapWrapper").append(locker);}
function _initMapRadius(mapHandler)
{$("#smallMapForm").show();var radiusSelect=document.createElement("select");radiusSelect.setAttribute("name","mapRadius");radiusSelect.setAttribute("id","small_map_radius");radiusSelect.setAttribute("class","mapRadius");radiusSelect.setAttribute("mapType","small");$("#radiusContainer").append(radiusSelect);var selector=new Selector({container:radiusSelect.parentNode,select:radiusSelect,className:"selectGhost",id:"radiusGhost"},{callbackObject:radiusSelect,callbackMethod:"activateRadius"});selector.active=false;mapHandler.mapRadius=radiusSelect;selector.defaultOption=makeOption("-1","any distance");selector.addOption(selector.defaultOption);selector.addOption(makeOption(".25","close - &frac14; mile"));selector.addOption(makeOption(".5","not far - &frac12; mile"));selector.addOption(makeOption("1","long walk - 1 mile"));selector.addOption(makeOption("5","long hike - 5 miles"));selector.addOption(makeOption("10","short drive - 10 miles"));selector.addOption(makeOption("25","adventure - 25 miles"));selector.display();radiusSelect.mapHandler=mapHandler;radiusSelect.setRadius=document.getElementById("setRadius");radiusSelect.deactivateRadius=function()
{this.active=false;this.mapHandler.hideRadius();this.defaultOption.select();}
radiusSelect.activateRadius=function(option)
{this.currentOption=option;if(option.value>0)
this.active=true;else
{if(this.mapHandler)
this.mapHandler.hideRadius();this.active=false;}
if(this.mapHandler)
{this.mapHandler.clearStreetView();trackEvent(["filters","radius"]);var marker=this.mapHandler.loadBookmark('my pin',option.value);}}}