function browseInitSearchForm(){$("search-form").addEvent("submit",function(d){d=new Event(d);d.stop();var b=baseURL+"browse";b+=$("category-filter").getValue();var c=$("search-location").getValue();if(c.length>0){b+="/"+c}var a=$("search-keywords").getValue();if(a.length>0&&!$("search-keywords").hasClass("placeholder-text")){b+="?keywords="+encodeURIComponent(a)}document.location=b});$$("input.placeholder-text").each(function(a){$(a).addEvents({focus:onTextFocus.bindWithEvent($(a)),blur:onTextBlur.bindWithEvent($(a))})})}var changeLocationSlide;function browseInitLocationBar(){var a=Cookie.get("BrowseLocationBar");if(a===false){a="out"}changeLocationSlide=new SimpleSlide("locbrowser","height",{inValue:0,outValue:142,out:(a=="out"),onComplete:function(){if(changeLocationSlide.out){$("btn-change-loc").addClass("expanded");$("change-loc-action").setHTML("Hide")}else{$("btn-change-loc").removeClass("expanded");$("change-loc-action").setHTML("Show")}}});$("btn-change-loc").addEvent("click",function(b){Cookie.set("BrowseLocationBar",(changeLocationSlide.out?"in":"out"),{path:"/",duration:365});b=new Event(b);b.stop();changeLocationSlide.toggle()});$$("#locbrowser a.selected").each(function(c){if(!$(c).visibleWithin(c.parentNode.parentNode)){var b=new Fx.Scroll(c.parentNode.parentNode,{duration:0});b.toElement(c)}});preloadImages(["browser-loc-loading.gif","btn-changeloc-dwn.gif","btn-changeloc-up.gif"]);$$("#locbrowser ul a").each(function(b){b.addEvent("click",function(k){var d=$(b.parentNode.parentNode);d.getElements("a").each(function(e){e.removeClass("selected");e.removeClass("loading")});b.addClass("selected");b.addClass("loading");k=new Event(k);k.stop();var c=baseURL+"browse";c+=$("category-filter").getValue();var h=b.href.replace(baseURL+"browse/","").split("/");if(h.length>2){for(var g=2;g<h.length;g++){c+="/"+h[g]}}var j=$("search-keywords").getValue();if(j.length>0&&!$("search-keywords").hasClass("placeholder-text")){c+="?keywords="+encodeURIComponent(j)}var n=d;while(n!==null){var m=n.getCoordinates();var f=new Element("div",{styles:{top:m.top,left:m.left,width:m.width-(n.hasClass("last")?2:1)+"px"}}).inject(n.getParent());f.addClass("loading");var l=new Element("img",{src:versionImage("browser-loc-loading.gif"),width:"40px",height:"17px",styles:{position:"absolute",top:(m.height-17)/2+"px",left:(m.width-40)/2+"px"}});l.inject(f);var o=$(n.parentNode).getNext();if(o===null){n=null}else{n=$(o).getFirst()}}setTimeout(function(){document.location=c},50)})})}function browseInit(){browseInitSearchForm()}function browseDetailsInit(b){browseInitSearchForm();browseInitLocationBar();if($("mini-map")){map=new GSMap("mini-map",{centerOnDblClick:false});map.addControl(GSMap.COMPACT_ZOOM_CONTROL);resultsLayer=map.createLayer("results",{zIndex:1000});var c=new GSPoint(b.x,b.y);var a=createFeature(b.name,c,"nearby-origin",{data:b,allowClickHandler:false});a.addToMap();infoWindow.feature=a;map.centerAndZoom(c,15);favourites=new FavouritesCollection(map,null)}}function browseResultsInit(){if(totalPages>1){populatePagerSelect($("paging-select"),totalPages,currentPage);$("paging-select").addEvent("change",function(a){document.location=baseURL+pagingURL+this.options[this.selectedIndex].value}.bind($("paging-select")))}$$("#category-heading a").each(function(a){a.addEvent("click",function(c){c.stop();var b=$("search-keywords");document.location=this.href+(b.value.length&&b.value!=b.title?"?keywords="+encodeURIComponent(b.value):"")}.bindWithEvent(a))});browseInitSearchForm();browseInitLocationBar();if(searchResults.length>0){map=new GSMap("mini-map",{centerOnDblClick:false,useScalebar:false,minZoomLevel:3});map.addControl(GSMap.COMPACT_ZOOM_CONTROL);resultsLayer=map.createLayer("results",{zIndex:1000});searchResults.each(function(b){var a=createFeature(b.name,new GSPoint(b.x,b.y),b.search_index_alpha,{data:b,allowClickHandler:function(){document.location=$("search-result-link-"+b.search_index_alpha).href}});a.addToMap()});map.centerOnLayer("results")}}infoWindow.getDirections=function(){var a=baseURL+"directions/";var b=toURLToken(getPoiDataString(this.feature.data))+";"+this.feature.getCoordinate().x+";"+this.feature.getCoordinate().y;var c=($("info-to")&&$("info-to").checked)?"from":"to";if(c=="to"){a+=toURLToken($("txt-get-directions").value)+"/"+b}else{a+=b+"/"+toURLToken($("txt-get-directions").value)}document.location=a;return false};infoWindow.editFavourite=function(){document.location=baseURL+"favourites/edit/"+this.feature.getKey()};function displayView(b,a){switch(a){case"places":document.location=baseURL;break;case"directions":document.location=baseURL+"directions";break;case"favourites":document.location=baseURL+"favourites";break}};