/* results
 
@author Jacob at Goby
 @version 09/02/11
@svn goby_-150
*/

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!="undefined"&&typeof this.result.facets[name]!="undefined"?this.result.facets[name]:'');objects.push(this);}},imbue:function(){},className:null,persistant:false,remove:function()
{var node=this.getNode();if(node)
node.parentNode.removeChild(node);this._destruct();},getResult:function()
{return this.result;},isPersistant:function()
{return this.persistant;},value:null,_destruct:function()
{if(this.result)
{this.result.removeFacet(this);this.result=null;}
this.node=null;Goby._kill(this);},setNode:function(node)
{this.node=node;},reRender:function(param)
{var node=this.getNode();if(node&&node.parentNode)
{node.parentNode.insertBefore(this.render(null,param),node);node.parentNode.removeChild(node);}},getField:function()
{switch(this.getName())
{case"phone":return new PrettyField({label:"phone",name:this.getName(),v:'[phone:0]',value:this.getValue(),default_value:"",tip:"(987) 765-5432"});break;case"website":case"source_url":return new PrettyField({label:"website",name:this.getName(),v:'[url:1]',value:this.getValue(),default_value:"",tip:"http://www.example.com"});break;case"title":return new PrettyField({label:this.getLabel(),name:"title",v:'[all:1]',value:this.getValue(),default_value:"",tip:this.getTip()});break;default:return null;}},close:function()
{if(this.node!=null&&this.node.parentNode!=null)
this.node.parentNode.removeChild(this.node);},hide:function()
{if(this.node!=null)
this.node.style.display='none';},show:function()
{if(this.node!=null)
this.node.style.display='';},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
return new Span({className:"facet_"+this.name,txt:this.getFormatted()});return node;},getName:function()
{return this.name;},getValue:function()
{if(this.value!=null)
return this.value;},setRequest:function(request)
{this.request=request;},getRequest:function()
{if(this.request==null)
{return null;}
else if(this.request.isTerminal())
{this.request=null;return this.request;}
else
return this.request;},getNode:function()
{if(this.node)
return this.node;else if(this.getResult()==null)
return null;else if(this.getResult().obj=="static")
{if(this.className)
var name="."+this.className;else
var name=".facet_"+this.name
var node=$(this.result.resultTemplate).find(name).get(0);if(node)
this.node=node;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;}
FacetPrice.prototype.getField=function()
{return new PrettyField({label:"price",'name':this.name,v:"[int:1]"});}
function FacetAffiliate(result)
{this._construct('affiliate',result);}
FacetAffiliate.prototype=new Facet(null);FacetAffiliate.prototype.render=function(node)
{var value=this.getValue();if(!value)
return false;if(!node)
{var node=document.createElement("span");node.className="facet_affiliate";this.setNode(node);}
node.appendChild(new Link({href:value.url,popup:true,fnc:function(){trackEvent(['Affiliate',this.widget.result.entityID,this.widget.getValue().name])},widget:this,text:'<small class="ico"></small>'+value.label,className:value.name}));return node;}
function FacetTitle(result,header)
{this.header=(header?header:false);this._construct('title',result);}
FacetTitle.prototype=new Facet(null);FacetTitle.prototype.useAnchor=true;FacetTitle.prototype.getLabel=function()
{return this.getResult().facets.date!=null?"name of event":"name of activity/place";}
FacetTitle.prototype.imbue=function()
{$(this.getNode()).find('a').data('result',this.result);if(this.result.isSponsored)
{$(this.getNode()).find('a').attr("target","_blank");$(this.getNode()).find('a').click(function()
{var result=$(this).data('result');trackEvent(["sponsored_result_title",result.displayFacet("display_url"),result.entityID.toString()]);trackOffsite(result);});}
else
{$(this.getNode()).find('a').click(function()
{var result=$(this).data('result');trackOffsite(result);trackEvent(["search_result","title",result.displayFacet("display_url")]);});}}
FacetTitle.prototype.getTip=function()
{return this.getResult().facets.date!=null?"Rolling Stones at the Palladium, Picasso Exhibit at Modern Museum":"mike's diner, borderland state park, whispy balloon tours";}
FacetTitle.prototype.render=function(node,len)
{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");if(len)
var title=this.getValue().truncate(len,'...',true);else
var title=this.getValue();if(!this.useAnchor)
sourceURL=undefined;var link=(sourceURL!=undefined?document.createElement("a"):document.createElement("span"));link.href=this.result.getLink();link.result=this.result;if(this.result.isSponsored)
{link.href=sourceURL;link.target="_blank";var displayURL=this.result.displayFacet("display_url");var entityID=this.result.entityID.toString();$(link).click(function()
{trackEvent(["sponsored_result_title",displayURL,entityID]);trackOffsite(this.result);});}
else
{$(link).click(function()
{trackOffsite(this.result);trackEvent(["search_result","title",this.result.displayFacet("display_url")]);});}
$(link).html(title.htmlentities());$(link).attr("title",this.getValue());$(node).append(link);this.setNode(node);return node;}
function PsudoFacet(name,result)
{}
PsudoFacet.prototype=new Facet(null);PsudoFacet.prototype._construct=function(name,result)
{if(result)
{this.name=name;this.result=result;objects.push(this);}}
function FacetFacebook(result)
{this._construct('facebook',result);}
FacetFacebook.prototype=new PsudoFacet(null);FacetFacebook.prototype.render=function(fb)
{if(Goby.conf('USE_LOGIN'))
{this.link=new Link({widget:this,className:"save-node",text:"<span>save to a list</span>",fnc:function(e)
{trackEvent([PAGE_ID,'save_to_start']);if(Goby.requireLogin($(this),e,'bookmark'))
{var saveModule=new BookmarkSelect({container:this.parentNode,className:"selectGhost",id:"save-result-ghost",autoPop:true},this.widget.getResult());$(this.parentNode).addClass('open');saveModule.closeMethod="removeFrom";saveModule.addOption(null,{label:"SAVE",value:-1});saveModule.display();saveModule.show();}}});var span=document.createElement('span');span.className='save-node-wrapper';span.appendChild(this.link);this.setNode(span);return span;}
else
return $("<small></small>")[0];}
function FacetShare(result)
{this._construct('share',result);}
FacetShare.prototype=new PsudoFacet(null);FacetShare.prototype.render=function()
{this.link=new Link({widget:this,className:"share-node",text:"<span>share this</span>",fnc:function(e)
{trackEvent([PAGE_ID,'save_to_share']);var shareModule=new Selector({container:this.parentNode,className:"selectGhost",id:"TabGhost"},{callbackObject:this.widget,callbackMethod:"share"});$(this.parentNode).addClass('open');shareModule.closeMethod="removeFrom";shareModule.addOption(null,{label:'<span class="facebook"><small class="icon"></small><span class="txt">facebook</span></span>',value:'facebook'});shareModule.addOption(null,{label:'<span class="twitter"><small class="icon"></small><span class="txt">twitter</span></span>',value:'twitter'});shareModule.addOption(null,{label:'<span class="email"><small class="icon"></small><span class="txt">email</span></span>',value:'email'});shareModule.display();shareModule.show();}});var span=document.createElement('div');span.className='share-node-wrapper';span.appendChild(this.link);this.setNode(span);return span;}
FacetShare.prototype.share=function(option)
{var title=this.result.title.getValue();var url=Goby.conf('url.goby')+this.result.url;this.reRender();switch(option.value)
{case"email":trackEvent([PAGE_ID,'share_email'],2);var body="I found "+title+" here on Goby.com:\n"
+url+"\n\n"
+"This site has lots of great ideas for things to do. You should check it out!";window.location="mailto:?subject="+encodeURIComponent(title)+"&body="
+encodeURIComponent(body);return false;break;case"facebook":postEntityToNewsFeed({link:url,title:title});return false;break;case"twitter":var href="http://twitter.com/?status="+encodeURIComponent("Check this out (via Goby.com): "+title+"\n"+url);window.open(href,"_blank");trackEvent([PAGE_ID,'share_twitter_old'],2);return false;break;default:break;}}
function FacetActionMenu(result)
{this._construct('actionMenu',result);}
FacetActionMenu.prototype=new PsudoFacet(null);FacetActionMenu.prototype.className='facet_actionmenu';FacetActionMenu.prototype.render=function()
{var wrapper=document.createElement('div');wrapper.className=this.className;wrapper.style.display='none';this.link=new Div({className:"actionmenu_button",text:"<span>take action</span>"});wrapper.appendChild(this.link);this.setNode(wrapper);this.node.admin=this;$(this.node).hover(function()
{$(this.admin.link).addClass('open');if(!this.actionMenu)
{this.actionMenu=new WidgetActionMenu({container:this,className:"widget-content",autoPop:true},this.admin.getResult());this.actionMenu.display();this.actionMenu.show();}
else
{this.actionMenu.show();}},function()
{$(this.admin.link).removeClass('open');this.actionMenu.hide();});return wrapper;}
FacetActionMenu.prototype.collapse=function()
{this.hide();$(this.link).removeClass('open');this.link.actionMenu.hide();}
function FacetIndex(result)
{this._construct('index',result);}
FacetIndex.prototype=new PsudoFacet(null);FacetIndex.prototype.className='entry_index';FacetIndex.prototype.render=function()
{var node=document.createElement("div");node.className="entry_index";if(this.result.facets.location==null||this.result.facets.location.lat==null)
$(node).addClass("pin_none");else
$(node).addClass("pin_normal");node.innerHTML="<span>"+(this.result.showieIndex)+"</span>";return node;}
function FacetDrag(result)
{this._construct('drag',result);}
FacetDrag.prototype=new PsudoFacet(null);FacetDrag.prototype.render=function()
{$(this.result.resultTemplate).addClass("draggable");var node=$("<div class='dimples'></div>");return node.get(0);}
function FacetLink(result,header)
{this.header=(header?header:false);this._construct('link',result);}
FacetLink.prototype=new Facet(null);FacetLink.prototype.className='ticket-link';FacetLink.prototype.imbue=function()
{$(this.getNode()).click(function(){trackEvent(["search_result","stubhub_tickets"]);});};FacetLink.prototype.render=function(node)
{if(this.getValue())
{var link=new Link({href:this.getValue(),text:"<span>link</span>",fnc:function(){trackEvent(["search_result","stubhub_tickets"]);}});link.className="ticket-link";this.setNode(link);return link;}}
var ResultCtrl={};ResultCtrl.Pagination=function(container,params,resultSet){this.__run(container,params,resultSet)}
ResultCtrl.Pagination.prototype=Class({impliments:null,vars:{resultCnt:0,resultMax:0,viewscopeAmt:3},_construct:function(container,data,resultSet)
{this.nodes={};this.container=container;this.resultSet=resultSet;this.resultCnt=data.filteredResults;this.resultMax=data.totalResults;this.resultsPerPage=data.resultsPerPage;this.resultType=data.resultType;if(document.getElementById("drill_current"))
{this.nodes={'current':document.getElementById("drill_current"),'max':document.getElementById("drill_max")}}
else
{this.nodes={'current':new Span({id:"drill_current"}),'max':new Span({id:"drill_max"})};this.container.appendChild(new Div({id:"drilldown",nodes:[this.nodes.current,this.nodes.max]}));}
this.nodes.pgHead=(data.headContainer?data.headContainer:null);},methods:{hide:function()
{for(var i in this.nodes)
if(i!="headers")
$(this.nodes[i]).hide();$("#resultToolbar").hide();this.removeResults();},show:function()
{$("#resultToolbar").show();for(var i in this.nodes)
if(i!="headers")
$(this.nodes[i]).show();this.renderPages();},setCurrentPage:function(page)
{if(!window.getParameter('page').isDeclared())
window.setParameter(new Parameter('page',null,page));this.currentPage=this.resultSet.getCurrentPage();},getCurrentPage:function()
{return this.resultSet.getCurrentPage();},getResultCount:function(){return this.resultSet.getResultCount(this.resultType);},removeResults:function()
{if(this.container.childNodes.length)
{for(var i=(this.container.childNodes.length-1);i>=0;i--)
{try
{var node=this.container.childNodes[i];if(node.remove!=null)
{node.remove();}
else
this.container.removeChild(node);}
catch(e)
{konsole.log(e);}}}
this.container.innerHTML='';},renderPages:function()
{var page=this.getCurrentPage();var finalPage=this.getPageCnt()-1;this.removeResults();var offset={right:page-this.viewscopeAmt,left:finalPage-(page+this.viewscopeAmt)};var viewscope={left:page-(offset.left<0?this.viewscopeAmt+Math.abs(offset.left):(offset.right<0?this.viewscopeAmt-Math.abs(offset.right):this.viewscopeAmt)),right:page+(offset.right<0?this.viewscopeAmt+Math.abs(offset.right):(offset.left<0?this.viewscopeAmt-Math.abs(offset.left):this.viewscopeAmt))};if(viewscope.left<0)
viewscope.left=0;if(viewscope.right>finalPage)
viewscope.right=finalPage;this.container.appendChild(new PG.Node({value:page-1,label:"prev",set:this}));this.container.appendChild(new PG.Node({value:0,label:1,set:this}));if(viewscope.left>1)
this.container.appendChild(new PG.Elipsis({set:this}));for(var index=viewscope.left;index<=viewscope.right;index++)
if(index>0&&index<(this.getPageCnt()))
this.container.appendChild(new PG.Node({value:index,label:index+1,set:this}));if(viewscope.right<(finalPage-1))
this.container.appendChild(new PG.Elipsis({set:this}));if(viewscope.right!=finalPage)
this.container.appendChild(new PG.Node({value:finalPage,label:finalPage+1,set:this}));this.container.appendChild(new PG.Node({value:page+1,label:"next",set:this}));this.updateHeaders();},updateHeaders:function()
{if(!this.nodes.headers)
{this.nodes.headers={'prev':new PG.Node({value:this.getCurrentPage()-1,label:"<small>&#171;</small> prev",set:this}),'next':new PG.Node({value:this.getCurrentPage()+1,label:"next <small>&#187;</small>",set:this})}
try{this.nodes.pgHead.appendChild(this.nodes.headers.prev);}catch(e){}
try{this.nodes.pgHead.appendChild(this.nodes.headers.next);}catch(e){}}
else
{this.nodes.headers.prev.update(this.getCurrentPage()-1);this.nodes.headers.next.update(this.getCurrentPage()+1);}},selectPage:function(page)
{this.setCurrentPage(page);this.renderPages();this.setDrilldown();return page;},update:function(parameter)
{return this.selectPage(parameter.serialize());},resetPages:function(len,pg)
{len=(len!=null?len:this.resultMax);this.resultCnt=len;this.setPages();this.selectPage(0);},groomPage:function(page)
{if(!isInteger(page))
page=0;var startIndex=page*this.resultsPerPage;var initPg=page;var resultLength=this.getResultCount();if(startIndex>=resultLength)
{while(startIndex>=resultLength)
{var page=parseInt(page)-1;var startIndex=page*this.resultsPerPage;}}
this.setCurrentPage(page);return page;},getPageCnt:function()
{return Math.ceil(this.getResultCount()/this.resultsPerPage);},setDrilldown:function()
{var cnt=this.getResultCount();var page=this.getCurrentPage();if(this.resultMax!=cnt)
$(this.nodes.max).addClass("fltr");else
$(this.nodes.max).removeClass("fltr");if(cnt>0)
{var start=(page*this.resultsPerPage)+1;var end=(parseInt(start)+parseInt(this.resultsPerPage))-1;if(end>cnt)
end=cnt;var txt=start+" - "+end;}
else
var txt=0;$(this.nodes.current).text(txt);$(this.nodes.max).text(cnt);},updateResults:function(results)
{return this.getPageResults(results,this.getCurrentPage());},getPageResults:function(results,page)
{var 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;}}
return resultSet;},submit:function(pg)
{this.resultSet.getResults({page:pg.page.serialize()});}},_destruct:function()
{this.container=null
this.nodes=null;this.resultSet=null;this.removeResults();Goby._kill(this);}});var PG={};PG.Node=function(params)
{params.className="pg_item "+params.label;this.v=params.value;this.label=params.label;this.set=params.set;var node=this._construct(params);node.update(params.value);return node;}
PG.Node.prototype=new LI(null,true);PG.Node.prototype.render=function()
{this.link=new Link({text:this.label,widget:this,fnc:function(){this.widget.select(this);}});this.appendChild(this.link);};PG.Node.prototype.select=function(anchor)
{if(!this.inert)
{var prm=this.getParameters();window.compileLink(prm,anchor);if(this.parentNode.id=="pgFoot")
$(window).scrollTo($("#wrapper"));this.set.submit(prm);}}
PG.Node.prototype.getParameters=function()
{return{'page':new Parameter('page',null,this.v)};}
PG.Node.prototype.update=function(value)
{if(value<0||value>=(this.set.getPageCnt()))
{$(this).addClass('inert');this.inert=true;}
else if(value==this.set.getCurrentPage())
{$(this).addClass('sel');$(this).removeClass('inert');}
else
{this.inert=false;$(this).removeClass('inert');$(this).removeClass('sel');}
this.v=value;}
PG.Node.prototype.remove=function()
{this.link._destruct();this.link=null;this.set=null;if(this.parentNode)
this.parentNode.removeChild(this);this._destruct();}
PG.Elipsis=function(params)
{params.className="elipse";params.text="...";this.v=params.value;this.label=params.label;this.set=params.set;return this._construct(params);}
PG.Elipsis.prototype=new LI(null,true);ResultCtrl.SortMgr=function(param0,param1,param2,param3){this.__run(param0,param1,param2,param3)};ResultCtrl.SortMgr.prototype=Class({inherits:null,vars:{data:[],format:'tab',select:null,container:null,currentSort:null},_construct:function(container,params,resultSet)
{this.resultSet=resultSet;if(this.resultSet.sortFormat)
{this.format=this.resultSet.sortFormat;this.selector=new Selector({container:container,className:"selectGhost",id:"sortGhost"},{callbackObject:this,callbackMethod:"selectOptionByID"});}
try
{if(container!=null)
{if(this.format!="select")
{container.appendChild($("<legend>sort by</legend>").get(0));this.container=new UL({id:"sortContent"});container.appendChild(this.container);container=null;}}
if(params)
{this.load(params);if(this.selector!=null)
this.selector.display();}}
catch(e)
{Goby.reportError(e);}},methods:{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;}},selectOptionByID:function(data)
{try
{var option=this.getSort(data.value);if(option!=null)
option.select_();}
catch(e){}},update:function(parameter)
{var params=parameter.serialize();var sort=this.getSort(params.label);if(sort)
sort.select(params.dir);},removeOption:function(node)
{switch(this.format)
{case"select":this.selector.removeOption(node.node_id);break;default:this.container.removeChild(node.sortContainer);break;}},addOption:function(node)
{switch(this.format)
{case"select":var option=this.selector.addOption(null,{value:node.node_id,label:node.label});if(this.getCurrent()===node)
option.select();break;default:if(this.container)
this.container.appendChild(node.sortContainer);break;}},addSort:function(obj)
{obj.mgr=this;if(obj.isDefault)
{if(this.getCurrent()==null)
{if(obj.forced)
{obj.select(obj.dir);}
else
obj.update();this.setCurrent(obj);}}
if(!obj.isHidden())
obj.display();this.data[obj.node_id]=obj;},close:function()
{for(var i in this.data)
this.data[i].hide();if(this.container)
this.container.remove();},_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(){$(this.container).hide();},show:function()
{$(this.container).show();if(this.format=="select")
this.selector.display();},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;}},updateResults:function(results)
{var currentSort=this.getCurrent();currentSort.results=results;return this.sortResults(currentSort);},sortResults:function(sort)
{myCor=sort.coordinates;resultset=sort.results;resultset.sort(function(a,b)
{switch(sort.method)
{case"relevance":case"Relevance":var r1=a;var r2=b;var b=r1.score;var a=r2.score;konsole.log(a,r1,b,r2);break;case"keywordRelevance":var a=parseInt(a.relevance);var b=parseInt(b.relevance);break;case"votes":var votes_a=a.getVotes();var votes_b=b.getVotes();votes_a.up=Math.abs(votes_a.up);votes_b.up=Math.abs(votes_b.up);votes_a.down=Math.abs(votes_a.down);votes_b.down=Math.abs(votes_b.down);var b=(votes_a.up+votes_a.down)*((votes_a.up+1)/(votes_a.down+1));var a=(votes_b.up+votes_b.down)*((votes_b.up+1)/(votes_b.down+1));break;case"distance":var r1=a;var r2=b;if(!r1.isPlottable()&&!r2.isPlottable())
return 0;else if(!r2.isPlottable())
return-1;else if(!r1.isPlottable())
return 1;var a=r1.getDistance();var b=r2.getDistance();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;},getResults:function(data)
{return this.resultSet.getResults(data);},load:function(data)
{for(index in data)
{var sortData=data[index];sortData.node_id=index;var sortItem=new ResultSortItem(sortData,this);this.addSort(sortItem);try
{if((sortData.isDefault)&&(window.getParameter("sort"))&&(!window.getParameter("sort").isDeclared()))
{sortItem.select('ASC');window.setParameter(sortItem.getParameters(1).sort,"sort");}}
catch(e)
{}}
if(window.getParameter("sort")&&window.getParameter("sort").isDeclared())
{var sort=window.getParameter("sort").serialize();var sort2=this.getSort(sort.label);if(sort2)
sort2.select(sort.dir);}
if(!this.getSort("distance"))
{var distanceObject=new ResultSortItem
({method:"distance",dir:"ASC",label:"distance",node_id:"distance",hidden:true,noreverse:true},this);this.addSort(distanceObject);}
this.addSort(new ResultSortItem
({method:"keywordRelevance",dir:"ASC",label:"keywordRelevance",node_id:"keywordRelevance",hidden:true,noreverse:true},this));}}});function ResultSortItem(params,mgr)
{this.forced=false;this.mgr=mgr;this.hidden=false;for(var i in params)
this[i]=params[i];if(!this.dir)
this.dir="ASC";this.sortContainer=null;this.default_dir=this.dir.toString();this.parameters={"sort":new Parameter("sort",null,{label:this.node_id,dir:this.dir}),'page':new Parameter("page",0)};}
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.removeOption(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);this.sortContainer=sortContainer;this.mgr.addOption(this);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.link).addClass("sel");$(this.dirbox).addClass(dir);}
ResultSortItem.prototype.updateDirection=function()
{var currentObj=this.mgr.getCurrent();if(currentObj==null)
{this.select(this.dir);this.mgr.setCurrent(this);}
else if((currentObj===this)&&this.mgr.format!="select")
{this.invert();}
else if(currentObj!==this)
{if(currentObj!=null)
currentObj.reset();this.select(this.dir);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}),'page':new Parameter("page",1)};}
ResultSortItem.prototype.getParameters=function(format)
{switch(format)
{case 2:var params={};for(var i in this.parameters)
params[i]=this.parameters[i].serialize();return params;break;case 1:default:return this.parameters;}}
ResultSortItem.prototype.serialize=function()
{var params={};for(var i in this.parameters)
params[i]=this.parameters[i].serialize();return params;}
ResultSortItem.prototype.isHidden=function()
{if((this.hidden!=null)&&(this.hidden))
return true;else
return false;}
ResultSortItem.prototype.select_=function()
{try
{this.updateDirection();if(this.link)
window.compileLink(this.getParameters(1),this.link);else
{window.bookmarkPage(this.getParameters(1));}
trackEvent(["sort_box",this.node_id]);this.mgr.getResults(this.serialize());}
catch(e)
{Goby.reportError(e);}}
ResultSortItem.prototype.createLink=function()
{this.link=new Link({fnc:function()
{this.widget.select_()},text:"<span>"+this.label.toLowerCase()+"</span>",href:"#sort:"+this.label.toLowerCase(),widget:this});this.link.select=function(dir){this.widget.select(dir);}
this.dirbox=new Link({className:"dir",widget:this,fnc:function(){this.widget.select_()}});this.link.appendChild(this.dirbox);return this.link;}
ResultCtrl.FilterMgr=function(param0,param1,param2,param3){this.__run(param0,param1,param2,param3)};ResultCtrl.FilterMgr.prototype=Class({_construct:function(container,params,resultSet)
{this.filters=new List();this.container=container;this.resultSet=resultSet;this.activeFilters={};this.init(params);},inherits:null,vars:{resultCnt:0},methods:{init:function(params)
{try
{var values=this.resultSet.getParameter('filters').serialize();for(var i in params)
{if(i!='radius')
{var filter=this.loadFilter(params[i],values[i]);if(values[i])
this.addFilter(filter);}}}
catch(e){Goby.reportError(e);}},hide:function(){$(this.container).hide();},show:function(){$(this.container).show();},update:function(parameter)
{var values=parameter.serialize();this.filters.reset();while(this.filters.valid())
{var filter=this.filters.getCurrent();var i=this.filters.getIndex();var value=values[filter.field]?values[filter.field]:false;if(!value&&this.isActive(filter,i))
{this.removeFilter(filter,i);}
else if(value)
{filter.updateFilter(value,i);if(!this.isActive(filter,i))
this.addFilter(filter);}
this.filters.next();}},isActive:function(filter,index){return(this.activeFilters[filter.label]===filter?true:false)},getBookmark:function()
{return this.bookmark;},loadFilter:function(_filter,value)
{if(_filter.label=="radius")
return false;else
{_filter.value=value;var filter=new ResultFilter[_filter.object](_filter,this);this.filters.add(_filter.label,filter);filter.display();return filter;}},getFilterContainer:function()
{return this.container;},getResults:function(filter)
{try
{this.addFilter(filter);return this.commitFilters();}
catch(e)
{Goby.reportError(e);}},applyFilter:function(filter)
{this.getResults(filter);},addFilter:function(filter)
{this.activeFilters[filter.getLabel()]=filter;},removeFilter:function(filter,index)
{filter.resetInputs(1);this.activeFilters[index?index:filter.label]=null;},clearFilter:function(filter)
{this.removeFilter(filter);},clearFilters:function()
{if(this.activeFilters.length>0)
return false;for(var i in this.activeFilters)
this.removeFilter(this.activeFilters[i],i);this.activeFilters={};if(this.resultSet.setResultGroup)
this.resultSet.setResultGroup(ResultGroup.FILTER,this.resultSet.getResultGroup(ResultGroup.ALL));this.commitFilters();},setParameter:function()
{},commitFilters:function()
{var data={'filters':this.compileFilters(),'page':new Parameter('page',1)}
var parameters={"filters":data.filters.serialize(),"page":data.page.serialize()};this.bookmark=window.bookmarkPage(data);this.resultSet.getResults(parameters);},serializeFilters:function(filter)
{return null;},compileFilters:function()
{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)
{konsole.log('exception!',e);}}}
return new Parameter("filters",null,dset);},updateResults:function(results)
{return this.filterResults(results);},filterResults:function(results)
{for(var f in this.activeFilters)
if(this.activeFilters[f]!=null)
{results=this.activeFilters[f].filterResults(results);}
this.resultCnt=results.length;return results;},getResultCount:function(){return(this.resultCnt?this.resultCnt:this.resultSet._results.length);}}});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;}}
var ResultFilter={};ResultFilter.Result=function(module,resultSet)
{if(resultSet!=null)
this._construct(module,resultSet);}
ResultFilter.Result.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;},getValue:function()
{return this.value;},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;},getField:function()
{return this.field;},display:function()
{return null;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;$(this.resultSet.getFilterContainer(this)).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(this);break;default:this.resultSet.getResults(this);}},setParameters:function()
{},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!=null&&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()
{konsole.log('this?');this.resultSet.addFilter(this);return this.resultSet.serializeFilters();},_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);}}
var RESULT_FACET_MAP={photo:"FacetPhoto",title:"FacetTitle",description:"FacetDescription",categorySet:"FacetCategorySet",rating:"FacetRating",overallRating:"FacetOverallRating",price:"FacetPrice",date:"FacetDate",link:"FacetLink",address:"FacetAddress",action:"FacetActions",index:"FacetIndex",map:"FacetMap",pixel:"FacetPixel",sponsormark:"FacetSponsormark",votes:"FacetVotes",settings:"FacetSettings",comments:"FacetComments",facebook:"FacetFacebook",share:"FacetShare",actionMenu:"FacetActionMenu",address:"FacetAddress",affiliate:"FacetAffiliate",venue:"FacetVenue",dateBar:"FacetDateBar"};var FACET_NUM_SPAN='spn';var FACET_STRING='str';var FACET_NUMBER='int';var FACET_PRICE='price';var FACET_LOCATION='location';var FACET_OVERALL_RATING='overallRating';var FACET_DATE='date';var FACET_PRICE='price';var FACET_RATING='rating';var FACET_CATEGORIES='categorySet';var FACET_PHOTOS='photos';var FACET_ADDRESS='address';var FACET_DESCRIPTION='description';var FACET_FACEBOOK='facebook';var FACET_SHARE='share';var FACET_ACTIONMENU='actionMenu';var FACET_MAP='map';var FACET_PIXEL='pixel';var FACET_SPONSORMARK='sponsormark';var FACET_TITLE='title';var FACET_INDEX='index';var FACET_PHONE='phone';var FACET_PHOTO='photo';var FACET_DISTANCE='distance';var FACET_COMMENTS='comments';var FACET_VOTES='votes';var FACET_SETTINGS='settings';var FACET_LINK='link';var FACET_AFFILIATE='affiliate';var FACET_VENUE='venue';function Result(resultJson,resultSet,node)
{if(node)
{}
else if(!resultJson)
return null;this._construct(resultJson,resultSet);}
Result.prototype={_construct:function(resultJson,resultSet)
{this.tpl=[];this.facetObjects=new List();for(index in resultJson)
this[index]=resultJson[index];objects.push(this);if(typeof(this.facets)!=='undefined'&&this.facets.date!=null)
this.dateSensitive=true;this.resultTabs=null;if(resultSet)
this.setResultSet(resultSet);this.isSponsored=this.checkSponsored();this.nodes={};},type:"result",action:"edit",user:null,isSponsored:null,getUser:function()
{return this.user;},setUser:function(user)
{this.user=user;},isOwner:function(user)
{if(user!=null&&this.getUser()!=null&&this.getUser().getID()==user.getID())
{return true;}
else
return false;},getID:function()
{return this.id;},getDistance:function()
{if(this.facets.location!=null)
{return getDistance(this.facets.location,this.resultSet.getLocation());}
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(RESULT_FACET_MAP[id])
{var node=eval("new "+RESULT_FACET_MAP[id]+"(this);");}
else
{var node=new Facet(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);},hasFacet:function(id)
{return(this.facets[id]!=null?true:false);},renderNode:function(entry)
{if(!entry)
return;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)
{if(entry.facets[f].facets){var chnode=document.createElement((entry.facets[f].tag!=null?entry.facets[f].tag:'div'));chnode.className=(entry.facets[f].className?entry.facets[f].className:'');for(var i in entry.facets[f].facets)
{var facet=this.fetchFacet(entry.facets[f].facets[i]);var _node=facet.render();(_node?chnode.appendChild(_node):'');}
(chnode?node.appendChild(chnode):'');}else{var facet=this.fetchFacet(entry.facets[f]);var _node=facet.render();(_node?node.appendChild(_node):'');}}}
if(entry.alias)
this[entry.alias]=node;return node;},getNode:function(index)
{return this.nodes[index];},getImageType:function()
{return this.resultSet.getImageMode();},updatePhoto:function(format)
{var photo=this.fetchFacet('photo');photo.reRender({type:format});try
{var desc=this.fetchFacet('description');desc.truncate(this.resultSet.getMode()=="small"?desc.shortDesc:desc.longDesc);desc.reRender();}
catch(e)
{Goby.reportError(e);}},getModule:function()
{if(!this.module&&this.resultSet.getModule)
this.module=this.resultSet.getModule((this.facets.categoryID?this.facets.categoryID:false),this.type,this.displayFacet("display_url"));return this.module;},displayObject:function()
{try
{this.module=this.getModule();this.resultTemplate=this.renderNode(this.module.scaffold);}
catch(e)
{Goby.reportError(e);}
var title=this.fetchFacet('title');var titleNode=title.getNode();if(titleNode)
{var facebook=this.fetchFacet('facebook');if(facebook)
{var facebookNode=facebook.getNode();if(facebookNode)
titleNode.appendChild(facebookNode);}}
this.nodes.tpl=this.resultTemplate;this.nodes.content=this.entryContent;this.resultTemplate.result=this;this.resultTemplate.id=this.id;var photo=this.fetchFacet('photo');if((!this.facets.description)&&(!photo.hasValue()))
$(this.entryContent).addClass("noilism");else if(!photo.hasValue())
$(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);if(Goby.conf('result.tabs'))
this.resultTabs=new ResultTabMgr(this);this.resultSet.getContainer().appendChild(this.resultTemplate);if(this.resultSet.ctrl&&this.resultSet.ctrl.sort.getCurrent().node_id=="date")
this.fetchFacet('dateBar').render();},unhover:function()
{this.lowlightName();this.hideName();this.getFacetObject('actionMenu').collapse();},hover:function()
{this.highlightName();this.showName();this.getFacetObject('actionMenu').show();},display:function()
{if(this.deleted)
return false;this.displayObject();if(this.isPlottable())
{$(this.resultTemplate).hover(function()
{this.result.hover();},function()
{this.result.unhover();});if(Goby.conf('result.tabs')&&this.resultTabs!=null)
this.resultTabs.displayLinks();}
return this.resultTemplate;},removeFacet:function(facet)
{this.facetObjects.remove(facet.name);},getComments:function()
{if(Goby.get("comments")!=null)
return Goby.get("comments")[this.getID()]!=null?Goby.get("comments")[this.getID()]:0;else
return 0;},opentab:function(label)
{var tab=this.resultTabs.getTab(label);if(tab!=null)
tab.open();},deleted:false,remove:function(perm)
{if(this.hideName!=null)
this.hideName();if(this.marker)
{try
{this.getMap().removeMarker(this.marker);if(this.marker)
this.marker._destruct();this.marker=null;}
catch(e){}}
if(this.dateMenuBar)
{try
{this.dateMenuBar.remove();}
catch(e){}}
this.module=null;this.facetObjects.reset();while(this.facetObjects.valid())
{var cur=this.facetObjects.getCurrent();cur.remove();this.facetObjects.next();}
this.resultTemplate.result=null;$(this.resultTemplate).remove();if(this.resultTabs!=null)
this.resultTabs._destruct();this.resultTemplate=null;return true;if(this.resultTemplate!=null&&this.resultTemplate.parentNode!=null)
this.resultTemplate.parentNode.removeChild(this.resultTemplate);return false;},_destruct:function()
{this.remove();for(var i in this)
this[i]=null;},hideName:function()
{try{this.getMarker().hideName(this);}catch(e){}},showName:function()
{try{this.getMarker().showName(this);}catch(e){}},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"";}},setLast:function()
{if(this.resultTemplate)
$(this.resultTemplate).addClass('last');},getLink:function()
{return this.entityLink;},getMap:function()
{if(this.map)
return this.map;else
return this.resultSet.getMap();},getMarker:function(point,hi)
{if(this.marker==null)
this.marker=new Marker.Result({result:this,map:this.getMap(),hi:hi,point:point});return this.marker;},highlightName:function()
{if(this.marker)
{this.getMap().closeEWindows();this.marker.hilight(this);}},lowlightName:function()
{if(this.marker)
this.marker.lolight(this);},closeInfoWin:function()
{this.marker.closeWindow();},isPlottable:function()
{if(this.isSponsored)return false;var loc=(this.facets.location!=null?this.facets.location:null);return(loc!=null&&loc.lat&&loc.lng?true:false);},checkSponsored:function()
{if(this.type=='sponsoredResult')
return true;return false;},openInfoWin:function()
{if(this.marker){this.selectMarker();}},selectMarker:function()
{this.getMarker().openWindow(this);},update:function(facets)
{this.facets=facets;$main=$("#wrapper");$main.children().remove();$main.append(new Div({id:"main",text:facets.confirmation.tpl}));$(window).scrollTo($main,500,'easeOutSine');},renderUpdate:function(data)
{},cancel:function()
{if(this.resultSet.url)
this.toggleMode('default');else
{window.open(Goby.conf('path.base'),'_self');}},getLocation:function()
{return new Location(this.facets.location);},edit:function()
{window.location=Goby.conf('path.base')+"/edit-listing/"+this.getID()+"/"+this.facets.title.urlEncode();},getPoint:function()
{return new google.maps.LatLng(this.facets.location.lat,this.facets.location.lng);},setMarker:function(marker)
{if(this.marker)
this.marker.remove();this.marker=marker;}}
function DummyResult(type)
{switch(type)
{case"event":var facets={title:'',address:'',date:'',phone:'',website:'',description:'',categorySet:{}};break;default:var facets={title:'',address:'',phone:'',website:'',description:'',categorySet:{}};break;}
var data={facets:facets}
var resultSet={url:false};this._construct(data,resultSet);}
DummyResult.prototype=new Result(null);DummyResult.prototype.action="new";function EventResult(params,resultSet,node)
{if(node)
{}
else if(!params)
return null;this._construct(params,resultSet);}
function SponsoredResult(resultJson,resultSet,node)
{if(node)
{}
else if(!resultJson)
return null;this._construct(resultJson,resultSet);}
SponsoredResult.prototype=new Result(null);SponsoredResult.prototype.type='sponsoredResult';SponsoredResult.prototype.getModule=function()
{var result={tabs:{"photos":"photos"},tpl:{body:false},misc:{className:'sponsored'},structure:{className:'entry_content',children:{'photo':{'className':"sponsored_photo",'facets':{0:FACET_PHOTO}},'marks':{'className':"sponsormark",'facets':{0:FACET_SPONSORMARK}},'facet_set':{'className':'info','facets':{0:FACET_TITLE,1:{'className':'facet_address_container','tag':'div','facets':{0:FACET_ADDRESS,1:FACET_PHONE,2:FACET_PIXEL}},2:{'className':'facet_catrating_container','tag':'div','facets':{0:FACET_CATEGORIES}},3:FACET_DESCRIPTION}}}}};result.structure.alias="entryContent";var scaffold={alias:'resultTemplate',className:"entry"+(result.misc.className?" "+result.misc.className:'')}
scaffold.children={};scaffold.children['content']=result.structure;result.scaffold=scaffold;return result;}
function StaticResult(json,resultSet,node)
{this._construct(json,resultSet);this.resultTemplate=$('#entry_'+this.getID()+":not(.sponsored)").get(0);}
StaticResult.prototype=new Result(null);StaticResult.prototype.obj='static';StaticResult.prototype.display=function()
{var node=this.fetchFacet('title').getNode();this.module=this.resultSet.getModule((this.facets.categoryID?this.facets.categoryID:false),this.type,this.displayFacet("display_url"));this.renderNode(this.module.scaffold);if(this.isPlottable())
{this.resultTemplate.result=this;$(this.resultTemplate).hover(function()
{this.result.hover();},function()
{this.result.unhover();});}}
StaticResult.prototype.renderNode=function(entry)
{if(!entry)
return;var node=$(this.resultTemplate).find('.'+entry.className).get(0);if(entry.children)
{for(var i in entry.children)
{if(entry.children[i].facet)
{var facet=this.fetchFacet(i);if(facet.getNode())
{facet.imbue();var facetNode=facet.getNode();}
else
{var facetNode=facet.render();if(facetNode)
{if(neighbor)
$(facetNode).insertAfter(neighbor);else
node.appendChild(facetNode);}}
var neighbor=facetNode;}
this.renderNode(entry.children[i]);}}
if(entry.facets)
{for(var f in entry.facets)
{var facet=this.fetchFacet(entry.facets[f]);if(facet.getNode())
{facet.imbue();var facetNode=facet.getNode();}
else
{if(entry.facets[f].facets)
{this.renderNode(entry.facets[f]);}
else
{var facetNode=facet.render();if(facetNode)
{if(neighbor)
$(facetNode).insertAfter(neighbor);else
node.appendChild(facetNode);}}}
var neighbor=facetNode;}}
if(entry.alias&&node&&entry.alias!="resultTemplate")
this[entry.alias]=node;return node;}
function StaticSponsoredResult(json,resultSet,node)
{this._construct(json,resultSet);this.resultTemplate=$('#sponsored_'+this.getID()).get(0);}
StaticSponsoredResult.prototype=new SponsoredResult(null);StaticSponsoredResult.prototype.obj='static';StaticSponsoredResult.prototype.display=function()
{var node=this.fetchFacet('title').getNode();this.module=this.getModule();this.renderNode(this.module.scaffold);}
StaticSponsoredResult.prototype.renderNode=function(entry)
{if(!entry)
return;var node=$(this.resultTemplate).find('.'+entry.className).get(0);if(entry.children)
{for(var i in entry.children)
{if(entry.children[i].facet)
{var facet=this.fetchFacet(i);if(facet.getNode())
{facet.imbue();var facetNode=facet.getNode();}
else
{var facetNode=facet.render();if(facetNode)
{if(neighbor)
$(facetNode).insertAfter(neighbor);else
node.appendChild(facetNode);}}
var neighbor=facetNode;}
this.renderNode(entry.children[i]);}}
if(entry.facets)
{for(var f in entry.facets)
{var facet=this.fetchFacet(entry.facets[f]);if(facet.getNode())
{facet.imbue();var facetNode=facet.getNode();}
else
{if(entry.facets[f].facets)
{this.renderNode(entry.facets[f]);}
else
{var facetNode=facet.render();if(facetNode)
{if(neighbor)
$(facetNode).insertAfter(neighbor);else
{try{node.appendChild(facetNode);}catch(e){}}}}}
var neighbor=facetNode;}}
if(entry.alias&&node&&entry.alias!="resultTemplate")
this[entry.alias]=node;return node;}
var TABS={MORE_INFO:'1',PHOTOS:"2",GENERAL:"1",DIRECTIONS:"3",REVIEWS:"6",NEARBY:"7",EVENTS:"10",RESTAURANTS:"9",HOTELS:"8"}
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.hideLinks=function()
{if(this.links!=null)
$(this.links).remove();}
ResultTabMgr.prototype.displayLinks=function()
{this.links=new UL({className:"entry_links"});set=[];for(var tabID in this.module.tabs)
{set.push(tabID);}
if(/chrome/.test(navigator.userAgent.toLowerCase()))
{set.reverse();}
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='tab_'+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.links).removeClass("activeSet");}
if(!this.mgr.displayResultTab(this.tabID))
{$(this.mgr.result.resultTemplate).addClass("noborder");$(this.mgr.links).addClass("activeSet");$(this).addClass("active");this.mgr.activeLink=this;}}
item.close=function()
{if(this.kCloser.closed!=undefined){this.kCloser._destruct();}
$(this.mgr.squishbox).slideUp(500,$(this.mgr.squishWrapper).hide());$(this.mgr.result.resultTemplate).removeClass("noborder");$(this).removeClass("active");$(this.mgr.links).removeClass("activeSet");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
{this.kCloser=new keywordCloser({'target':this.mgr.links},{object:this,method:'close'});this.kCloser.initStgClick(100);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.linkspan=document.createElement("span");item.link.appendChild(item.linkspan);item.linkspan.innerHTML=tabName.toLowerCase();item.link.item=item;if(item.tabID==TABS.MORE_INFO)
{try{item.link.href=this.result.getLink()}
catch(e){}}
else
{item.link.href="#__"+this.result.id.toString();item.link.name=this.result.id.toString()+"_"+tabID;item.link.onclick=function(e)
{var data=window.compileLink(null,this);this.href=data.href;this.hash=data.hash;this.item.select();}}}
catch(e)
{konsole.log(e);}}}
if($(this.result.entryContent).children('.tabs').attr('id')!=undefined){$(this.result.entryContent).children('.tabs').append(this.links);}else{this.result.entryContent.appendChild(this.links);}}
ResultTabMgr.prototype.getTab=function(id)
{if(this.reflinks[id]!=null)
return this.reflinks[id];}
ResultTabMgr.prototype.displayResultTab=function(tabID)
{if(tabID==TABS.MORE_INFO)
{return true;}
else if(this.tabObjects[tabID]!=null)
{this.tabObjects[tabID].reinit();this.displayContainer();return false;}
else
{this.fetchResultTab(tabID);return false;}}
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.resultSet.getCategory().getID(),locationID:this.result.resultSet.getLocation().getID()}
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;case TABS.HOTELS:var adtlParams={useLoader:true,loaderParent:this.squishbox,loaderClass:"loader_cardtabs",loaderText:''}
$(this.squishbox).css("height",100);break;case TABS.EVENTS:var adtlParams={useLoader:true,loaderParent:this.squishbox,loaderClass:"loader_cardtabs",loaderText:''}
$(this.squishbox).css("height",100);break;case TABS.RESTAURANTS:var adtlParams={useLoader:true,loaderParent:this.squishbox,loaderClass:"loader_cardtabs",loaderText:''}
$(this.squishbox).css("height",100);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}
break;}
$(this.squishWrapper).show();$(this.squishbox).slideDown(500);this.currentRequest=new AjaxRequest(AJAX_PATH+"result_requests.php",callbackParams,data,"GET");this.currentRequest.makeRequest(adtlParams);}
ResultTabMgr.prototype.loadResultTab=function(data)
{this.currentRequest=null;data.result=this.result;data.mgr=this;data.container=this.squishbox;data.id=this.pointer;this.current=data;if(data.js)
{var scriptLoader=Goby.get("scriptLoader");if(!scriptLoader.isLoaded(data.js))
{scriptLoader.importFile(data.js,{remote:false,callback:{object:this,method:"callback"}});}
else
this.callback(data.js);}
else
this.callback(data);}
ResultTabMgr.prototype.callback=function(script)
{var data=this.current;this.current=null;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.hideContainer=function()
{if(this.activeLink!=null)
{this.activeLink.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;if($(this.result.entryContent).children('.tabs').attr('id')!=undefined){$(this.result.entryContent).children('.tabs').append(squishWrapper);}else{this.result.entryContent.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(this.resizeH());objects.push(this);}},reinit:function()
{this.content=this.init();this.resize(this.resizeH());this.container.appendChild(this.content);},close:function()
{try
{this.container.removeChild(this.content);}catch(e){}},display:function()
{this.init();},resizeH:function()
{return-1;},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(params)
{this.htps=null;this.container=params.container;this.drag=(params.noDrag!=null&&params.noDrag?false:true);this.ewindows=[];this.ico=[];this.points=[];this.marker=[];this.size=params.size!=null?params.size:null;this.icons=[];this.bookmarks=[];this.stack=[];this.label=params.type;this.type=params.type;this.openStack=[];this.widget=params.widget;this.localBookmarks=[];this.scrollable=false;this.callback=params.callback;this.controls={};this.zoom=null;this.dots={hidden:new Array(),visible:new Array()};this.setHeuristicPoints(params.results);this.setCenterPt(params.location);this.initMap();objects.push(this);}
mapHandler.prototype={refPt:null,_destruct:function()
{if(this.container.remove)
this.container.remove();else if(this.container.parentNode)
this.container.parentNode.removeChild(this.container);this.container=null;Goby._kill(this);},getCurrentWindow:function()
{return this.currentWindow;},setCurrentWindow:function(node)
{if(node!==this.getCurrentWindow)
this.killCurrentWindow();this.currentWindow=node;},killCurrentWindow:function()
{if(this.currentWindow!=null)
{try
{if(this.currentWindow.remove)
this.currentWindow.remove();else
this.currentWindow.close();}
catch(e)
{}}},showAllPoints:function(isInit)
{var bounds=new google.maps.LatLngBounds(this.getCenterPt());try
{for(var i in this.marker)
{if(this.marker[i])
{var marker=this.marker[i];var result=this.marker[i].result;if(marker.getPosition())
{bounds.extend(marker.getPosition());if(result)
{if((current==null)||(result.getDistance()>current.getDistance()))
var current=result;}}}}}
catch(e)
{Goby.reportError(e);}
this.map.fitBounds(bounds);this.setZoom(this.map.getZoom());},setZoom:function(zoom)
{if(zoom<2)
this.zoom=2;else if(zoom>14)
this.zoom=14;else if(typeof zoom=="undefined")
this.zoom=10;else
this.zoom=zoom;this.map.setZoom(this.zoom);return this.zoom;},setHeuristicPoints:function(results)
{this.hpts=results;},getHeuristicZoom:function()
{if(this.hpts)
{try
{var bounds=new google.maps.LatLngBounds(this.getCenterPt());var current=null;for(var i in this.hpts)
{var result=this.hpts[i];if(result.isPlottable())
{if((current==null)||(result.getDistance()>current.getDistance()))
var current=result;bounds.extend(result.getPoint());}}
this.map.fitBounds(bounds);konsole.log(this.map.getZoom(),':zoom level');return this.setZoom(this.map.getZoom());}
catch(e)
{konsole.log(e.message);}}
else
{return 10;}},setHeuristicZoom:function()
{this.zoom=this.getHeuristicZoom();},getZoom:function()
{if(this.zoom!=null)
return this.zoom;else
return this.getHeuristicZoom();},showPoint:function(point){},initBounds:function(point){},setCenterPt:function(coor)
{this.centerPt=new google.maps.LatLng(coor.lat,coor.lng);return this.centerPt;},getCenterPt:function(){return this.centerPt;},setCenter:function(lat,lng)
{this.map.setCenter(this.setCenterPt({lat:lat,lng:lng}),10);},displayCenter:function(){},getControls:function(index)
{if(!this.controls[index])
{switch(index)
{case"small":var ctrl={'mapToggler':new MapToggler({map:this})};break;case"big":var ctrl={'mapToggler':new MapToggler({map:this})};break;case"bookmark":case"portal":default:var ctrl={};break;}
this.controls[index]=ctrl;}
return this.controls[index];},closeEWindows:function()
{while(this.ewindows.length>0)
{var win=this.ewindows.pop();win.remove();}},focus:function()
{if(this.type=="big")
$(window).scrollTo(this.container);},reformat:function(params)
{$(window).scrollTo(this.container);this.size=(params.size!=null?params.size:null);this.type=params.type;google.maps.event.trigger(this.map,'resize');this.showAllPoints();},resetCenter:function(coor)
{this.setCenterPt(coor);this.map.setCenter(this.getCenterPt());this.refPt.setPosition(this.getCenterPt());this.map.setZoom(this.getZoom());},getSize:function()
{if(this.size!=null)
return new google.maps.Size(this.size.x,this.size.y);else
{return new google.maps.Size($(this.container).innerWidth(),$(this.container).innerHeight());}},version:3,getVersion:function()
{return Goby.conf('google.api.map.version');},addControl:function(ctrl)
{if(ctrl.setMap)
ctrl.setMap(this.map);this.ctrl=ctrl;},initMap:function()
{try
{konsole.log(this.getCenterPt(),'how do i get the center point?');var map=new google.maps.Map(this.container,{size:this.getSize(),center:this.getCenterPt(),mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControl:true,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU,position:google.maps.ControlPosition.TOP_LEFT}});this.stacks=new StackMgr({map:this});this.map=map;google.maps.event.addListener(this.map,'tilesloaded',function(){this.mapHandler.loadControls()});var controls=this.getControls(this.type)
for(var index in controls)
this.addControl(controls[index]);this.setZoom(this.getZoom());this.map.mapHandler=this;google.maps.event.addListener(this.map,'click',function(){this.mapHandler.killCurrentWindow()});this.refPt=new Marker.Pin({map:this,point:this.getCenterPt(),drag:this.drag,callback:this.callback});this.refPt.setMap(this.map);map.mapHandler=this;try{this.closeEWindows();}
catch(e){}}
catch(e)
{Goby.reportError(e);}},loadControls:function(){},plotAddress:function(result){return false;},removeMarker:function(marker)
{if(marker)
{try
{marker.setMap(null);}
catch(e)
{konsole.log(marker)}}},resetMarkers:function()
{while(this.marker.length>0)
this.removeMarker(this.marker.pop());this.killCurrentWindow();this.stacks.erase();this.marker=[];this.bounds=false;},setPoint:function(result)
{if(result!=null&&result.isPlottable())
{var index=result.showieIndex;result.map=this;if(this.stacks)
{if(!this.stacks.append(result))
{var marker=result.getMarker(null);marker.setMap(this.map);}}
this.marker.push(result.getMarker());}},isDot:function(result){return false;},getDot:function(result){return false;},addDot:function(result){return false;},rmDot:function(result){return false;},hideDot:function(result){},showDot:function(result){return false;},getPinMap:function()
{return Goby.conf('google.api.pins');},getIcon:function(type,index,icon,size)
{return new MapIcon({type:type,index:index,icon:icon,size:size});},replaceMarker:function(oldmarker,marker,result)
{if(oldmarker.ewindow!=null)
marker.ewindow=oldmarker.ewindow;oldmarker.remove();marker.setMap(this.map);this.marker[result.showieIndex]=marker;this.showPoint(marker.getPosition());},setPinCallback:function(callback){this.refPt.setCallback(callback);},createCircle:function(marker,radius)
{if(marker.geoQuery)
marker.geoQuery.remove();var point=marker.getPosition();marker.geoQuery=createCircle(point,radius*1609.344,this);var radiusMI=radius/70;this.initBounds(point);var southwest=new google.maps.LatLng(point.lat()-radiusMI,point.lng()-radiusMI);var northeast=new google.maps.LatLng(point.lat()+radiusMI,point.lng()+radiusMI);this.bounds.isRadius=1;this.bounds.extend(southwest);this.bounds.extend(northeast);this.showAllPoints();return marker;},setDistance:function(point,d)
{point.lat();point.lng();return d/70;},hideRadius:function()
{delete this.radialSearch;},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;}},reshowMap:function()
{this.clearStreetView();},getCurrent:function()
{return(this.curMrk!=null?this.curMrk:null);},setCurrent:function(marker)
{while(this.openStack.length>0)
this.openStack.pop().close();this.curMrk=marker;},getContainer:function()
{return this.container;},show:function()
{$(this.getContainer()).show();},hide:function()
{if(this.type=="big")
this.changeSize();$(this.getContainer()).hide();return this.getContainer();},changeSize:function()
{this.widget.changeSize(this.type=="big"?"small":'big');}}
function makeOption(value,text)
{var option=document.createElement("option");option.value=value;option.text=text;return option;}
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);}}}
function BookmarkSelect(params,result)
{this.data={};this.loaded=false;this.position='right';this.positionWidth=180;if(result.type=="bookmark")
this.data.bookmarkID=result.getID();else
this.data.entityID=result.getID();this.result=result;var node=this._construct(params,null);node.autoPop=params.autoPop?params.autoPop:null;return node;}
BookmarkSelect.prototype=new Selector(null);BookmarkSelect.prototype.select=function(keep)
{this.ghost.updatePreamble();if(!keep)
{var option=this.getCurrent();var id=option.value;this.ghost.displayPreamble();switch(id)
{case'-1':break;case"new":var list=Goby.get("loginToolbar").createList(this);if(list)
list.setCallback({object:this,method:'saveNew'});var option=this.selectOption(-1);option.innerHTML="SAVE";option.updateGhost();this.updatePreamble();break;case"general":this.save(-1);break;default:this.save(id);break;}}}
BookmarkSelect.prototype.save=function(listID)
{if(listID!=-1)
this.data.listID=listID;var request=new AjaxRequest(AJAX_PATH+'user/'+(this.result.type=="bookmark"?'copyBookmark':'createBookmark'),{object:this,method:"finish"},this.data,"POST");try{this.bookmarkList=this.customer.getList(listID);}
catch(e){}
trackEvent([PAGE_ID,'save_to_submit'],PV.LABEL);request.makeRequest({loaderClass:"loader_select",loaderParent:this.getPreamble(),useLoader:false,parentSize:true});var option=this.selectOption(-1);option.innerHTML="SAVING..";option.updateGhost();this.updatePreamble();}
BookmarkSelect.prototype.showOptions=function()
{if(this.loaded)
return false;if(Goby.get("customer"))
this.customer=(Goby.get("customer"));Goby.set("bookmark_node",this);if(!Goby.promptLogin({object:this,method:'show'},"bookmark"))
{return false;}
else if(this.customer.hasLists())
{this.addOption(null,{label:"create a new list",value:"new",className:'newlist'});this.addOption(null,{label:"general bookmarks",value:"general",className:'bookmarkslist'});this.load(this.customer.getLists());return true;}
else
{this.addOption(null,{label:"create a new list",value:"new",className:'newlist'});this.addOption(null,{label:"general bookmarks",value:"general",className:'bookmarkslist'});var request=new AjaxRequest(AJAX_PATH+"user/getFavoritesLists",{object:this,method:"jax"},{},"GET");request.makeRequest({loaderClass:"loader_select",loaderParent:this.getCurrent().getGhost(),useLoader:true,parentSize:false});return true;}}
BookmarkSelect.prototype.hideOptions=function()
{this.loaded=false;this.ghost.removeOptions();if(this.popup)
$(this.popup.getWrapper()).css("width",'auto');}
BookmarkSelect.prototype.finish=function(data)
{trackEvent([PAGE_ID,'save_to_success']);if(this.result&&this.result.type!="entity")
{flash(data.msg);Goby.get("loginToolbar").updateSaved();if(!data.error&&this.bookmarkList)
{this.bookmarkList.count++;}
if(data.link&&!data.error)
{var entry=new Div({className:"added_bookmark",nodes:[new Span({text:"added to: "}),new Link({className:"name",href:data.link,text:data.name?data.name:"your list"}),new Link({className:"closeButton",text:"<span>[close]</span>",fnc:function(){$(this.parentNode).fadeOut(400,'easeInSine',this.parentNode.remove());}})]});entry.style.display="none";this.result.resultTemplate.appendChild(entry);$(entry).fadeIn(800);}}
else
{if(!data.error&&this.bookmarkList)
this.bookmarkList.count++;flash(data.msg);Goby.get("loginToolbar").updateSaved();}
if(this.autoPop)
{this.remove();}
else
{var option=this.selectOption(-1);option.innerHTML="SAVE";option.updateGhost();this.updatePreamble();}}
BookmarkSelect.prototype.jax=function(data)
{this.customer.setLists(data);this.load(this.customer.getLists());}
BookmarkSelect.prototype.load=function(data)
{for(var i in data)
{var item=data[i];this.addOption(null,{value:item.id,label:item.name.toString().truncate(28,'...',false)});}
$(this.popup.getWrapper()).css("width",this.positionWidth);this.popup.positionContent();this.loaded=true;}
BookmarkSelect.prototype.saveNew=function(data)
{if(data)
this.save(data.id);}
var Results={};Results.Teaser=function(params,resultSet){this.__run(params,resultSet)}
Results.Teaser.prototype=Class({inherits:Result,_construct:function(resultJson,resultSet)
{this.tpl=[];this.facetObjects=new List();for(index in resultJson)
this[index]=resultJson[index];if(typeof(this.facets)!=='undefined'&&this.facets.date!=null)
this.dateSensitive=true;this.resultTabs=null;if(resultSet)
this.setResultSet(resultSet);this.nodes={};},methods:{display:function(node)
{if(this.resultSet.getType()!="whats-nearby")
{var container=(node!=null?node:this.resultSet.getContainer());this.resultTemplate=document.createElement("div");this.resultTemplate.className="entry-teaser";var content=this.resultTemplate;this.nodes.tpl=content;this.nodes.content=content;var indexObject=new FacetIndex(this);content.appendChild(indexObject.render());container.appendChild(content);container.appendChild(getClear());var titleObject=new FacetTitle(this,'h4');content.appendChild(titleObject.render());var address=this.fetchFacet('address');if(this.facets.date!=null)
this.fetchFacet('dateBar').render();content.appendChild(address.render(null,(this.facets.date?true:false)));var categorySet=new FacetCategorySet(this);content.appendChild(categorySet.render(null,1));var sourceObj=new FacetDescription(this);sourceObj.truncate(0);content.appendChild(sourceObj.render(null,true));return this.resultTemplate;}
else
{var container=(node!=null?node:this.resultSet.getContainer());this.resultTemplate=document.createElement("div");this.resultTemplate.className="entry-teaser";var content=this.resultTemplate;this.nodes.tpl=content;this.nodes.content=content;var indexObject=new FacetIndex(this);content.appendChild(indexObject.render());container.appendChild(content);container.appendChild(getClear());var titleObject=new FacetTitle(this,'h4');content.appendChild(titleObject.render());if(this.facets.date!=null)
this.fetchFacet('dateBar').render();var categorySet=new FacetCategorySet(this);content.appendChild(categorySet.render(null,1));return this.resultTemplate;}}}});Results.Event=function(params,resultSet){this.__run(params,resultSet)}
Results.Event.prototype=Class({inherits:Result,methods:{display:function()
{this.fetchFacet('title').header='h4';this.resultTemplate=new LI({className:"entry",nodes:[this.fetchFacet('photo').render(new Div({className:"facet_photo"})),new Div({className:"entry-content",nodes:[this.fetchFacet('title').render(null,48),this.fetchFacet('categorySet').render()]}),(this.hasFacet('affiliate')?this.fetchFacet('affiliate').render(new Div({className:"facet_affiliate"})):null),this.fetchFacet('date').render(new Div({className:"facet_date"}),'oldway')]});return this.resultTemplate;}}});
