var portrait_count=100,facepile_loaded=false,point_index=0,points=[],faded_map=false;
$(function(){$.cookie("ckyPosition",null);_ctx.cache("btnZip","#btnZip");_ctx.cache("tbZip","#tbZip").defaultvalue("your zip code").keydown(function(a){a.keyCode==13&&submitZip()});_ctx.cache("geo_prompt","#geo_prompt");navigator&&navigator.geolocation&&document.location.toString().indexOf("zip")==-1?_ctx.geo_prompt.addClass("html5").show():_ctx.geo_prompt.addClass("html_").show();window.over_map=false;$("#divMap").hover(function(){window.over_map=true},function(){window.over_map=false});var b={zoom:13,
scrollwheel:false,center:new google.maps.LatLng(position.lat,position.lon),disableDefaultUI:true,navigationControl:true,mapTypeId:google.maps.MapTypeId.ROADMAP};window.map=new google.maps.Map(document.getElementById("divMap"),b);google.maps.event.addListener(map,"center_changed",function(){});b=new google.maps.StyledMapType([{featureType:"water",elementType:"all",stylers:[{visibility:"simplified"},{hue:"#5292BD"},{lightness:-40}]}],{map:window.map,name:"TheHotlist"});window.map.mapTypes.set("hotlist",
b);window.map.setMapTypeId("hotlist");populateMap(false)});function openPoint(b){openTooltip();_ctx.cache("venue_span","#gmap > div.venue > span").hide();var a=points[b];map.panTo(a.marker.panPosition);setTimeout(function(){_ctx.venue_span.html(a.html).fadeIn();trigger("point.open")},500)}
function makePortraitArray(){for(var b=[];b.length<10;){var a=parseInt(Math.random()*portrait_count,10);$.inArray(a,b)==-1&&b.push(a)}a=[];for(var c=0;c<10;c++)a.push("<img class='fb_tiny fl mr2 spr_portraits' src='/images/clear.gif' style='background-position: -"+25*b[c]+"px 0; '/>");return a.join("")}function openTooltip(){for(var b=0;b<points.length;b++)points[b].tooltip.close();setTimeout(function(){var a=points[point_index];a.tooltip.open(map,a.marker)},500)}
function loginFromVenue(b){$("body").append("<iframe src='"+b+"' style='width: 1px; height: 1px; ' frameborder='no'></iframe>");$("#divLogin").click()}
function populateMap(b){getPoints(b,function(){var a=[];a.push("<div class='gmap_tooltip cp' onclick='loginFromVenue(\"{venue_url}\");'>");a.push("<div class='pb5 al'><a class='venue_name b' title='Click to see this venue' href='#'>{venue_name}</a></div>");a.push("<div class='lh24'>");a.push("<div class='fl'>{stats.total_going} people, <a title='Click to log in and see the crowd' href='#'>? friends</a>:&nbsp;&nbsp;</div>");a.push("<div class='fl'><div class='spr_inside boy'></div></div>");a.push("<div class='fl'>&nbsp;&nbsp;{stats.gender_m}%&nbsp;</div>");
a.push("<div class='fl'><div class='spr_inside girl'></div> </div>");a.push("<div class='fl'>{stats.gender_f}%&nbsp;</div>");a.push("</div>");a.push("<div class='clear pt2' title='Click to log in and see the crowd'>");a.push("<div class='mt2'>{portraits}</div>");a.push("</div>");a.push("</div>");var c=jsontemplate.Template(a.join("")),f=new google.maps.MarkerImage(_gmap.mapShadow,new google.maps.Size(36,33),new google.maps.Point(0,0),new google.maps.Point(12,33));$.each(points,function(e,d){d.portraits=
makePortraitArray();d.html=c.expand(d);d.marker=new google.maps.Marker({position:new google.maps.LatLng(d.lat,d.lon),panPosition:new google.maps.LatLng(d.lat+0.01,d.lon),map:map,icon:"/images/icons/map/hot"+(e+1)+".png",shadow:f});d.tooltip=new google.maps.InfoWindow({content:d.html,pixelOffset:new google.maps.Size(0,10),maxWidth:340});google.maps.event.addListener(d.marker,"click",function(){point_index=e;openPoint(point_index)})});point_index=-1;clearInterval(window.moveInterval);window.moveInterval=
setInterval(function(){if(!window.over_map||faded_map){point_index++;if(point_index>=points.length)point_index=0;openPoint(point_index)}if(!facepile_loaded){facepile_loaded=true;_ctx.cache("divFacepile","#divFacepile").html("<fb:facepile width='270'></fb:facepile>");FB.XFBML.parse(document.getElementById("divFacepile"));setTimeout(function(){_ctx.divFacepile.removeClass("expanded")},1500)}},4E3)})}
function submitZip(){var b=_ctx.tbZip.val();reg=new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);if(reg.test(b)){_ctx.tbZip.attr("disabled","disabled").blur();_ctx.btnZip.val("Please wait...");position.zip=b;populateMap(false)}else{var a=_ctx.geo_prompt.find("span.msg").html();_ctx.geo_prompt.find("span.msg").data("msg",a).html("Oops! This is an invalid zip code...").effect("highlight",2E3);setTimeout(function(){_ctx.geo_prompt.find("span.msg").html(a)},5E3);_ctx.tbZip.select()}}
function getPoints(b,a){if(b)if(navigator&&navigator.geolocation){b=[];b.push("<div>");b.push("<a title='Close' href='javascript:v();' onclick='_ctx.help.hide();' class='fr'><span class='spr_inside close'></span></a>");b.push("<div class='clear'></div>");b.push("<div class='pb5'>Now click "+($.browser.webkit?"'Allow'":"'Share location'")+"!</div>");b.push("</div>");_ctx.cache("help","#help").find("div.arrow").addClass("faded").parent().find("div.content").html(b.join("")).parent().css("top","0").css("right",
"100px").show().unbind("mouseout").bind("mouseout",function(){setTimeout(function(){_ctx.help.fadeOut()},2E3)});navigator.geolocation.getCurrentPosition(function(c){_ctx.help.hide();position.lat=c.coords.latitude;position.lon=c.coords.longitude;_ctx.geo_prompt.removeClass("html5").addClass("html_");getPoints(false,a)},function(){log("not granted or failed (5611744)");_ctx.help.hide();_ctx.geo_prompt.removeClass("html5").addClass("html_")})}else getPoints(false,a);else{if(points.length>0){faded_map=
true;_ctx.cache("divMap","#divMap").animate({opacity:0.2},1E3)}$.getJSON("/act/near_by_events_for_today?"+(isUsable(position.zip)?"zip="+position.zip:"lat="+position.lat+"&long="+position.lon),function(c){if(c.status=="ok"){$.JSONCookie("ckyPosition",{lat:c.lat,lon:c.lon},{path:"/"});$.each(points,function(f,e){if(isUsable(e.marker)){e.marker.setMap(null);isUsable(e.tooltip)&&e.tooltip.close()}});points=c.data;bind("point.open",function(){bind("point.open");_ctx.cache("divMap","#divMap").animate({opacity:1},
1E3);faded_map=false;_ctx.tbZip.attr("disabled","");_ctx.btnZip.val("Submit")});tryCallback(a)}else log("failed to fetch points (9597958)")})}};
