var updateForm=false;var users=new Array;var ExternalLinks=false;var FacebookUser=new Class({Implements:Log,uid:false,profilePic:false,name:false,data:false,initialize:function(A){this.uid=A;this.profilePic=new Element("fb:profile-pic",{uid:"loggedinuser","facebook-logo":true,size:"square",linked:false});this.name=new Element("fb:name",{uid:"loggedinuser",useyou:false,linked:false});},addInfo:function(A){this.data=A;}});var MapUser=new Class({Implements:Log,uid:false,profilePic:false,name:false,latitude:false,longitude:false,marker:false,infoWindow:false,sideBar:false,initialize:function(A){this.uid=A.fb_uid;this.display_name=A.display_name;this.kind=A.kind;this.latitude=A.latitude;this.longitude=A.longitude;this.profilePic=new Element("fb:profile-pic",{uid:this.uid,"facebook-logo":true,size:"square",linked:false});this.name=new Element("span",{html:this.display_name});this.kindEl=new Element("span",{"class":this.kind,html:this.kind.ucwords()});},renderInfoWindow:function(){infoContainer=new Element("div");moreLink=new Element("a",{html:"more »",href:"#","class":"more"});infoContainer.adopt(this.profilePic,this.name,moreLink);return infoContainer.get("html");},addMarker:function(A){this.marker=new GMarker(new GLatLng(this.latitude,this.longitude),A);this.map.addOverlay(this.marker);GEvent.addListener(this.marker,"click",function(){users.each(function(B){if(B.infoWindow&&B.infoWindow.div_){B.infoWindow.hide();B.marker.show();}});if(!this.infoWindow){this.infoWindow=new ELabel(this.marker.getPoint(),this.renderInfoWindow(),"info-window "+this.kind,new GSize(-143,-95));this.map.addOverlay(this.infoWindow);closeLink=$(this.infoWindow.div_).getElement("a");$(closeLink).addEvent("click",function(B){if(B){B.preventDefault();B.stop();}closeLink.setStyle("display","none");this.show();}.bind(this));GEvent.addDomListener(this.infoWindow.div_,"click",function(B){this.infoWindow.hide();this.marker.show();}.bind(this));FB.XFBML.Host.parseDomElement(this.infoWindow.div_);}this.infoWindow.show();this.marker.hide();this.map.panTo(this.marker.getPoint());}.bind(this));},show:function(){users.each(function(A){if(A.sideBar&&A!==this){A.sideBar.dissolve();A.infoWindow.div_.getElement("a").setStyle("display","block");$("footer").setStyles({position:"auto"});}}.bind(this));if(!this.sideBar){request=new Request.JSON({url:RESPONDER,onSuccess:function(A){this.sideBar=new Element("div",{"class":"map-user-"+this.kind,styles:{"min-height":$("context").getSize().y,width:$("context").getSize().x,top:$("context").getPosition($("container")).y,left:$("context").getPosition($("container")).x-2,"padding-left":2}});this.sideBar.adopt(new Element("h2",{html:this.display_name}));this.sideBar.adopt(new Element("span",{html:this.kind.ucwords()+", "+A.location,"class":"location"}));if(A.kind=="seller"){this.sideBar.adopt(new Element("p",{html:A.profile}));this.sideBar.adopt(new Element("dl").adopt(new Element("dt",{html:"Selling:"}),new Element("dd",{html:A.produce})));if(A.phone){this.sideBar.getElement("dl").adopt(new Element("dt",{html:"Phone: "}),new Element("dd",{html:A.phone}));}if(A.website){this.sideBar.adopt(new Element("p").adopt(new Element("a",{href:A.website,html:this.display_name+"'s website"})));}}if(A.kind=="host"){this.sideBar.adopt(new Element("dl").adopt(new Element("dt",{html:"Theme:"}),new Element("dd",{html:A.event_theme})));this.sideBar.adopt(new Element("p",{html:A.profile}));}if(A.kind=="diner"){this.sideBar.adopt(new Element("p").appendText("Favourite Food: "+A.favourite));this.sideBar.adopt(new Element("p",{html:A.profile}));}closeLink=new Element("a",{href:"#",html:"Back","class":"button",events:{click:function(B){B.preventDefault();this.hide();this.infoWindow.div_.getElement("a").setStyle("display","block");}.bind(this)}});this.sideBar.adopt(closeLink);$("container").adopt(this.sideBar);this.show();FB.ensureInit(function(){FB.Facebook.apiClient.users_getInfo(this.uid,["profile_url","pic_big_with_logo"],function(B){if(!B||!B.length){return ;}this.pic=B[0].pic_big_with_logo;this.url=B[0].profile_url;if(this.pic.length){this.sideBar.grab(new Element("img",{src:this.pic}),"top");}if(A.link&&this.url){fbLink=new Element("a",{href:this.url,html:"Find "+this.display_name+" on Facebook"});ExternalLinks.bindEvent(fbLink);closeLink.grab(new Element("p").adopt(fbLink),"before");}}.bind(this));}.bind(this));}.bind(this)}).get({fb_uid:this.uid,action:"getUserDetail"});}else{this.sideBar.reveal();(function(){if($("footer").getPosition().y<this.sideBar.getCoordinates().bottom){$("footer").setStyles({position:"absolute",top:this.sideBar.getCoordinates().bottom+20,width:"100%"});}}.bind(this)).delay(500);}},hide:function(){this.sideBar.dissolve();(function(){$("footer").setStyles({position:"static",top:"auto"});}).delay(500);}});var GoogleMap=new Class({Implements:Log,errored:false,users:new Array,initialize:function(D){if(window.GBrowserIsCompatible&&!GBrowserIsCompatible()){return ;}window.addEvent("unload",function(){GUnload();});this.container=$(D);this.map=new GMap2(this.container);shadow="/images/icon-shadow.png";iconSize=new GSize(20,28);shadowSize=new GSize(39,28);iconAnchor=new GPoint(14,27);var C=new GIcon();C.image="/images/icon-diner.png";C.shadow=shadow;C.iconSize=iconSize;C.shadowSize=shadowSize;C.iconAnchor=iconAnchor;dinerMarker={icon:C};var A=new GIcon();A.image="/images/icon-host.png";A.shadow=shadow;A.iconSize=iconSize;A.shadowSize=shadowSize;A.iconAnchor=iconAnchor;hostMarker={icon:A};var B=new GIcon();B.image="/images/icon-seller.png";B.shadow=shadow;B.iconSize=iconSize;B.shadowSize=shadowSize;B.iconAnchor=iconAnchor;sellerMarker={icon:B};G_PHYSICAL_MAP.getMaximumResolution=function(){return G_MAX_ZOOM;};G_PHYSICAL_MAP.getMinimumResolution=function(){return G_MIN_ZOOM;};this.map.setMapType(G_PHYSICAL_MAP);this.map.setCenter(new GLatLng(G_LAT,G_LNG),G_ZOOM);this.mapControl=new GSmallMapControl();this.map.addControl(this.mapControl,new GControlPosition(G_ANCHOR_TOP_LEFT));this.map.addControl(new GScaleControl());},plotUsers:function(){b=this.map.getBounds();responder=new Request.JSON({url:RESPONDER,link:"cancel",onSuccess:function(A){A.users.each(this.addUser,this);}.bind(this)}).get({action:"getUsers",swLat:b.getSouthWest().lat(),neLat:b.getNorthEast().lat(),swLng:b.getSouthWest().lng(),neLng:b.getNorthEast().lng()});},addUser:function(A){u=new MapUser(A);if(u.kind=="diner"){opts=dinerMarker;}if(u.kind=="seller"){opts=sellerMarker;}if(u.kind=="host"){opts=hostMarker;}u.map=this.map;users.push(u);i=users.length-1;users[i].addMarker(opts);},setFromBounds:function(A){zoom=this.map.getBoundsZoomLevel(new GLatLngBounds(new GLatLng(A.swLat,A.swLng),new GLatLng(A.neLat,A.neLng)));this.map.setCenter(new GLatLng(A.cLat,A.cLng),zoom);this.listUsers();},setCenter:function(A){this.map.setCenter(new GLatLng(A.latitude,A.longitude),G_MAX_ZOOM);this.listUsers();},listUsers:function(){bounds=this.map.getBounds();new Request.JSON({url:RESPONDER,onSuccess:function(A){containerDiv=new Element("div",{id:"search-results",styles:{height:$("context").getSize().y,width:$("context").getSize().x,top:$("context").getPosition($("container")).y,left:$("context").getPosition($("container")).x-2,"padding-left":2}});containerDiv.adopt(new Element("h2",{html:"Users nearby:"}));ul=new Element("ul");if(A.users.length){A.users.each(function(B){li=new Element("li");a=new Element("a",{href:"#",html:B.display_name,events:{click:function(C){C.preventDefault();users.each(function(D){if(D.uid==B.fb_uid){GEvent.trigger(D.marker,"click");}});}}});li.adopt(a);li.appendText(" ("+B.kind.ucwords()+")");ul.adopt(li);});containerDiv.adopt(ul);}else{containerDiv.adopt(new Element("p",{html:"None"}));}containerDiv.adopt(new Element("p").adopt(new Element("a",{href:"#",html:"Back","class":"button",events:{click:function(B){B.preventDefault();this.getParent("div").destroy();}}})));if($("search-results")){containerDiv.replaces($("search-results"));}else{$("container").adopt(containerDiv);containerDiv.reveal();}}}).get({action:"getUsersFromBounds",neLat:bounds.getNorthEast().lat(),neLng:bounds.getNorthEast().lng(),swLat:bounds.getSouthWest().lat(),swLng:bounds.getSouthWest().lng()});}});String.implement({ucwords:function(){return(this+"").replace(/^(.)|\s(.)/g,function(A){return A.toUpperCase();});}});var fb_login=function(B){if(!$defined(B)){return ;}if($("become-a-fan")){$("become-a-fan").addClass("logged-in");}var A=new FacebookUser(B);welcomeMsg=new Element("p",{id:"facebook-welcome",html:"Welcome, "});welcomeMsg.adopt(A.name);links=new Element("p",{id:"facebook-links"});profile=new Element("a",{html:"Account Settings",href:"/profile"});logout=new Element("a",{id:"logout-link",href:"#",html:"Logout",events:{click:function(D){D.preventDefault();var F=FB.Facebook.apiClient.get_session();var C=F?F.uid:null;var E=FB.Connect._singleton;var G=FBIntern.Uri.addQueryParameters(FB.XdComm.Server.singleton.get_receiverUrl(),"fb_login&fname=_parent&session=loggedout");E._ensureLoginHandler();E._logoutCallback="/";logoutUrl=FBIntern.Utility.getFacebookUrl("www");logoutUrl+="logout.php?app_key="+FB.Facebook.apiKey;logoutUrl+="&session_key="+encodeURIComponent(F.session_key)+"&next="+encodeURIComponent(G);FB.Facebook.apiClient.set_session(null);E.set__userInfo(null);E._logoutIframe=FB.XdComm.Server.singleton.createNamedHiddenIFrame("fbLogout",logoutUrl,"fb_logout",null);}}});links.adopt(logout);links.appendText(" | ");links.adopt(profile);links.setStyle("opacity",0.69);$("facebook-login").empty();$("facebook-login").adopt(A.profilePic,welcomeMsg,links);$("facebook-login").set("class","logged-in");response=FB.XFBML.Host.parseDomElement($("facebook-login"));if(updateForm&&!$("main").hasClass("profile")){updateForm(B);}};var track=function(A){try{var B=_gat._getTracker(G_ANALYTICS);B._trackPageview(A?A:"/");}catch(C){}};var googleAnalytics=function(){var A=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");body=document.getElement("body");script=new Element("script",{src:A+"google-analytics.com/ga.js",type:"text/javascript"});body.adopt(script);track.delay(500);};window.addEvent("domready",function(){$("footer").setStyle("opacity",0.69);if(Browser.Engine.trident&&Browser.Engine.version<5){document.getElement("body").addClass("ie");}ExternalLinks=new ExternalLinksObject();$$("a").each(function(A){if($defined(A.get("href"))&&A.get("href").getHostname()&&A.get("href").getHostname()!==document.domain){ExternalLinks.bindEvent(A);}}.bind(this));googleAnalytics();});var k=0;var l=0;document.addEvent("keyup",function(A){if((A.key=="up"&&k==0)||(A.key=="up"&&k==1&&l=="up")||(A.key=="down"&&k==2&&l=="up")||(A.key=="down"&&k==3&&l=="down")||(A.key=="left"&&k==4&&l=="down")||(A.key=="right"&&k==5&&l=="left")||(A.key=="left"&&k==6&&l=="right")||(A.key=="right"&&k==7&&l=="left")||(A.key=="b"&&k==8&&l=="right")||(A.key=="a"&&k==9&&l=="b")||(A.key=="enter"&&k==10&&l=="a")){k++;l=A.key;}else{l=0;k=0;}if(k==10){document.getElement("body").setStyles({"background-image":"url(/images/hamster.gif)","background-color":"#FFF","background-repeat":"repeat"});}});