var $,$avatar,$bubble,$list,$map,bounds,GControlZoom,gmaps_add,gmaps_date,gmaps_date_relative,gmaps_init,gmaps_window,gmaps_window_city,map,markers,options;$=jQuery;$avatar=$("body").append($("<div></div>").attr("id","avatar").append($("<img/>"))).find("#avatar");$bubble=$("body").append($("<div></div>").attr("id","bubble")).find("#bubble");$list=$("#list ul.cities");options={path:"/"};GControlZoom=function(){};GControlZoom.prototype=new GControl; GControlZoom.prototype.initialize=function(c){var b;b=$("<div></div>").attr("id","zoom");b.append($("<div></div>").addClass("out").bind("click",function(){c.zoomOut()})).append($("<div></div>").addClass("in").bind("click",function(){c.zoomIn()}));$map.append(b);return b[0]};GControlZoom.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(4,4))}; gmaps_add=function(c,b,d){var a,f;a=new GIcon;a.image=options.path+"wp-content/themes/hyper-island/images/hi.png";a.shadow=options.path+"wp-content/themes/hyper-island/images/hi_shadow.png";a.iconSize=new GSize(21,34);a.shadowSize=new GSize(39,34);a.iconAnchor=new GPoint(10,17);a.infoWindowAnchor=new GPoint(10,17);f=new GMarker(c,a);GEvent.addListener(f,"click",function(){gmaps_window(f,b,d)});return f}; gmaps_date=function(c){var b,d,a,f,g,e;b=$("<ul></ul>");d=(new Date).getTime();e=["January","February","Mars","April","May","June","July","August","September","October","November","December"];c=c.split("|");for(g in c)if(c.hasOwnProperty(g)){a=new Date(c[g]);f=[a.getDate(),e[a.getMonth()],a.getFullYear()];b.append($("<li></li>").addClass("date"+(d>a.getTime()?" old":"")).text(f.join(" ")))}return b}; gmaps_date_relative=function(c){var b,d,a;b=(new Date).getTime();c=c.split(",");for(a in c)if(c.hasOwnProperty(a)){d=new Date(c[a]*1E3);d=parseInt((d-b)/1E3,10);if(d<=0&&d>-86400)return"HI in town"}return false}; gmaps_init=function(c){var b,d;$map=$(c);d=$map.offset();bounds=new GLatLngBounds;map=new GMap2($map[0]);markers=[];$.getJSON(options.path+"maps",function(a){var f,g,e,h,i;for(e in a)if(a.hasOwnProperty(e)){i=new GLatLng(parseFloat(a[e].lat),parseFloat(a[e].lng));h=gmaps_add(i,e,a[e].name_slug);g=gmaps_date_relative(a[e].date_start);f=gmaps_date(a[e].date_start);if(e==="0"){b=new GLatLng(0,0);GEvent.addListener(map,$.browser.safari?"load":"tilesloaded",function(){})}$list.append($("<li></li>").addClass("item").attr("id", "marker-"+e).append($("<a></a>").attr("href","#"+a[e].name_slug).text(a[e].name)).append($("<span></span>").addClass("date").text(g.length>0?g:"")).append(f).bind("click",function(){var j,k;k=$(this).find("a").attr("href").replace("#","");j=parseInt($(this).attr("id").replace("marker-",""),10);$list.parent().find("ul.digital li.active").removeClass("active");GEvent.trigger(map,"movestart");gmaps_window(markers[j],j,k);return false}));bounds.extend(i);markers.push(h);map.addOverlay(h)}map.addControl(new GControlZoom); map.setCenter(b,1);$map.css("background-image","none");$avatar.css("left",d.left+$map.width()-$avatar.width());$bubble.css("left",d.left+310);$list.parent().css({top:d.top,left:d.left}).show()})}; gmaps_window=function(c,b,d,a){var f;b=$list.find("li#marker-"+b);if(b.hasClass("active"))return false;$list.find("li.active").removeClass("active").find("ul").hide();b.addClass("active").find("ul").show();if(typeof a==="undefined")f=GEvent.addListener(map,"moveend",function(){gmaps_window_city(d);GEvent.removeListener(f)});else gmaps_window_city(d);map.panTo(c.getLatLng())}; gmaps_window_city=function(c){$.getJSON(options.path+"maps/"+c,function(b){var d;if(b===null)return false;$bubble.html("").append($("<p></p>").html(b.body)).append($("<div></div>").attr("id","bubble-bottom"));$avatar.find("img").attr("src",b.avatar).parent().fadeIn();$bubble.fadeIn();d=GEvent.addListener(map,"movestart",function(){$bubble.fadeOut();$avatar.fadeOut().find("img").attr("src","");GEvent.removeListener(d)})})};jQuery(document).ready(function(){gmaps_init("#map")});