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

var THUMBS_DOWN=0;var THUMBS_UP=1;var THUMBS_MIDDLE=2;function evokeLoginPopup(node)
{node.popup=new LoginPopup({id:"signinContainer",container:document.getElementById("login_container"),isMask:false,slidable:true,fixed:true,form_name:"form_login",form_type:"login"});node.popup.init();}
_initAccount=function(signinlink)
{signinlink.popup=new LoginPopup({id:"accountContainer",container:document.body,isMask:true,isCloser:true,noClick:false,fixed:true,opacity:0.25,mask:"#12345",form_name:"form_update",form_type:"update_account",submitCallback:"closePopup",useBlind:true,hideMessage:function()
{$(this).find(".msg").text('');$(this.button).removeClass("signalValid");},displayMessage:function(data)
{this.hideError();$(this).find(".msg").show();$(this).find(".msg").text(data);},submit:function()
{if(this.request==null)
{this.hideError();this.hideMessage();var myValidator=new Validator(this);if(myValidator.validate()>0)
return false;this.request=new AjaxRequest(this.REQUEST_URL,{object:this,method:this.submitCallback},this.requestElements());this.request.makeRequest();}},closePopup:function(data)
{this.request=null;if(data.valid)
{this.hideError();$(this.button).addClass("signalValid");this.displayMessage(data.msg);}
else
{this.hideMessage();this.displayError(data.error);}}});$(signinlink).click(function()
{if(!this.popup.isClosed())
this.popup.close();else
this.popup.init();});}
function Feedback()
{objects.push(this);}
Feedback.prototype={popups:[],popup:null,closePopup:function()
{this.popup.close();this.popup._destruct();this.popup=null;},setThumb:function(thumb)
{this.thumb=thumb;},close:function()
{if(this.thumb==THUMBS_DOWN)
{var form=this.popup.getForm();var requestElements=form.requestElements();requestElements.feedback_thumb=this.thumb;var r=new AjaxRequest(form.REQUEST_URL,{object:this.popup,method:"close"},requestElements);r.makeRequest();}
else
{this.closePopup();}},giveFeedback:function(type)
{if((this.popup!=null)&&(!this.popup.popup.isClosed()))
return false;window.scrollTo(0,0);this.thumb=type;this.popup=new LoginPopup({id:"feedbackContainer",container:document.body,isMask:true,isCloser:true,thumb:type,noClick:false,useBlind:true,fixed:true,slidable:false,feedback:this,mask:"#12345",opacity:0.25,form_name:"form_feedback",form_type:"give_feedback",generateThumbs:function()
{var container=document.getElementById("feedbackThumbContainer");container.getCurrent=function()
{return this.current;}
container.setCurrent=function(item)
{if(this.getCurrent())
$(this.getCurrent()).removeClass("active");this.current=item;$(item).addClass("active");feedback.setThumb(item.thumbID);}
this.popup.params.feedback.thumbContainer=container;var thumbs=this.popup.data.thumbs;for(var i in thumbs)
{var thumb=thumbs[i];var item=document.createElement("li");var link=document.createElement("a");var span=document.createElement("span");item.appendChild(link);link.appendChild(span);item.id="feedback-option-"+thumb.id;span.innerHTML=thumb.label;item.thumbID=thumb.id;link.item=item;link.container=container;link.onclick=function()
{if(this.item!==this.container.getCurrent())
{this.container.setCurrent(this.item);}}
if(this.popup.params.feedback.thumb==thumb.id)
container.setCurrent(item);container.appendChild(item);}},initCallback:"generateThumbs",submitCallback:"closePopup",hideMessage:function()
{$(this).find(".msg").text('');$(this.button).removeClass("signalValid");},displayMessage:function(data)
{this.hideError();$(this).find(".msg").show();$(this).find(".msg").text(data);},submit:function()
{if(this.request==null)
{this.hideError();this.hideMessage();var myValidator=new Validator(this);if(myValidator.validate()>0)
return false;var data=this.requestElements();data.feedback_thumb=feedback.thumb;this.request=new AjaxRequest(this.REQUEST_URL,{object:this,method:this.submitCallback},data);this.request.makeRequest();}},closePopup:function(data)
{this.request=null;if((data.valid!=null)&&(data.valid))
{this.hideError();$(this.button).addClass("signalValid");this.displayMessage(data.msg);$("#feedbackArea").hide();}
else
{this.hideMessage();if(data.error)
this.displayError(data.error);else
this.displayError("There was an internal error");}}});if(!this.popup.isClosed())
this.popup.close();else
this.popup.init();}}
var feedback=new Feedback();$(document).ready(function()
{var obj=document.getElementById("customerName");if(obj!=null)
_initAccount(obj);});function keywordCloser(wrappers,callback)
{this.wrappers={"document":document,"body":document.body};this.namespace=Math.round(Math.random()*10000);this.stack=[];this.closed=false;this.safeWrappers=[];this.callback=false;this.top=document;if(wrappers)
this.setWrappers(null,wrappers,callback);objects.push(this);}
keywordCloser.prototype.setWrappers=function(wrappers,safeWrappers,callback,top)
{if(!top)
top=document.body;if(!safeWrappers)
{var safeWrappers={"searchbox":document.getElementById("searchbox"),"browser":document.getElementById("browser")}}
for(var i in safeWrappers)
{if(safeWrappers[i]==null)
continue;if(safeWrappers[i].replace!=null)
safeWrappers[i]=document.getElementById(safeWrappers[i]);if(safeWrappers[i]!=null)
{this.wrappers[i]=safeWrappers[i];this.safeWrappers[i]=true;}}
this.callback=callback;this.top=top}
keywordCloser.prototype.initStgClick=function(tm)
{if(this.invalid)
return false;tm=(tm?tm:10);var closer=this;setTimeout(function()
{closer.initClick();},tm);}
keywordCloser.prototype.bindCloser=function(index)
{var element=this.wrappers[index];if(element!=undefined)
{if(element.closerSet==null)
element.closerSet={};$(element).unbind('click.closer');element.closerSet[this.namespace]={'index':index,'controller':this};$(element).bind('click.closer',function(e)
{var closers=this.closerSet;for(index in closers)
{if(closers[index])
{var controller=closers[index].controller;var elementIndex=closers[index].index;if((controller.closed!=true)&&(controller!=null))
{controller.addElement(elementIndex);}}}})}
else
{}}
keywordCloser.prototype.initClick=function()
{for(index in this.wrappers)
this.bindCloser(index);}
keywordCloser.prototype.addElement=function(index)
{this.stack.push(index);this.checkUp(index);}
keywordCloser.prototype.destruct=function()
{this.closed=true;for(var index in this.wrappers)
{if(this.wrappers[index]!=null)
var element=(this.wrappers[index].replace!=null?document.getElementById(index):this.wrappers[index]);if(element!=null)
element.closerSet[this.namespace]=null;}}
keywordCloser.prototype.checkUp=function(index)
{var element=this.wrappers[index];var good=false;if(element===this.top)
{while(this.stack.length>0)
{var nodeIndex=this.stack.pop();if(this.safeWrappers[nodeIndex])
good=true;}
if(!good)
{if(this.callback)
{if(this.callback.object)
this.callback.object[this.callback.method]();else
eval(this.callback.method+"()");}
else
{this.destruct();}}}}
keywordCloser.prototype.addSafeWrapper=function(div)
{this.safeWrapper[div.id]=true;this.wrappers[div.id]=div;this.bindCloser(div.id);}
keywordCloser.prototype._destruct=function()
{var count=0;this.destruct();for(var i in this)
{if(this[i]!=null)
{if(this[i]._destruct!=null)
this[i]._destruct();else
this[i]=null;count++;}}
killself(this);}
keys={BACKSPACE:8,RETURN:13,DELETE:46,ESCAPE:27,DOWN:40,UP:38,TAB:9,RIGHT:39,LEFT:37,SPACE:32}
var suggestObject;function closeList()
{suggestionObject.closeList();}
keywordSuggest.prototype.closeList=function()
{$(this.ghost).css("height",0);$(this.ghost).css("width","244px");$(this.ghost).css("display","none");$(this.ghost).hide();$(this.keywordList).hide();this.ghost.removeOptions();this.keywordList.selectedIndex=0;this.ghost.style.display="none";if(this.closer!=null)
{this.closer.destruct();this.closer=null;}}
function checkFocus(elementID)
{}
function keywordSuggest(fieldid,storageFieldID)
{this.REQUEST_URL=AJAX_PATH+"search_requests.php";objects.push(this);this.field=document.getElementById(fieldid);this.storageField=document.getElementById(storageFieldID);this.field.myObject=this;this.myBrowserMap=browseMap[fieldid];this.prefix=this.myBrowserMap.tracker;this.ghostID=storageFieldID+"_ghost";this.keywordListID=storageFieldID+"_keywordlist";this.textContainer=$(this.field).parents(".textbox_container");this.inProcess=false;this.init=false;this.nextField=$(this.field).parents(".textbox_container").next().find("input");this.resultLimit=10;this.key="";switch(storageFieldID)
{case"where_id":this.label="Locations";break;case"what_id":this.label="Categories";break;case"when_id":this.label="Time";break;default:this.label="Entries"}
this.field.autocomplete="off";jQuery(this.field).attr("autocomplete","off");this.nodeType=this.storageField.title;this.limitLocal=2;this.limitRemote=2;this.listSet=new List();this.hashSet=new Array();this.buildContainer();this.field.keys={BACKSPACE:8,RETURN:13,DELETE:46,ESCAPE:27,DOWN:40,UP:38,RIGHT:39,LEFT:37,SPACE:32,TAB:9}
jQuery(this.field).keypress(function(e)
{switch(e.which)
{case keys.RETURN:return false;break;}});jQuery(this.field).keydown(function(e)
{switch(e.which)
{case keys.RETURN:return false;break;}});$(this.field).blur(function(e)
{if(this.currentRequest!=null)
this.currentRequest.terminateRequest();});jQuery(this.field).keyup(function(e)
{var myObject=jQuery(this).attr("myObject");if(jQuery("#"+myObject.myBrowserMap.browser).is(":visible"))
{jQuery("#"+myObject.myBrowserMap.tab).click();}
if((e.which>=49&&e.which<=256)||(e.which==this.keys.BACKSPACE)||(e.which==this.keys.DELETE)||(e.which==this.keys.SPACE))
{$(myObject.storageField).attr("value",0);if($(this).attr("value").length>=myObject.limitLocal)
{var listObj=myObject.getListObj();if((listObj!=undefined)&&(listObj.isVisible()))
this.field.toggleMenu();if(myObject.inProgress())
{}
else if(myObject.listExists(jQuery(this).attr("value")))
{if(this.currentRequest!=undefined)
{this.currentRequest.terminateRequest();this.currentRequest=null;}
myObject.displaySuggestions(jQuery(this).attr("value"));}
else
{var value=jQuery(this).attr("value");myObject.keywordList.innerHTML="";data=new Array;data['action']="getCompletion";data['actualPhrase']=value.toLowerCase();if(myObject.listExists(value))
data['value']=data['actualPhrase'];else
data['value']=myObject.formatPhrase(value);var oldPhrase=value.substr(0,value.length-1);data['node_type']=myObject.nodeType;callbackParams={object:myObject,method:"showCompletion"}
if(this.currentRequest!=undefined)
{this.currentRequest.terminateRequest();this.currentRequest=null;}
var myRequest=new AjaxRequest(myObject.REQUEST_URL,callbackParams,data,"GET");myRequest.makeRequest();this.currentRequest=myRequest;myObject.inProcess=true;}}
else
{myObject.keywordList.innerHTML="";myObject.ghost.removeOptions();myObject.closeList();return false;}}
else if(e.which==this.keys.ESCAPE)
{myObject.keywordList.innerHTML="";myObject.ghost.removeOptions();myObject.closeList();return false;}
else if((e.which==this.keys.RETURN)||(e.which==this.keys.DOWN)||(e.which==this.keys.RIGHT)||(e.which==this.keys.TAB))
{$(myObject.keywordList).data("keepOpen","true");if(jQuery(myObject.keywordList).is(":visible"))
{myObject.keywordList.focus(e.which);myObject.ghost.hoverOptionByIndex(0);}
else if(myObject.listExists(jQuery(this).attr("value")))
{myObject.displaySuggestions(jQuery(this).attr("value"));if(myObject.keywordList.options.length>0)
{myObject.keywordList.focus(e.which);myObject.ghost.hoverOptionByIndex(0);}}
else
{myObject.keywordList.innerHTML="";myObject.closeList();return false;}}
else if((e.which==this.keys.UP))
{myObject.closeList();}
else
{myObject.closeList();return false;}});}
keywordSuggest.prototype.getList=function(phrase)
{return this.listSet.get(this.formatPhrase(phrase));}
keywordSuggest.prototype.listExists=function(phrase)
{if(this.getList(phrase))
return true;else
return false;}
keywordSuggest.prototype.setListObj=function(object)
{this.listObj=object;}
keywordSuggest.prototype.getListObj=function()
{if(this.listObj==null)
if(this.field.list)
this.listObj=this.field.list;return this.listObj;}
keywordSuggest.prototype.storeList=function(hash,phrase)
{this.listSet.add(this.formatPhrase(phrase),hash);}
keywordSuggest.prototype.reconstructor=function(rs)
{for(key in rs)
{wordList=rs[key];if(key=="word")
{for(index in wordList)
if(wordList[index].string!==undefined)
{if(this.coolResults.length<=this.resultLimit)
this.coolResults.push(wordList[index]);else
break;}}
else if((wordList!==undefined)&&(this.coolResults.length<=this.resultLimit))
this.reconstructor(wordList);}}
keywordSuggest.prototype.getSuggestions=function(phrase)
{phrase=phrase.toLowerCase();delete this.coolResults;this.coolResults=false;this.coolResults=[];var data=this.getList(phrase);return data;}
keywordSuggest.prototype.displaySuggestions=function(phrase)
{var valid=false;if(phrase.length>=this.limitLocal)
{this.keywordList.options.length=0;this.ghost.removeOptions();var keywords=this.getSuggestions(phrase.toLowerCase());var j=0;for(var i in keywords)
{var keyword=keywords[i];if(keyword.node_value==null)
continue;keyword.id=keyword.node_id;keyword.string=keyword.node_value.toLowerCase();var index=keyword.node_id;var value=keyword.node_value.toLowerCase();if(j<this.resultLimit)
{var listItem=document.createElement("option");listItem.text=value;this.ghost.addOption(keyword,listItem,phrase);this.keywordList.add(listItem,(navigator.isBrowser(browser.IE)||navigator.isBrowser(browser.IE_SEVEN)||navigator.isBrowser(browser.IE_EIGHT)||navigator.isBrowser(browser.IE_SIX)?(j+1):null));jQuery(listItem).attr("text",value);jQuery(listItem).attr("value",index);j++;}}
var listItem=document.createElement("option");listItem.text="View All "+this.label;listItem.value="view_all";this.keywordList.listItem=listItem;this.keywordList.add(listItem,(navigator.isBrowser(browser.IE)||navigator.isBrowser(browser.IE_SEVEN)||navigator.isBrowser(browser.IE_EIGHT)||navigator.isBrowser(browser.IE_SIX)?(j):null));this.ghost.addOption({string:listItem.text,id:"view_all"},listItem,false);if(j>0)
{var valid=true;if(jQuery(this.keywordList).is(":hidden"))
{jQuery(this.keywordList).fadeIn(100);jQuery(this.ghost).fadeIn(100);if(this.closer==null)
{var wrappers=[];wrappers[this.ghost.id]=this.ghost;wrappers[this.keywordList.id]=this.keywordList;this.closer=new keywordCloser(wrappers,{object:this,method:"closeList"});this.closer.initClick();}}
this.init=true;this.ghost.setSize();return true;}}
this.ghost.removeOptions();this.keywordList.innerHTML="";this.closeList();}
keywordSuggest.prototype.inProgress=function()
{return(this.inProcess?true:false);}
keywordSuggest.prototype.formatPhrase=function(phrase)
{var phrase=phrase.substr(0,this.limitLocal).toLowerCase();return phrase;}
keywordSuggest.prototype.buildContainer=function()
{var keywordList=document.createElement("select");keywordList.id=this.keywordListID
keywordList.myObject=this;keywordList.style.display="none";keywordList.className="suggestion_box";keywordList.size=1;keywordList.style.width="20px";keywordList.name=this.field.id+"_box";keywordList.multiple=false;keywordList.keepOpen=false;this.keywordList=keywordList;this.ghost=this.buildGhost();jQuery(this.keywordList).focus(function(e){if($(this).data("keepOpen")=="true")
{}
else
{var myObject=jQuery(this).attr("myObject");myObject.closeList();$(myObject.nextField).focus();}
$(this).data("keepOpen",false);});jQuery(this.keywordList).click(function(e)
{var myObject=jQuery(this).attr("myObject");var options=jQuery(this).attr("options");var index=jQuery(this).attr("selectedIndex");if(options[index])
{var option=options[index];myObject.ghost.hoverOption(option);}
else
{}});jQuery(this.keywordList).keydown(function(e)
{var index=jQuery(this).attr("selectedIndex");myObject=jQuery(this).attr("myObject");var options=jQuery(this).attr("options");var option=options[index];var noHover=false;switch(e.which)
{case keys.ESCAPE:myObject.closeList();break;case keys.TAB:var index=jQuery(this).attr("selectedIndex");var options=jQuery(this).attr("options");var option=options[index];var noHover=false;myObject.selectOption(option);myObject.closeList();myObject.field.focus();break;case keys.UP:if(index==0)
{myObject.field.focus();}
break;}});jQuery(this.keywordList).keyup(function(e)
{var index=jQuery(this).attr("selectedIndex");myObject=jQuery(this).attr("myObject");var options=jQuery(this).attr("options");var option=options[index];var noHover=false;switch(e.which)
{case keys.RETURN:myObject.selectOption(option);break;case keys.UP:if(index<0)
{myObject.field.focus();noHover=true}
case keys.DOWN:case keys.RIGHT:case keys.LEFT:if(!noHover)
myObject.ghost.hoverOption(option);break;case keys.ESCAPE:myObject.closeList();break;}});var wrappingMech=jQuery(this.field).parents(".textbox_container");var container=document.createElement("div");$(container).addClass("floater")
jQuery(container).appendTo(jQuery(wrappingMech));jQuery(this.keywordList).appendTo(jQuery(container));return this.keywordList;}
keywordSuggest.prototype.selectOption=function(option)
{if(option!==undefined)
{switch(option.value)
{case"view_all":this.field.toggleMenu();this.field.highlight(1);$(this.field).focus();break;default:this.field.setValue(option.text);this.storageField.value=option.value;trackSearchEvent([this.prefix+'_suggest_select']);$(this.field).focus();if(this.listObj)
this.listObj.autoSelect(option.value);break;}
this.closeList();}}
keywordSuggest.prototype.showCompletion=function(data)
{this.inProcess=false;var phrase=data.phrase;var actualPhrase=data.actualPhrase;var list=data.list;actualPhrase=this.field.value;this.storeList(list,phrase);if(list!=null)
this.displaySuggestions(actualPhrase);else
this.removeSuggestions();}
keywordSuggest.prototype.buildGhost=function()
{this.ghost=document.createElement("ul");this.ghost.className="suggestion_blox";this.ghost.id=this.ghostID;this.ghost.keywordList=this.keywordList;this.ghost.handler=this;$(this.textContainer).append(this.ghost);this.ghost.hoverOptionByIndex=function(index)
{this.keywordList.selectedIndex=index;if((this.keywordList.options.length>index)||((0>index)))
{var option=this.keywordList.options[this.keywordList.selectedIndex];this.hoverOption(option);}}
this.ghost.hoverOption=function(option)
{$(this.currentOption).removeClass("active");var stringID=this.id+"["+option.value+"]";this.currentOption=document.getElementById(stringID);var position=$(this.currentOption).position();$(this).scrollTop(position.top);$(this.currentOption).addClass("active");$(this.currentOption).removeClass("inactive");}
this.ghost.addOption=function(data,option,phrase)
{var item=document.createElement("li");if(data.id=="view_all")
{$(item).addClass("sBrowser");var span=document.createElement("span");$(span).addClass("sBrowserLink");$(span).text(data.string);item.appendChild(span);}
else
{phrase=phrase.replace(regex,' ');var regex=new RegExp(phrase,"i");var pos=data.string.search(regex);var phraseCase=data.string.substr(pos,phrase.length);item.innerHTML=data.string.replace(regex,"<strong>"+phraseCase+"</strong>");}
item.id=this.id+'['+data.id+"]";item.option=option;item.ghost=this;$(item).addClass("ghostOption");$(item).hover(function(e)
{$(this).addClass("hover");},function(e)
{$(this).removeClass("hover");})
$(item).dblclick(function(e)
{$(this).attr("ghost").handler.selectOption($(this).attr("option"));});$(item).click(function(e)
{$(this).attr("ghost").handler.selectOption($(this).attr("option"));$(this).addClass("active");$(this).removeClass("inactive");});this.appendChild(item);}
this.ghost.removeOptions=function()
{$(this).scrollTop(0);$(this).contents(".ghostOption").remove();this.currentOption=null;}
this.ghost.setSize=function()
{var maxWidth=244;var maxHeight=90;var height=0;var width=0;var count=0;for(index in this.childNodes)
{var item=this.childNodes[index];if(item!=undefined)
{if(item.tagName=="LI")
{var txt=$(item).text();height+=parseInt($(item).css("height"))+parseInt($(item).css("paddingTop"))+parseInt($(item).css("paddingBottom"));var myWidth=8*txt.length;if(myWidth>width)
width=myWidth;}}}
if(!this.childNodes)
$(this).hide();maxWidth=(width>maxWidth?width:maxWidth);maxHeight=(height>maxHeight?height:maxHeight);var maxHeight=height;$(this).css("width",maxWidth);$(this).css("height",maxHeight);}
this.ghost.removeOption=function(index)
{$(this).css("height",$(this).css("height")-10);this.currentOption=null;this.removeChild[index];}
return this.ghost;}
keywordSuggest.prototype._destruct=function()
{var count=0;for(var i in this)
{if(this[i]!=null)
{if(this[i]._destruct!=null)
this[i]._destruct();else
this[i]=null;count++;}}
delete this;}
function keywordList(container,type,field)
{var myBrowseMap=browseMap[container.id];this.REQUEST_URL=AJAX_PATH+"search_requests.php";this.myBrowseMap=myBrowseMap;this.initialized=false;this.prefix=myBrowseMap.tracker;this.field=field;this.minLevels=3;this.defaultWidth=378;this.gestalt=container;this.container=document.createElement("div");this.container.id="what_list";this.list=this.container;this.closeBox=document.createElement("a");this.closeBox.id="what_closebox";this.closeBox.listHdlr=this;this.closeBox.appendChild(document.createTextNode("close"));this.closeBox.onclick=function()
{this.listHdlr.field.closePanel();}
this.breadcrumbContainer=document.createElement("div");this.breadcrumbContainer.id="what_breadcrumb";var toolbar=document.createElement("div");toolbar.appendChild(this.closeBox);toolbar.appendChild(this.breadcrumbContainer);this.toolbar=toolbar;$(container).css("width",this.defaultWidth);container.appendChild(this.container);container.appendChild(toolbar);toolbar.className="keywordlist_toolbar";this.type=(type?type:"local");this.activeTab=new Array();$(this.field).bind("keyup.keywordList",function()
{if(!this.storage.value)
{if(this.keywordList.isVisible())
this.keywordList.reset();else
this.keywordList.setInitID(1);}});this.field.keywordList=this;$(this.field.deletebox).bind("click.keywordList",function()
{var field=$(this).data("field");if(field.keywordList!=null)
{field.keywordList.reset();}});objects.push(this);this.setInitID('default');}
keywordList.prototype.isVisible=function()
{if($("#"+this.myBrowseMap.browser).is(":visible"))
return true;else
return false;}
keywordList.prototype.reset=function()
{this.setInitID('default');this.autoSelect(this.initID,true);}
keywordList.prototype.resetMenu=function(menu,list)
{if((menu!=null))
{listWrap=menu.listWrapper;if(menu.list)
listWrap.removeChild(menu.list);menu.list=list;listWrap.appendChild(menu.list);$(listWrap).scrollTop(0);$(menu.down).removeClass("inactive");$(menu.up).removeClass("inactive");if($(menu.listWrapper).height()>$(menu.list).outerHeight())
{$(menu.up).addClass("disabled");$(menu.down).addClass("disabled");}
else
{$(menu.up).addClass("inactive");$(menu.up).removeClass("disabled");$(menu.down).removeClass("disabled");}
if(menu.slider.reset)
menu.slider.reset();menu.list.menu=menu;return menu;}
else
return null;}
keywordList.prototype.close=function()
{$(this.gestalt).hide();}
keywordList.prototype.generateMenu=function(params)
{if((params.parent!=null)&&(params.parent.next!=null))
{var menu=this.resetMenu(params.parent.next,params.list);return menu;}
var menu=document.createElement("div");var head=document.createElement("div");var foot=document.createElement("div");var slider=document.createElement("div");var up=document.createElement("a");var down=document.createElement("a");up.title="up";down.title="down";up.appendChild(document.createElement("div"));down.appendChild(document.createElement("div"));up.menu=menu;down.menu=menu;$(up).addClass("ctrl_up");$(down).addClass("ctrl_down");this.addScrollCtrl(up,"up");this.addScrollCtrl(down,"down");head.appendChild(up);foot.appendChild(down);$(slider).addClass("slider");$(head).addClass("head");$(foot).addClass("foot");$(menu).addClass("browser_menu");$(this.container).css("overflow","hidden");if(params.className)
$(menu).addClass(params.className);params.list.defaultValue=(params.defaultValue?params.defaultValue:"<h3>Select a Category</h3>");$(menu).attr("index",params.index);menu.index=params.index;var list=params.list;var listWrapper=document.createElement("div");listWrapper.className="content";listWrapper.appendChild(list);list.menu=menu;menu.listWrapper=listWrapper;menu.list=list;menu.up=up;menu.down=down;menu.slider=slider;slider.menu=menu;menu.appendChild(slider);menu.appendChild(head);menu.appendChild(listWrapper);menu.appendChild(foot);menu.next=null;if(params.parent==null)
{menu.index=1;this.menu=menu;}
else
{menu.index=params.parent.index+1;params.parent.next=menu;menu.last=params.parent;}
menu.id="browser_level_"+menu.index;this.container.appendChild(menu);if(params.parent!=null)
var newWidth=parseInt($(this.container).css('width'))+parseInt($(menu).css("width"));else
var newWidth=parseInt($(menu).css("width"));if(menu.index>2)
{if((params.auto)&&(newWidth>this.defaultWidth))
{$(this.container).css("width",newWidth+"px");$(this.toolbar).css("width",newWidth+"px");}
else if((newWidth>this.defaultWidth))
{$(this.container).css("width",newWidth+"px");$(this.toolbar).css("width",newWidth+"px");}}
$(this.gestalt).css("width",(menu.index*189)+"px");if($(menu.listWrapper).height()>$(menu.list).outerHeight())
{$(up).addClass("disabled");$(down).addClass("disabled");}
else
{$(up).removeClass("disabled");$(down).removeClass("disabled");if($(menu.listWrapper).scrollTop()==0)
$(up).addClass("inactive");else
$(up).removeClass("inactive");}
if(params.parent!=null)
this.makeSlidable(menu.slider);return menu;}
keywordList.prototype.removeMenu=function(menu,animate)
{menu.last.next=null;var newWidth=(parseInt($(this.container).css('width'))-parseInt($(menu).css("width")));if(newWidth>=this.defaultWidth)
{$(this.container).contents(".searchbox_header").contents(".content").css({width:(newWidth-8)+"px"});$(this.container).css({width:newWidth+"px"});$(this.toolbar).css("width",newWidth+"px");$(this.container).contents(".searchbox_footer").contents(".content").css({width:(newWidth-8)+"px"});$(menu).remove();}
else
$(menu).remove();$(this.gestalt).css("width",((menu.index-1)*189)+"px");}
keywordList.prototype.initKeywords=function()
{if(this.initialized==true)
{this.autoSelect(this.initID);return false;}
var adtlParams={useLoader:true,loaderParent:this.container,loaderClass:"loader_keywordList"}
this.initialized=true;var data=[];data['action']=(this.type=="local"?"getKeywordTree":"getBastards");data['node_type']=this.field.name;callbackParams={object:this,method:"popTop"}
var aRequest=new AjaxRequest(this.REQUEST_URL,callbackParams,data,"GET");aRequest.makeRequest(adtlParams);}
keywordList.prototype.popTop=function(data)
{if(this.type=="local")
this.keywords=data.keywords;var result={keywords:data.keywords,auto:true}
this.displayChildren(result);this.autoSelect(this.initID);}
keywordList.prototype.getChildNodes=function(object)
{var roots=[];while(object!==null)
{roots.push(object.id);object=document.getElementById(object.parentID);}
parentID=roots.pop();var keywordList=this.keywords[parentID];while(roots.length>0)
keywordList=keywordList['children'][roots.pop()];return keywordList['children'];}
keywordList.prototype.attachMenuEvent=function(dude)
{jQuery(dude).attr("listHandler",this);$(dude).addClass("item_"+dude.id);jQuery(dude).hover(function()
{if(!$(this).hasClass("active")&&!$(this).hasClass("activeParent")&&!$(this).hasClass("artifact"))
$(this).addClass("hover");},function()
{$(this).removeClass("hover");});jQuery(dude).click(function()
{var myObject=jQuery(this).attr("listHandler");myObject.field.setValue(jQuery(this).text());myObject.field.setID(jQuery(this).attr("id"));$(this).removeClass("hover");this.decorate();trackSearchEvent([myObject.prefix+"_panel",jQuery(this).text()],true);if(this.list.menu==null)
{return false;}
else if(this.list.menu.next!=null)
{var menu=(this.children?this.list.menu.next:this.list.menu);var stack=[];while(menu.next!=null)
{stack.push(menu.next);menu=menu.next;}
while(stack.length>0)
myObject.removeMenu(stack.pop());}
myObject.updateBreadcrumbs(this);if(this.child_count>0)
{data.parentID=this.id;data.parentItem=this;data.menu=this.list.menu;data.keywords=this.keywords;data.auto=false;myObject.displayChildren(data);}
else
{myObject.field.closePanel();}});}
keywordList.prototype.displayChildren=function(data)
{var keywords=data.keywords;var list=document.createElement("ul");if((data.parentItem!=null)&&(!data.parentItem.inert))
{var node={node_value:"all",node_id:data.parentItem.id,listHandler:this,list:list,parent:data.parent,child_count:0,parent:data.parentItem,parentID:data.parentItem.id,children:null,isAggregate:true,parentItem:data.parentItem}
var item=this.createListElement(node,list,data);list.appendChild(item);}
for(index in keywords)
{var item=this.createListElement(keywords[index],list,data);list.appendChild(item);keywords[index].node=item;}
params={auto:(data.auto?true:false),parent:(data.menu?data.menu:null),list:list,defaultValue:"<h2>Select A Sub-Category</h2>"}
var menu=this.generateMenu(params);return menu;}
keywordList.prototype.updateBreadcrumbs=function(item)
{this.breadcrumbContainer.innerHTML="";var menu=item.list.menu;var breadcrumbs=[];while(menu!=null)
{breadcrumbs.push(menu.list.activeTab);menu=menu.last;}
while(breadcrumbs.length>0)
{var item=document.createElement("a");var node=breadcrumbs.pop();item.innerHTML=node.innerHTML;this.breadcrumbContainer.appendChild(item);item.link=node;item.onclick=function()
{$(this.link).click();}
var span=document.createElement("span");span.innerHTML=(breadcrumbs.length>=1?">":"");this.breadcrumbContainer.appendChild(span);}}
keywordList.prototype.setInitID=function(id)
{this.initID=id;return this.initID;}
keywordList.prototype.autoScroll=function()
{var menu=this.menu;while(menu!=null)
{var node=menu.list.activeTab;if(node!=null)
{if((menu.slider!=null))
{try
{if((menu.slider!=null)&&(menu.slider.slider))
{menu.slider.nudgeByPixels(getCenterPtForNode(menu,node));}}
catch(e)
{}}}
var menu=menu.next;}}
function getCenterPtForNode(menu,node)
{$(menu.listWrapper).scrollTop(0);var h=parseInt($(menu.listWrapper).height());var c=parseInt($(menu.list).outerHeight());var pos=parseInt($(node).position().top)-(h/2);return pos;}
keywordList.prototype.autoSelect=function(id,noPop)
{if(this.initialized!=true)
return false;if(id=="default")
id=1;if(!id)
{this.autoScroll();return false;}
this.initID=false;if(!this.keywords)
return false;var keyword=this.getNode(id,this.keywords);if((!keyword)&&(id!=1))
this.autoSelect(1,noPop);var stack=new Array();stack.push(keyword);if((!this.field.value)&&(!noPop))
{this.field.setValue(keyword.node_value);this.field.setID(keyword.node_id);}
while(keyword.parent)
{keyword=this.getNode(keyword.parent,this.keywords);stack.push(keyword);}
if(!this.menu)
{this.menu=this.displayChildren({parentItem:null,parentID:null,keywords:this.keywords,menu:null,auto:true});}
var targetMenu=this.menu;var deleteStack=[];var meue=this.menu;while(meue.next!=null)
{deleteStack.push(meue.next);var meue=meue.next;}
while(deleteStack.length>0)
{this.removeMenu(deleteStack.pop());}
while(stack.length>0)
{keyword=stack.pop();if(keyword==false)
return false;var node=keyword.node;if(node==null)
break;node.decorate();try{if((targetMenu.slider!=null)&&(targetMenu.slider.slider))
{targetMenu.slider.nudgeByPixels(getCenterPtForNode(targetMenu,node));}}
catch(ex)
{}
if(keyword.children)
{if(targetMenu)
{var targetMenu=this.displayChildren({parentItem:node,parentID:keyword.node_id,keywords:keyword.children,menu:targetMenu,auto:true});}}}
this.updateBreadcrumbs(node);}
keywordList.prototype.getNode=function(id,keywords)
{if(keywords==undefined)
return false;if(keywords[id])
{return keywords[id];}
else
{for(index in keywords)
{if(id=="default")
return keywords[index];if(keywords[index].child_count>0)
{var result=this.getNode(id,keywords[index].children);if(result)
return result;}}}}
keywordList.prototype.addScrollCtrl=function(item,dir)
{switch(dir)
{case"up":item.onmouseout=function(e)
{clearInterval(this.interval);$(this).removeClass('hover');if($(this.menu.listWrapper).scrollTop()==0)
{$(this).addClass('inactive');}
else
{$(this).removeClass('inactive');}}
item.onmouseover=function(e)
{var item=this;$(this).addClass('hover');this.interval=setInterval(function()
{if($(item.menu.listWrapper).scrollTop()!=0)
{$(item.menu.down).removeClass("inactive");var scroll=$(item.menu.listWrapper).scrollTop()-27;$(item.menu.listWrapper).scrollTop(scroll);item.menu.slider.nudge(scroll);}
else
{clearInterval(item.interval)
$(item).addClass('inactive');}},220);}
item.update=function(pos)
{var height=($(this.menu.list).outerHeight());var top=$(this.menu.listWrapper).scrollTop();var wrapHeight=$(this.menu.listWrapper).height();if(wrapHeight>height)
$(this).addClass("disabled");else
$(this).removeClass("disabled");if($(this.menu.listWrapper).scrollTop()==0)
$(this).addClass('inactive');else
$(this).removeClass('inactive');}
break;case"down":item.onmouseout=function(e)
{clearInterval(this.interval);var height=($(this.menu.list).outerHeight());var top=$(this.menu.listWrapper).scrollTop();var wrapHeight=$(this.menu.listWrapper).height();$(this).removeClass('hover');if((height-top)<=wrapHeight)
$(this).addClass('inactive');}
item.onmouseover=function(e)
{var item=this;$(this).addClass('hover');this.interval=setInterval(function()
{var height=($(item.menu.list).outerHeight());var top=$(item.menu.listWrapper).scrollTop();var wrapHeight=$(item.menu.listWrapper).height();if(((height-top)>wrapHeight)&&(height>wrapHeight))
{$(item.menu.up).removeClass("inactive");var scroll=$(item.menu.listWrapper).scrollTop()+27;item.menu.slider.nudge(scroll);$(item.menu.listWrapper).scrollTop(scroll);}
else
{clearInterval(item.interval)
$(item).addClass('inactive');}},220);}
item.update=function(pos)
{var height=($(this.menu.list).outerHeight());var top=$(this.menu.listWrapper).scrollTop();var wrapHeight=$(this.menu.listWrapper).height();if(wrapHeight>height)
{$(this).addClass("disabled");$(this).removeClass("inactive");}
else
{$(this).removeClass("disabled");if((height-top)<=wrapHeight)
$(this).addClass('inactive');else
$(this).removeClass('inactive');}}
break;}}
keywordList.prototype.makeSlidable=function(container)
{var slider=document.createElement("div");$(slider).addClass("sliderBar");container.isSlide=true;container.slider=slider;var height=($(container.menu.list).outerHeight());var wrapHeight=$(container.menu.listWrapper).height();container.appendChild(slider);slider.container=container;if(wrapHeight<height)
$(container.slider).css("margin-top",0);else
$(container.slider).hide();var percent=wrapHeight/height;var dudeHeight=($(container).height()*percent);var dudeHeight=40;$(slider).css("height",dudeHeight);$(slider).hide();container.reset=function(distance)
{$(this.slider).hide();}
container.nudgeByPixels=function(distance)
{$(this.menu.listWrapper).scrollTop(distance);this.nudge(distance);this.menu.up.update(distance);this.menu.down.update(distance);}
container.nudge=function(distance)
{return false;var height=($(this.menu.list).outerHeight());var wrapHeight=$(this.menu.listWrapper).height();var max=(height-wrapHeight);var percent=distance/max;var top=percent*$(this).height();top=top-($(slider).height()/2);$(this.slider).css("margin-top",top);}
container.moveResults=function(percent)
{var height=($(this.menu.list).outerHeight());var wrapHeight=$(this.menu.listWrapper).height();var max=(height-wrapHeight)
var coor=max*percent;this.menu.up.update();this.menu.down.update();$(this.menu.listWrapper).scrollTop(coor);}
slider.endDrag=function(e)
{$(this).css("cursor","pointer");this.scroll=0;this.onmousemove=null;}
slider.move=function(e)
{if(this.scroll==1)
{var containerHeight=$(this.container).height();var y=this.startMargin+(e.clientY-this.startY);if((y>0)||(y<containerHeight))
{$(this).css("margin-top",y);var percent=parseInt($(this).css("margin-top"))/height;this.container.moveResults(percent);}}}
slider.onmousedown=function(e)
{this.startY=e.clientY;$(this).css("cursor","move");this.startMargin=parseInt($(this).css("margin-top"));this.scroll=1;slider.onmousemove=function(e)
{}
slider.onmouseup=function(e)
{}}}
function applyScroller(node)
{$(node).mousemove(function(e)
{if(!this.interval)
{var inactiveMargin=140;var wrapperWidth=$(this).width();var wrapperHeight=$(this).height();var scrollableHeight=$(this).children("ul").outerHeight()+2*inactiveMargin;var wrapperOffset=$(this).offset();if(top<0)
{top=0;}
this.currentTop=(this.top!=null?this.top:0);this.top=(e.pageY-wrapperOffset.top)*(scrollableHeight-wrapperHeight)/wrapperHeight-inactiveMargin;var node=this;var top=this.top;this.time=1;this.dir=(node.top>node.currentTop?1:0);this.interval=setInterval(function()
{d=100;if(node.time>=d)
{node.currentTop=node.top;clearInterval(node.interval);node.interval=false;}
var t=node.time;var c=node.top;var b=node.currentTop;$("#wrapper").text(node.currentTop+":"+node.top);node.time=(node.time+1);$(node).scrollTop(c*Math.sin(t/d*(Math.PI/2))+b);},4);}});}
keywordList.prototype.createListElement=function(nodeData,list,data)
{var item=document.createElement("li");if(nodeData.child_count>=1)
{jQuery(item).addClass("hasChildren");jQuery(item).addClass("inactiveParent");isParents=true;}
var content=(nodeData.node_value!=null?nodeData.node_value.toLowerCase():'');item.value=content;item.listHandler=this;item.parentID=data.parentID;item.list=list;item.parent=nodeData.parent;item.parentID=nodeData.parentID;item.inert=(nodeData.inert!=null?true:false);item.keywords=nodeData.children;if((nodeData.child_count!=null)&&(nodeData.child_count>=1))
item.keywords=nodeData.children;else
item.keywords=false;item.child_count=nodeData.child_count;item.isAggregate=(nodeData.isAggregate!=null?true:false);item.id=(nodeData.isAggregate!=null?null:nodeData.node_id);item.parentItem=(data.parentItem!=null?data.parentItem:null);item.decorate=function()
{if((this.list.activeTab!=null)&&(this.list.activeTab!==this))
{$nodeSibling=$(this.list.activeTab);if(this.list.activeTab.child_count>0)
{$nodeSibling.removeClass("artifact");$nodeSibling.removeClass("activeParent");$nodeSibling.addClass("inactiveParent");}
else
$nodeSibling.removeClass("active");}
if(this.parentItem!=null)
{var $parentDiv=$(this.parentItem);$parentDiv.removeClass("activeParent");$parentDiv.addClass("artifact");}
$node=$(this);if(this.child_count>0)
{$node.removeClass("artifact");$node.removeClass("inactiveParent");$node.addClass("activeParent");}
else
$node.addClass("active");this.list.activeTab=this;}
jQuery(item).text(content);if(item.isAggregate)
{this.attachMenuEvent(item);$(item).click(function()
{$(this.parentItem).click();});}
else
this.attachMenuEvent(item);return item;}
keywordList.prototype._destruct=function()
{var count=0;for(var i in this)
{if(this[i]!=null)
{if(this[i]._destruct!=null)
this[i]._destruct();else
this[i]=null;count++;}}
delete this;}
function keywordToID(keywordField,idField)
{this.gettingID=false;this.valid=0
if((keywordField==null)||(idField==null))
{}
else
{this.keywordField=keywordField;this.idField=idField;this.isReady=0;this.legend="Did You Mean?";this.typeField=null;switch(this.keywordField.name)
{case"categoryName":this.prefix="what";this.styleID="search_what";this.label="Category";break;case"locationName":this.prefix="where";this.styleID="search_where";this.typeField=this.keywordField.typeField;this.label="Location";break;case"date":this.prefix="when";this.styleID="search_when";this.label="Date";break;default:this.prefix="field";this.styleID="error";this.label="";}}
objects.push(this);this.REQUEST_URL=AJAX_PATH+"search_requests.php";}
keywordToID.prototype.isValid=function()
{if(!this.hasValue())
{return true;}
else if((this.yankID()!=0&&(this.hasValue())))
{if((this.keywordField.typeField!=null)&&(!this.yankType()))
return false;return true;}
else
return false;}
keywordToID.prototype.hasValue=function()
{if(this.yankValue())
return true;else
return false;}
keywordToID.prototype.yankValue=function()
{if((this.keywordField.value)&&(this.keywordField.value!=$(this.keywordField).attr("default_value")))
return this.keywordField.value;else
return false;}
keywordToID.prototype.yankID=function()
{return this.idField.value;}
keywordToID.prototype.yankType=function()
{if(this.keywordField.typeField!=null)
return this.keywordField.typeField.value;}
keywordToID.prototype.getData=function()
{var result={};if(this.yankValue())
{var name=this.keywordField.name;var value=this.yankValue();result[name]=value;result[this.idField.name]=this.idField.value;return result;}
else
return null;}
keywordToID.prototype.area=false;keywordToID.prototype.isGoodEnough=function()
{if(!this.isValid())
return false;else
return true;}
keywordToID.prototype.displayMatches=function(data)
{if(data==null)
{this.setID({id:false,noHide:true});return false;}
if(this.area)
{$(area).remove();}
if(data.error)
{var header=document.createElement("p");var p=document.createElement("p");var blank=this.keywordField.value;if(blank.length>12)
var blank=blank.substring(0,9)+"...";header.innerHTML="Sorry, we didnt understand <strong>&quot;"+blank+"&quot;</strong>";var span2=document.createElement("span");var strong=document.createElement("strong");strong.appendChild(document.createTextNode("tip:"));var anchor=document.createElement("a");anchor.src="#";if(this.prefix=="where")
anchor.innerHTML="interactive map";else
anchor.innerHTML=this.label.toLowerCase()+" menu";anchor.handler=this;anchor.onclick=function()
{this.handler.close();this.handler.keywordField.toggleMenu();}
p.appendChild(strong);p.appendChild(document.createTextNode(" browse the "));p.appendChild(anchor);trackSearchEvent([this.prefix+'_didyoumean_unresolved',this.keywordField.value],true);this.setID({id:false,noHide:true});var area=this.displayBubble(true,[header,p]);this.area=area;this.isReady="ready";return false;}
else if(data.length>1)
{trackSearchEvent([this.prefix+'_didyoumean_resolved',this.keywordField.value],true);var listSet=document.createElement("ul");for(index in data.nodes)
{var nodeData=data.nodes[index];var itemCtr=document.createElement("li");var item=document.createElement("a");item.node_value=nodeData.node_value.toLowerCase();item.node_id=nodeData.node_id;$(item).text(item.node_value);$(item).val(nodeData.node_id);item.handler=this;item.area=area;$(item).click(function()
{this.handler.setID({keyword:this.node_value,id:this.node_id,overwrite:true});trackSearchEvent([this.handler.prefix+'_didyoumean_select',this.node_value],true);});item.value=item.node_value;itemCtr.appendChild(item);listSet.appendChild(itemCtr);}
var header=document.createElement("p");header.appendChild(document.createTextNode("Did you mean?"));var area=this.displayBubble(true,[header,listSet]);this.area=area;this.isReady="ready";this.valid=0;}
else if(data.node!=undefined)
{var node=data.node;this.setID({keyword:node.node_value,type:(node.type!=null?node.type:null),id:node.node_id,overwrite:false});}
else
{return false;}}
keywordToID.prototype.setMenu=function(item)
{this.listObj=item;}
keywordToID.prototype.close=function()
{this.popup.close();}
keywordToID.prototype.setID=function(data)
{if
((this.area!=false)&&(!data.noHide))
{this.close();}
if((this.keywordField.typeField!=null)&&(data.type))
{this.keywordField.typeField.value=data.type;}
if(data.id)
{this.idField.value=data.id;if(data.overwrite==true)
this.keywordField.setValue(data.keyword,(this.keywordField.typeField!=null?data.type:false));this.valid=1;if((this.listObj)&&(data.id>0))
this.listObj.setInitID(data.id);}
else
{this.valid=0;}
this.isReady='ready';}
keywordToID.prototype.displayBubble=function(hasMatches,nodes)
{var stem=document.createElement("div");$(stem).addClass("bubble_stem");var area=document.createElement("div");area.appendChild(stem);area.id="keywordMatch_"+this.styleID;$(area).addClass((hasMatches?"matches":"no_match"));var container=document.createElement("div");$(container).addClass("bubble_body");for(var i in nodes)
container.appendChild(nodes[i]);area.appendChild(container);this.popup=new Popup
({container:this.keywordField.container.get(0),content:area,isMask:false,position:"none",wrapperStyle:"keywordMatchContainer",customClass:true,isShell:false,fixed:false});this.popup.display();return this.popup.getNode();}
keywordToID.prototype._destruct=function()
{var count=0;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 DateVerifier(value,id)
{var from=keywordToID.prototype;for(m in from)
{if(this[m]==null)
this[m]=from[m];}
this.superclass(value,id);}
DateVerifier.prototype.action="verifyDate";DateVerifier.prototype.superclass=keywordToID;var keys={BACKSPACE:8,RETURN:13,DELETE:46,ESCAPE:27,DOWN:40,UP:38,TAB:9,RIGHT:39,LEFT:37,SPACE:32}
var browseSet=new Array();browseSet['what']={tab:'browse_what',inputLink:'link_what',input:'search_what_box',browser:'browser_what',browserMenu:'what_content',storage:'what_id',tracker:"what",suggest:'suggested_what',hiddenText:'what_string'}
browseSet['where']={tab:'browse_where',inputLink:'link_where',input:'search_where_box',storage:'where_id',browserMenu:'where_list',tracker:"where",browser:'browser_where',suggest:'suggested_where',hiddenText:'where_string',menuObject:'whatever',typeField:"where_type"}
browseSet['when']={tab:'browse_when',tracker:"when",inputLink:'link_when',input:'search_when_box',input2:'when_end',storage:'when_id',browserMenu:'when_area',browser:'browser_when',suggest:'suggested_when',hiddenText:'when_string'}
$(document).ready(function()
{var ScriptLoader=Goby.get("scriptLoader");if(Goby.has("scriptLoader"))
ScriptLoader.loadQueuedScripts();var container=document.createElement("div");container.className="clientContainer";document.body.insertBefore(container,document.body.childNodes[0]);$("#where_toggle_wrapper input").click(function()
{$(this).siblings("input").each(function()
{hideFlash($(this).attr("value"));$($(this).attr("value")).hide();});var divID=$(this).attr("value");setTimeout("showFlash('"+$(this).attr("value")+"')",1000);$(divID).show();if(browseMap[divID.replace("#","")])
{var myBrowseMap=browseMap[divID.replace("#","")];if(myBrowseMap.menuObject)
eval(myBrowseMap.menuAction);}});$("#where_toggle_wrapper input").each(function()
{if($(this).is(":checked"))
$($(this).val()).show();else
$($(this).val()).hide();});try
{Goby.set('searchbox',new Searchbox((document.forms.searchbox!=null?document.forms.searchbox:window.parent.document.forms.searchbox),{what:new WhatField(document.getElementById(browseMap.what.input)),where:new WhereField(document.getElementById(browseMap.where.input)),when:new WhenField(document.getElementById(browseMap.when.input))}));}
catch(e)
{alert(e.message);}
_initExamples();});j=0;k=0;browseMap=new Object;for(index in browseSet)
{browseTabs=browseSet[index];for(index2 in browseTabs)
{data=new Object;browseData=browseTabs;for(index3 in browseData)
if(index3!=index2)
data[index3]=browseData[index3];else
data[index3]="self";k++;browseMap[browseTabs[index2]]=data;}
j++;}
var activeTextbox=false;var activeMenu=false;function loveOn(node,type)
{if(node.loveNode==null)
{node.loveNode=document.createElement("div");node.loveNode.id=type;node.appendChild(node.loveNode);}}
function loveOff(node)
{if(node.loveNode!=null)
{node.removeChild(node.loveNode);node.loveNode=null;}}
function _initExamples()
{if($(".example").is(":visible"))
{$(".example a").click(function()
{this.href="#";var data=this.className.toString().split("|");(Goby.has('searchbox')?Goby.get("searchbox").autoSelect(data[0],data[1],data[2]):'');});}}
function autoSelect(type,id,value)
{(Goby.has('searchbox')?Goby.get("searchbox").autoSelect(type,id,value):'');}
Searchbox=function(form,fields)
{this.form=form;for(var i in fields)
fields[i].searchbox=this;this.fields=fields;this.init();this.form.submitted=false;this.request=null;this.validators={};this.interval=null;this.openSgn=[];this.submitbutton=$("#search_submit").get(0);if(this.submitbutton!=null)
{$(this.submitbutton).mouseover(function(){if(this.form.submitted==false){$(this).css({backgroundPosition:'0px -33px'});}});$(this.submitbutton).mouseout(function(){if(this.form.submitted==false){$(this).css({backgroundPosition:'0px 0px'});}});$(this.submitbutton).focus(function(){if(this.form.submitted==false){$(this).css({backgroundPosition:'0px -66px'});}});$(this.submitbutton).blur(function(){if(this.form.submitted==false){$(this).css({backgroundPosition:'0px 0px'});}});$(this.submitbutton).click(function(){if(this.form.submitted==false){$(this).css({backgroundPosition:'0px -99px'});}});}
objects.push(this);}
Searchbox.prototype={activePanel:null,getField:function(name)
{if(this.fields[name])
return this.fields[name];else
return null;},destroyConverters:function()
{delete this.when;delete this.where;delete this.what;},getCategoryID:function()
{return this.fields.what.storage.value;},getLocationID:function()
{return this.fields.where.storage.value;},autoSelect:function(type,id,value)
{var field=this.fields[type];field.setValue(value);field.storage.value=id;if(id==6699)
return false;if(field.keywordList!=null)
field.keywordList.setInitID(id);},closeSuggestions:function()
{for(var i in this.fields)
if(this.fields[i].suggestion!=null)
this.fields[i].suggestion.closeList();},init:function()
{this.form.searchbox=this;this.form.onsubmit=function()
{try
{if(this.request!=null)
this.request.terminateRequest();this.submitted=true;this.searchbox.validateSearch();}
catch(e)
{}
return false;}},validateSearch:function()
{trackSearchEvent(['searchbutton']);var fields=this.fields;this.validators={};this.validators.what=new keywordToID(fields.what,fields.what.storage);this.validators.where=new keywordToID(fields.where,fields.where.storage);this.validators.when=new DateVerifier(fields.when,fields.when.storage);var searchbox=this;var data={};data.action="validateSearch";var goodEnough=true;for(var i in this.validators)
{var validator=this.validators[i];if(!validator.isGoodEnough())
{var contents=validator.getData();for(var i in contents)
data[i]=contents[i];goodEnough=false;}}
var callback={"object":this,"method":"sendResponse"}
if(goodEnough)
{this.sendResponse({bypass:true});}
else
{var adtlParams={useLoader:true,loaderParent:this.getSubmitBox().parentNode,loaderClass:"loader_submit",append:false}
this.request=new AjaxRequest(AJAX_PATH+"search_requests.php",callback,data);this.request.makeRequest(adtlParams);}},getSubmitBox:function()
{return this.submitbutton;},getTitle:function()
{var params={locationID:this.validators.where.yankID(),locationName:this.validators.where.yankValue(),locationType:this.validators.where.yankType(),categoryID:this.validators.what.yankID(),categoryName:this.validators.what.yankValue(),dateID:this.validators.when.yankID(),dateName:this.validators.when.yankValue()};return getPageTitle(params,this.pageType);},sendResponse:function(data)
{if(data.bypass!=null)
{}
else
{for(var i in this.validators)
if(data[i]!=null)
this.validators[i].displayMatches(data[i]);}
var urlparams={locationID:this.validators.where.yankID(),locationName:this.validators.where.yankValue(),locationType:this.validators.where.yankType(),categoryID:this.validators.what.yankID(),categoryName:this.validators.what.yankValue(),dateID:this.validators.when.yankID(),dateName:this.validators.when.yankValue(),debug:false};if(!this.validators.when.isValid())
{}
else if(!this.validators.where.hasValue()&&(this.validators.what.yankID()!=6699))
{var head=document.createElement("p");head.innerHTML="Please enter a city or state";this.validators.where.displayBubble(true,[head]);}
else if((!this.validators.where.isValid())||(!this.validators.what.isValid()))
{}
else if(((this.validators.what.hasValue())&&(this.validators.where.hasValue()))||((this.validators.what.hasValue())&&(this.validators.where.hasValue()))||((this.validators.what.hasValue())&&(!this.validators.where.hasValue()))||((!this.validators.what.hasValue())&&(this.validators.where.hasValue())))
{this.pageType="search";new SearchLink(urlparams).open();}
else
{alert('not sure.');}},isActivePanel:function(panel)
{return(this.activePanel===panel?true:false);},getActivePanel:function()
{return this.activePanel;},setActivePanel:function(panel)
{return(this.activePanel=panel);},closeActivePanel:function()
{(this.activePanel!=null?this.activePanel.close():'');},_destruct:function()
{var count=0;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 SearchLink(params,anchor)
{if(params.debug!=null)
this.debug=params.debug;if(params.type=="url"&&params.url)
{var params=this.constructParams(params.url);this.bypass=true;}
else if(params.type=="mimic")
{if(goby.embedded){this.bypass=true;}
var _params=this.constructParams(params.url);params.type="mimic";for(var i in params)
_params[i]=params[i];params=_params;this.debug=true;}
else
this.bypass=true;if(anchor!=null)
this.anchor=anchor;this.params=params;}
SearchLink.prototype={bypass:false,debug:false,popup:null,getUrl:function()
{return getFormattedUrl(this.params,"search");},open:function()
{this.url=this.getUrl();if(!this.bypass){this.renderPopup();}
else
return this.loadPage();if((this.debug!=true)&&(this.params.type!="mimic"))
{this.request=new AjaxRequest(this.getUrl(),{method:"loadPage",object:this},{},"GET");this.request.makeRequest();}},getTitle:function()
{return getPageTitle(this.params,"search");},renderSubmitbox:function()
{var submitbox=Goby.get("searchbox").getSubmitBox();if(submitbox==null)
return false;var container=submitbox.parentNode;container.removeChild(submitbox);var div=document.createElement("div")
$(div).attr("id","search_inert");$(div).css({backgroundPosition:'0px -99px'});var loader=document.createElement("div");loader.className="loader_submit";container.appendChild(loader);container.appendChild(div);},renderPopup:function()
{var iteratorData=getWrappers();var count=0;var content=document.createElement("div");var clear=document.createElement("div");content.className="loader_wrapper";var iteratorTitle=document.createElement("h3");clear.className="clear";var iteratorDiv=document.createElement("div");var iteratorIco=document.createElement("div");var title="searching the web for information about <strong>"+
this.getTitle()+"</strong>";iteratorTitle.innerHTML=title.toString().toLowerCase();content.id=(PAGE_ID=="home"?"loaderPopup-home":"loaderPopup-page");content.appendChild(iteratorTitle);content.appendChild(clear);content.appendChild(iteratorIco);content.appendChild(iteratorDiv);var popup=new Popup({container:(this.params.parent?this.params.parent:document.body),content:content,fixed:true,isMask:true,useBlind:true,blindClass:(PAGE_ID=="home"?"pageBlind-home":"pageBlind-page"),mask:"#wrapper",position:"none",slidable:false,closerText:"cancel",maskOpacity:0.3,isShell:true,isCloser:false,noClick:true});window.scrollTo(0,0);popup.display();this.popup=popup;if(popup.closerNode!=null)
{$(popup.closerNode).css("position","absolute");$(popup.closerNode).css("marginLeft",$(popup.closerNode).width()-($(popup.closerNode).width()*2));$(popup.closerNode).css("margin-left",$(popup.closerNode).width()-($(popup.closerNode).width()*2));popup.shell.bot.right.appendChild(popup.closerNode);popup.searchLink=this;popup.close=function()
{this.hide();this.closed=true;if(this.verifyClose!=null)
this.verifyClose.destruct();if(this.searchLink.request!=null)
this.searchLink.request.terminateRequest();$("#search_inert").remove();$("#search_submit").show();}}
iteratorDiv.iterations=0;iteratorDiv.handler=this;var loadInterval=setInterval(function()
{if(iteratorDiv.iterations>300)
iteratorDiv.handler.close();iteratorDiv.iterations++;var data=iteratorData.pop();if(data.status==1)
iteratorIco.className="good";else
iteratorIco.className="bad";iteratorDiv.innerHTML=data.text;iteratorData.unshift(data);},100);},close:function()
{if(this.popup!=null)
this.popup.close();},_destruct:function()
{this.close();for(var i in this)
this[i]=null;},loadPage:function(data)
{this.renderSubmitbox();if((this.popup!=null)&&(this.popup.closerNode!=null))
$(this.popup.closerNode).fadeOut(100);window.open(this.getUrl(),"_self");},constructParams:function(str)
{var params={};var regex={"pg":"/pg-([0-9]{1,99})[/]??","date":"/date-([a-z0-9+-]{1,99})[/]??"}
var str=str.replace(BASE_PATH,'');var results=str.match("[/]??([a-z-+]{1,99}(?=--near--|--around--|--in--))(--near--|--around--|--in--)([^/][a-z-+]{1,99})[/]??");if(results)
{params.categoryName=results[1].urlDecode();params.locationName=results[3].urlDecode();params.locationType=(str.match("--near--")?"CITY":"REGION");}
else
{var results=str.match("[/]??([a-z+-]+?)([/]|/date-[a-z-+]+?)??$");if(results)
{params.locationName=results[1].urlDecode();params.locationType="UNKNOWN";}}
for(var i in regex)
{var result=str.match(regex[i]);params[i]=(result?result[1].urlDecode():null);}
return params;}}
var PANEL_CLOSE=0;var PANEL_OPEN=1;function SearchField(node)
{if(node!=null)
return this._construct(node)}
SearchField.prototype={_construct:function(node)
{if(!node)
return false;objects.push(node);for(var i in this)
node[i]=this[i];initField(node);return node;},getID:function()
{return this.storage.value;},setID:function(id)
{this.storage.value=id;},panelCallback:function(action)
{},loadSuggestions:function()
{this.suggestion=new keywordSuggest(this.id,this.storage.id);return this.suggestion;},_destruct:function()
{for(var i in this)
this[i]=null;}}
function WhatField(node)
{var node=this._construct(node);var whatSuggestion=node.loadSuggestions();whatSuggestion.inProgress=function(){return false;}
whatSuggestion.formatPhrase=function(phrase)
{if(phrase)
{var phrase=phrase.toLowerCase();return phrase;}}
return node;}
WhatField.prototype=new SearchField;WhatField.prototype.panelCallback=function(action)
{if(action==PANEL_OPEN)
{if(this.list==null)
{this.list=new keywordList(this.panel.getBodyNode(),"local",this);this.list.setInitID(this.searchbox.getCategoryID()?this.searchbox.getCategoryID():1);this.suggestion.setListObj(this.list);}
this.list.initKeywords();}
else
{this.list.close();}}
function WhereField(node)
{var node=this._construct(node);var suggestion=node.loadSuggestions();suggestion.inProgress=function()
{return false;}
suggestion.formatPhrase=function(phrase)
{if(phrase)
{var phrase=phrase.toLowerCase();return phrase;}}
return node;}
WhereField.prototype=new SearchField;WhereField.prototype.panelCallback=function(action)
{if(action==PANEL_OPEN)
{var container=this.panel.getBodyNode();if(!container.flash)
{container.flash=initFlashMap('us','search');$(container).html(container.flash);}}
else
{}}
function WhenField(node)
{return this._construct(node);}
WhenField.prototype=new SearchField;WhenField.prototype.panelCallback=function(action)
{if(action==PANEL_OPEN)
{if(this.datePanel==null)
this.datePanel=new DatePanel(this.panel.getBodyNode());}
else
{}}
function Panel(inputElement)
{this.field=inputElement;this.target=document.createElement("div");this.target.className="browser_wrapper clearfix";this.target.style.marginTop="0";this.searchbox=this.field.searchbox;this.target.id=this.field.map.browser;$(this.field.container).append(this.target);this.target.style.display="block";}
Panel.prototype={isTrackable:false,setTrackable:function(val)
{this.isTrackable=val;},open:function()
{this.searchbox.setActivePanel(this);if(this.isTrackable)
trackSearchEvent([this.field.map.tracker+"_down"]);if(this.field.suggestion!=null)
try{this.field.suggestion.closeList();}
catch(e){}
$(this.field).focus();this.field.highlight(1);this.perf={stem:document.createElement("div"),header:document.createElement("div"),footer:document.createElement("div")}
this.perf.body=this.getBodyNode();this.perf.stem.className="browser_stem";this.perf.header.className="searchbox_header";this.perf.header.innerHTML="<div class=\"left\"></div><div class=\"content\"></div><div class=\"right\"></div>";this.perf.footer.className="searchbox_footer";this.perf.footer.innerHTML="<div class=\"left\"></div><div class=\"content\"></div><div class=\"right\"></div>";this.field.panelCallback(PANEL_OPEN);$(this.field.container).addClass("tb_active");$(this.field.button).addClass("textbox_link_active");$(this.target).prepend(this.perf.header);$(this.target).prepend(this.perf.stem);$(this.target).append(this.perf.body);$(this.target).append(this.perf.footer);this.target.style.display="block";var safeWrappers=[];safeWrappers[this.field.id+'=target']=this.target;safeWrappers[this.field.id+'=field']=this.field.container;this.kCloser=new keywordCloser(safeWrappers,{object:this,method:"close"});this.kCloser.initStgClick(100);},getBodyNode:function()
{if(this.body)
{$(this.body).show();return this.body;}
else
{var body=document.createElement("div");body.id=this.field.map.browserMenu;body.className='browser_content';this.body=body;return body;}},storeNode:function(node)
{$(node).hide();},close:function()
{this.searchbox.setActivePanel(null);if(this.isTrackable)
trackSearchEvent([this.field.map.tracker+"_up"]);this.kCloser.destruct();this.field.highlight(2);$(this.field.button).removeClass("textbox_link_active");$(this.field.container).removeClass("tb_active");this.target.style.display="none";for(var i in this.perf)
if(this.perf[i]!=this.body)
this.target.removeChild(this.perf[i]);this.field.panelCallback(PANEL_CLOSE);}}
function DatePanel(div)
{this.ACTIVE_CALENDAR=true;this.REQUEST_URL=AJAX_PATH+"search_requests.php";this.container=div;this.setCurrent(document.getElementById(browseSet.when.storage).value);this.field=document.getElementById(browseSet.when.input);this.currentNode=null;this.field.datepanel=this;this.init();$(this.field).bind("keyup.datepanel",function()
{if(!this.storage.value)
{this.datepanel.reset();}});$(this.field.deletebox).bind("click.datepanel",function()
{var field=$(this).data("field");field.datepanel.reset();});objects.push(this);}
DatePanel.prototype.reset=function(action)
{this.current=null;if(this.currentNode=="calendar")
{this.dateform.reset();}
else if(this.currentNode!=null)
{$(this.currentNode).removeClass("sel");}
this.currentNode=null;}
DatePanel.prototype.setCurrent=function(value,node)
{this.current=value;if(node!=null)
{this.currentNode=node;$(this.currentNode).addClass("sel");}}
DatePanel.prototype.getCurrentType=function()
{if(this.current.match())
return"span";else if(this.current.match())
return"one";else
return"id";}
DatePanel.prototype.getCurrent=function()
{return this.current;}
DatePanel.prototype.isCurrent=function(id)
{if(this.current==id)
return true;else
return false;}
DatePanel.prototype.init=function()
{var data=[];data['action']="initDatePanel";callbackParams={object:this,method:"load"}
var adtlParams={useLoader:true,loaderParent:this.container,loaderClass:"loader_keywordList"}
var aRequest=new AjaxRequest(this.REQUEST_URL,callbackParams,data,"GET");aRequest.makeRequest(adtlParams);}
DatePanel.prototype.load=function(data)
{$(this.container).html(data.tpl);this.list=document.createElement("ul");$(this.container).prepend(this.list);this.setTimestamps(data.timestamps);this.linkDates("whenlinks");document.forms.dateForm.datepanel=this;this.dateform=initDateForm(document.forms.dateForm);}
DatePanel.prototype.setTimestamps=function(stamps)
{this.timestamps=stamps;}
DatePanel.prototype.getTimestamp=function(id)
{if(this.timestamps[id])
return this.timestamps[id];}
DatePanel.prototype.activateCalendar=function()
{this.ACTIVE_CALENDAR=true;if(document.forms.dateForm!=null)
$(document.forms.dateForm).show();}
DatePanel.prototype.linkDates=function(div)
{var list=this.list;for(var index in this.timestamps)
{var timestamp=this.timestamps[index];var li=document.createElement("li");var a=document.createElement("a");li.appendChild(a);li.timestamp=timestamp;li.datepanel=this;a.appendChild(document.createTextNode(timestamp.text))
if(this.isCurrent(timestamp.id))
{this.setCurrent(timestamp.id,li);}
$(li).click(function()
{var stamp=this.timestamp;var dateObj1=new Date(stamp.start);var dateObj2=new Date(stamp.end);$(this).siblings().removeClass("sel");this.datepanel.reset();this.datepanel.setCurrent(stamp.id,this);setDate({'start':dateObj1,'end':dateObj2,'label':stamp.text,'id':stamp.id});this.datepanel.field.closePanel();});list.appendChild(li);}}
function makeDateField(field)
{field.defaultValue="mm/dd/yy";field.reset=function()
{this.value=this.defaultValue;$(this).addClass("asleep");this.date=null;}
$(field).blur(function()
{if((!this.value)||(this.value=this.defaultValue))
this.reset();});field.onkeyup=function()
{if(this.value)
$(this).removeClass("asleep");this.date=null;}
$(field).click(function()
{if(this.defaultValue==this.value)
{this.value='';$(this.datebox).removeClass("asleep");}
var target=document.getElementById($(this).attr("target"));target.closeCalendar=function()
{$(this).datepicker('destroy');this.closer.destruct();}
if(this.isAnfang)
{var minimum=new Date();var dateDefault=(this.date!=null?this.date:'');}
else if(this.isEnde)
{var minimum=(this.anfang.date!=null?this.anfang.date:new Date());var dateDefault=(this.date!=null?this.date:'');}
target.datebox=this;$(target).datepicker({inline:true,minDate:minimum,defaultDate:dateDefault,gotoCurrent:true,onSelect:function(dateText,inst)
{this.date=$(this).datepicker('getDate');$(this.datebox).removeClass("asleep");this.datebox.value=formatDate(this.date);this.datebox.date=this.date;if((this.datebox.isAnfang)&&(this.datebox.date>this.datebox.ende.date))
{this.datebox.ende.reset();}
this.closeCalendar();}});var sw=[];sw[target.id]=target;var closer=new keywordCloser(sw,{object:target,method:"closeCalendar"});closer.initStgClick(100);target.closer=closer;});field.init=function()
{if((!this.value)||(this.value=this.defaultValue))
{this.reset();}}
field.init();return field;}
function initCalendars()
{var date1=document.getElementById('date_anfang');var date2=document.getElementById('date_ende');date1.ende=date2;date1.isAnfang=true;date2.anfang=date1;date2.isEnde=true;var dates=[];dates.push(makeDateField(date1));dates.push(makeDateField(date2));return dates;}
if(DATESTAMP!=null)
var stamps=DATESTAMP.toString().split('x');function initDateForm(f)
{var dates=initCalendars();if(f==null)
return false;f.elements.dateButton.onclick=function()
{this.form.submit();};f.reset=function()
{this.elements.date_start.reset();this.elements.date_end.reset();}
f.handler=this;f.submit=function()
{var myValidator=new Validator(this);if(myValidator.validate()>0)
{return false;}
else
{if((this.datepanel.currentNode!=null)&&(this.datepanel.currentNode!="calendar"))
this.datepanel.reset();if((this.elements.date_start.date==null)&&(this.elements.date_start.value))
this.elements.date_start.date=getDateFromString(this.elements.date_start.value);if((this.elements.date_end.date==null)&&(this.elements.date_end.value))
this.elements.date_end.date=getDateFromString(this.elements.date_end.value);setDate({'start':(this.elements.date_start.date!=null?this.elements.date_start.date:null),'end':(this.elements.date_end.date!=null?this.elements.date_end.date:null),'label':null});this.datepanel.currentNode="calendar";this.datepanel.field.toggleMenu();return false;}}
return f;}
function getDateFromString(string)
{var dateparams=string.split("/");var m=dateparams[0];var d=dateparams[1];var y=dateparams[2];if(y.length==2)
y=(2000+y);var date=new Date(y,m,d,1,1,1,1);if(date.toString()!="Invalid Date")
return date;else
return null;}
function formatDate(date,format)
{if((date!=null)&&(!format))
return getMonthString(date.getMonth(),"n")+"/"+date.getDate()+"/"+date.getFullYear();else if(format)
{return getMonthString(date.getMonth(),"M")+" "+date.getDate()+", "+date.getFullYear();}
else
return"anytime";}
function setDate(params)
{var input=browseSet['when'].input;var inputObj=document.getElementById(input);var storage=document.getElementById(browseSet['when'].storage);dateObj1=params.start;dateObj2=params.end;if(params.label!=null)
{inputObj.setValue(params.label);}
else
{inputObj.setValue(formatDate(dateObj1,"M j,Y")+(dateObj2!=null&&dateObj2?" - "+formatDate(dateObj2,"M j,Y"):''));}
if(params.id)
$(storage).val(params.id);else
{$(storage).val((dateObj1.valueOf()/1000)+(dateObj2!=null?"x"+(dateObj2.valueOf()/1000):false));}}
function getMonthString(mon,format)
{var abbrv={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"};var full={1:"January",2:"February",3:"March",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"};var formats={M:abbrv,F:full};switch(format)
{case"M":return formats.M[(mon+1)];break;case"F":return formats.F[(mon+1)];break;case"n":return(mon+1);break;}}
DatePanel.prototype._destruct=function()
{var count=0;for(var i in this)
{if(this[i]!=null)
{if(this[i]._destruct!=null)
this[i]._destruct();else
this[i]=null;count++;}}
killself(this);}