document.addEventListener&&document.addEventListener("DOMContentLoaded",DOMContentLoaded,!1);
function DOMContentLoaded(){if(!arguments.callee.done&&(arguments.callee.done=!0,navigator.geolocation&&document.getElementById("ghome-list")&&(geoButton.createLocationLink(),geoButton.get_location()),elementSupportsAttribute("input","placeholder")||(searchHint.addInitialHint(),searchHint.checkSubmitText()),document.getElementById("tabs")&&tabs.cloneTabContentArea(),navigator.geolocation&&document.getElementById("categorytabs")&&nearbyTab.createNearbyTab(),document.getElementById("eventsearch")&&
toggleEventSearch.init(),window.location.pathname.indexOf("/nearby")!=-1)){var a=document.getElementById("categorytabs");document.getElementById("places-list")&&nearbyMap.buildMapButton("#",a,"places-list");document.getElementById("events-list")&&nearbyMap.buildMapButton("#",a,"events-list")}}
var tabs={tabLinks:[],contentDivs:[],currentSection:"",cloneTabContentArea:function(){var a=document.getElementById("searchtab"),b=document.getElementById("sectionstab").cloneNode(!0);b.setAttribute("id","sectiontabclone");var c=document.getElementById("tabsections");c.appendChild(a);c.appendChild(b);tabs.init()},init:function(){if(document.getElementById("tabs")){for(var a=onlyElementNodes(document.getElementById("tabs").childNodes),b=0;b<a.length;b++)if(a[b].nodeName=="LI"){var c=tabs.getFirstChildWithTagName(a[b],
"A");c.getAttribute("href")=="#sectionstab"&&c.setAttribute("href","#sectiontabclone");var d=tabs.getHash(c.getAttribute("href"));tabs.tabLinks[d]=c;tabs.contentDivs[d]=document.getElementById(d)}b=0;for(d in tabs.tabLinks)tabs.tabLinks[d].onclick=tabs.showTab,tabs.tabLinks[d].onfocus=function(){this.blur()},b++;b=0;for(d in tabs.contentDivs)a=tabs.contentDivs[d],a.className="tabcontent hide",a.setAttribute("style","display:block"),b++}},showTab:function(){var a=tabs.getHash(this.getAttribute("href"));
if(a!=tabs.currentSection){for(var b in tabs.contentDivs)b==a?(tabs.tabLinks[b].className="selected",tabs.contentDivs[b].className="tabcontent"):(tabs.tabLinks[b].className="",tabs.contentDivs[b].className="tabcontent hide");tabs.currentSection=a}else{for(b in tabs.contentDivs)tabs.tabLinks[b].className="",tabs.contentDivs[b].className="tabcontent hide";tabs.currentSection=""}return!1},getFirstChildWithTagName:function(a,b){for(var c=0;c<a.childNodes.length;c++)if(a.childNodes[c].nodeName==b)return a.childNodes[c]},
getHash:function(a){var b=a.lastIndexOf("#");return a.substring(b+1)}},nearbyTab={createNearbyTab:function(){var a=document.getElementById("categorytabs"),b=window.location.toString(),c=document.createElement("li"),d=document.createElement("span");c.setAttribute("id","lasttab");b.indexOf("/nearby/")!=-1?(c.className="current",nearbyTxt=document.createTextNode("Nearby"),d.appendChild(nearbyTxt),c.appendChild(d)):(b=document.createElement("a"),b.setAttribute("id","nearbyLink"),b.setAttribute("href",
""),nearbyTxt=document.createTextNode("Nearby"),b.appendChild(nearbyTxt),b.addEventListener("click",nearbyTab.findLocation,!1),c.appendChild(b));document.getElementById("cats")&&addClass(a,"threetabs");a.appendChild(c)},findLocation:function(a){a.preventDefault();addClass(this,"spinner");navigator.geolocation.getCurrentPosition(nearbyTab.geo_success,geo_error)},geo_success:function(a){var b=document.getElementsByTagName("body")[0],c=b.getAttribute("data-location"),b=b.getAttribute("id"),d=b.indexOf("section-"),
b=b.substr(d+8),b=b=="eating-drinking"?"places":b,d=document.getElementsByTagName("body")[0].getAttribute("data-categorypath"),g=roundVal(a.coords.latitude,4),a=roundVal(a.coords.longitude,4);createCookie("stvlocallocation",g+","+a,14);window.location=d?"http://"+window.location.hostname+"/"+c+"/"+b+"/"+d+"/nearby/?lat="+g+"&long="+a:"http://"+window.location.hostname+"/"+c+"/"+b+"/nearby/?lat="+g+"&long="+a}},geoButton={currentSite:window.location.hostname,createLocationLink:function(){var a=document.getElementById("atoz"),
b=document.createElement("li");b.setAttribute("id","cl");var c=document.createElement("a");c.setAttribute("href","#");var d=document.createTextNode("Use my current location");c.appendChild(d);b.appendChild(c);a.parentNode.insertBefore(b,a)},get_location:function(){document.getElementById("cl").addEventListener("click",geoButton.findLocation,!1)},findLocation:function(){navigator.geolocation.getCurrentPosition(geoButton.geo_success,geo_error)},geo_success:function(a){var b=roundVal(a.coords.latitude,
4),a=roundVal(a.coords.longitude,4);createCookie("stvlocallocation",b+","+a,14);window.location="http://"+geoButton.currentSite+"/location-search?lat="+b+"&long="+a}},nearbyMap={places:[],mapLoaded:!1,infowindow:null,currentLatLon:"",currentItem:0,mydomain:window.location.hostname,buildMapButton:function(a,b,c){console.log(nearbyMap.mydomain);a=document.documentElement.clientHeight>356?document.documentElement.clientHeight-70:document.documentElement.clientHeight-20;nearbyMap.buildLocations(c);c=
document.createElement("div");c.setAttribute("id","map_canvas");c.setAttribute("style","width:100%; height:"+a+"px");a=document.createElement("p");a.className="buttonrow nearbybutton clearing";a.setAttribute("id","loadnearbymap");var d=document.createElement("a");d.className="standardbutton";d.setAttribute("href","#");d.setAttribute("id","maphidden");d.addEventListener("click",nearbyMap.loadCheck,!1);var g=document.createTextNode("View on Map");d.appendChild(g);a.appendChild(d);insertAfter(c,b);insertAfter(a,
b)},buildLocations:function(a){if(readCookie("stvlocallocation")){var b=readCookie("stvlocallocation").split(","),c={content:"<h2>Your current Location</h2>",lat:b[0],lon:b[1]};nearbyMap.places.push(c);nearbyMap.currentItem=1}for(var a=document.getElementById(a).getElementsByTagName("li"),d=b=0;d<a.length;d++){var g=a[d],j=g.getAttribute("data-maplink")?g.getAttribute("data-maplink"):"",h=g.getAttribute("data-maptitle")?g.getAttribute("data-maptitle"):"",f=g.getAttribute("data-mapdistance")?g.getAttribute("data-mapdistance"):
"",c=g.getAttribute("data-lat")?g.getAttribute("data-lat"):"",e=g.getAttribute("data-lon")?g.getAttribute("data-lon"):"",g=c+","+e,k=parseInt(nearbyMap.currentItem-1);nearbyMap.currentLatLon==g?(j='<h2 class="multibubble"><a href="'+j+'">'+h+"</a></h2></p>",nearbyMap.places[k].content+=j):(j=f?"<p><strong>Distance: "+f+'km</strong></p><h2 class="multibubble"><a href="'+j+'">'+h+"</a></h2>":'<h2 class="multibubble nodistance"><a href="'+j+'">'+h+"</a></h2>",c={content:j,lat:c,lon:e},nearbyMap.places.push(c),
nearbyMap.distance=f,nearbyMap.currentItem+=1,nearbyMap.currentLatLon=g,b++);if(b==10)return!1}},loadCheck:function(a){a.preventDefault();nearbyMap.mapLoaded?nearbyMap.toggle(a):(a=document.getElementById("map_canvas"),addClass(a,"mapvisible"),nearbyMap.loadAPI())},toggle:function(){var a=document.getElementById("loadnearbymap").getElementsByTagName("a")[0],b=document.getElementById("map_canvas");hasClass(b,"mapvisible")?(b.className="maphidden",nearbyMap.showSurroundingContent(),a.lastChild.nodeValue=
"Show on map"):(b.className="mapvisible",nearbyMap.hideSurroundingContent(),a.lastChild.nodeValue="Hide map")},loadAPI:function(){var a=document.createElement("script");a.src="http://maps.google.com/maps/api/js?&sensor=true&callback=nearbyMap.initialize";a.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(a)},initialize:function(){var a={zoom:15,center:new google.maps.LatLng(nearbyMap.places[0].lat,nearbyMap.places[0].lon),disableDefaultUI:!0,scrollwheel:!1,mapTypeId:google.maps.MapTypeId.TERRAIN},
a=new google.maps.Map(document.getElementById("map_canvas"),a);nearbyMap.hideSurroundingContent();nearbyMap.setMarkers(a,nearbyMap.places);nearbyMap.infowindow=new google.maps.InfoWindow({maxWidth:200,content:""})},hideSurroundingContent:function(){window.scrollTo(0,0);addClass(document.getElementsByTagName("body")[0],"hideformap")},showSurroundingContent:function(){removeClass(document.getElementsByTagName("body")[0],"hideformap")},setMarkers:function(a,b){for(var c=[],d=b[0].lat,g=b[0].lat,j=b[0].lon,
h=b[0].lon,f=0;f<b.length;f++){var e=b[f];c.push(new google.maps.MarkerImage("http://"+nearbyMap.mydomain+"/assets/img/marker"+[f]+".png",null,null,null,new google.maps.Size(44,44)));d<=parseFloat(e.lat)&&(d=parseFloat(e.lat));g>=parseFloat(e.lat)&&(g=parseFloat(e.lat));j<=parseFloat(e.lon)&&(j=parseFloat(e.lon));h>=parseFloat(e.lon)&&(h=parseFloat(e.lon));var k=new google.maps.LatLng(e.lat,e.lon),e=new google.maps.Marker({position:k,map:a,icon:c[f],html:'<div class="fixbubble">'+e.content+"</div>"});
google.maps.event.addListener(e,"click",function(){nearbyMap.infowindow.setContent(this.html);nearbyMap.infowindow.open(a,this)});e=new google.maps.LatLngBounds(new google.maps.LatLng(parseFloat(g),parseFloat(h)),new google.maps.LatLng(parseFloat(d),parseFloat(j)));a.fitBounds(e);nearbyMap.mapLoaded=!0;document.getElementById("loadnearbymap").getElementsByTagName("a")[0].lastChild.nodeValue="Hide map"}}};
function geo_error(a){switch(a.code){case a.TIMEOUT:alert("We are unable to obtain your position at the moment");break;case a.POSITION_UNAVAILABLE:alert("Position unavailable");break;case a.PERMISSION_DENIED:alert("Permission denied");break;case a.UNKNOWN_ERROR:alert("Unknown error")}document.getElementById("nearbyLink")&&(a=document.getElementById("nearbyLink"),removeClass(a,"spinner"))}
var searchHint={inputs:document.getElementsByTagName("input"),addInitialHint:function(){for(i=0;i<searchHint.inputs.length;i++)if(searchHint.inputs[i].getAttribute("placeholder")){var a=searchHint.inputs[i].getAttribute("placeholder");searchHint.inputs[i].setAttribute("value",a);addClass(searchHint.inputs[i],"hashint");searchHint.inputs[i].addEventListener("click",searchHint.removeHint,!0);searchHint.inputs[i].addEventListener("blur",searchHint.addHint,!0)}},removeHintText:function(){for(i=0;i<searchHint.spans.length;i++)if(searchHint.spans[i].className==
"searchhint"){var a=document.getElementById(searchHint.spans[i].parentNode.getAttribute("for"));a.addEventListener("click",searchHint.removeHint,!0);a.addEventListener("blur",searchHint.addHint,!0)}},removeHint:function(){var a=this.getAttribute("placeholder"),b=this.getAttribute("id");if(this.value==a)this.value="",removeClass(document.getElementById(b),"hashint")},addHint:function(){var a=this.getAttribute("placeholder");if(this.value=="")this.value=a,addClass(this,"hashint")},checkSubmitText:function(){for(i=
0;i<searchHint.inputs.length;i++)searchHint.inputs[i].className.indexOf("submitremovehint")!=-1&&searchHint.inputs[i].addEventListener("click",searchHint.removeTipsOnSubmit,!1)},removeTipsOnSubmit:function(a){a.preventDefault();var a=this.getAttribute("data-form-id"),b=document.getElementById(a).getElementsByTagName("input");for(i=0;i<b.length;i++)if(b[i].getAttribute("type")=="search"&&b[i].getAttribute("placeholder")){var c=b[i].value,d=b[i].getAttribute("placeholder");if(c==d)b[i].value="";document.getElementById(a).submit()}}};
toggleEventSearch={init:function(){if(document.getElementById("eventsearch")){var a=document.getElementById("eventdates"),b=document.getElementById("eventsearch");if(a.className.indexOf("active")!=-1)b.style.display="none",a.style.display="block"}a=document.getElementById("swaptodropdown");b=document.getElementById("swaptoinput");a.addEventListener("click",toggleEventSearch.searchToggle,!1);b.addEventListener("click",toggleEventSearch.searchToggle,!1)},searchToggle:function(a){a.preventDefault();
var b=a.target;if(b.nodeType==3)b=a.target.parentNode;a=b.getAttribute("data-currentform");b=b.getAttribute("data-hiddenform");document.getElementById(a).style.display="none";document.getElementById(b).style.display="block"}};
var tracking={init:function(){document.getElementById("site-wrapper").addEventListener("click",tracking.findDataValue,!1);document.getElementById("footer").addEventListener("click",tracking.findDataValue,!1)},findDataValue:function(a){var a=a.target,b=tracking.findTrackingAttribute(a);if(b!="wrapper")b=b.getAttribute("data-tracked-component");else return!1;switch(a.nodeName){case "A":var c=a.hasAttribute("data-subtracked")?a.getAttribute("data-subtracked"):removeSpaces(a.lastChild.nodeValue);break;
case "INPUT":if(a.getAttribute("type")=="submit")c="button"+a.getAttribute("value");else return!1;break;default:(a=tracking.findLink(a))&&(c=a.hasAttribute("data-subtracked")?a.getAttribute("data-subtracked"):a.getAttribute("href"))}b&&c&&_gaq.push(["_trackEvent",b,c])},findTrackingAttribute:function(a){if(a.hasAttribute("data-tracked-component"))return a;return a.parentNode?tracking.findTrackingAttribute(a.parentNode):!1},findLink:function(a){if(a.nodeName=="HTML")return!1;return a.nodeName=="A"?
a:a.parentNode?tracking.findLink(a.parentNode):!1}};function onlyElementNodes(a){for(var b=[],c=0;c<a.length;c++)a[c].nodeType==1&&b.push(a[c]);return b}function removeSpaces(a){return a.split(" ").join("")}RegExp.escape=function(a){return a.replace(RegExp("[.*+?|()\\[\\]{}\\\\]","g"),"\\$&")};function elementSupportsAttribute(a,b){var c=document.createElement(a);return b in c?!0:!1}
function createCookie(a,b,c){if(c){var d=new Date;d.setTime(d.getTime()+c*864E5);c="; expires="+d.toGMTString()}else c="";document.cookie=a+"="+b+c+"; path=/"}function readCookie(a){a+="=";for(var b=document.cookie.split(";"),c=0;c<b.length;c++){for(var d=b[c];d.charAt(0)==" ";)d=d.substring(1,d.length);if(d.indexOf(a)==0)return d.substring(a.length,d.length)}return null}function eraseCookie(a){createCookie(a,"",-1)}
function insertAfter(a,b){var c=b.parentNode;c.lastChild==b?c.appendChild(a):c.insertBefore(a,b.nextSibling)}function getNextElement(a){if(a.nodeType==1)return a;if(a.nextSibling)return getNextElement(a.nextSibling);return null}function addClass(a,b){a.className?(newClassName=a.className,newClassName+=" ",newClassName+=b,a.className=newClassName):a.className=b}function hasClass(a,b){return a.className.match(RegExp("(\\s|^)"+b+"(\\s|$)"))}
function removeClass(a,b){if(hasClass(a,b))a.className=a.className.replace(RegExp("(\\s|^)"+b+"(\\s|$)")," ")}function roundVal(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)}
var getElementsByClassName=function(a,b,c){getElementsByClassName=document.getElementsByClassName?function(a,b,c){for(var a=(c||document).getElementsByClassName(a),b=b?RegExp("\\b"+b+"\\b","i"):null,c=[],h,f=0,e=a.length;f<e;f+=1)h=a[f],(!b||b.test(h.nodeName))&&c.push(h);return c}:document.evaluate?function(a,b,c){for(var b=b||"*",c=c||document,h=a.split(" "),f="",e=document.documentElement.namespaceURI==="http://www.w3.org/1999/xhtml"?"http://www.w3.org/1999/xhtml":null,a=[],k,l=0,m=h.length;l<
m;l+=1)f+="[contains(concat(' ', @class, ' '), ' "+h[l]+" ')]";try{k=document.evaluate(".//"+b+f,c,e,0,null)}catch(n){k=document.evaluate(".//"+b+f,c,null,0,null)}for(;b=k.iterateNext();)a.push(b);return a}:function(a,b,c){var b=b||"*",c=c||document,h=a.split(" "),a=[],b=b==="*"&&c.all?c.all:c.getElementsByTagName(b),c=[],f;f=0;for(var e=h.length;f<e;f+=1)a.push(RegExp("(^|\\s)"+h[f]+"(\\s|$)"));for(var e=0,k=b.length;e<k;e+=1){h=b[e];f=!1;for(var l=0,m=a.length;l<m;l+=1)if(f=a[l].test(h.className),
!f)break;f&&c.push(h)}return c};return getElementsByClassName(a,b,c)};
