function get_bloginfo_url(){return"http://wassp.net"}
var VENUE={CLUB:0,SPORTS_CENTRE:1,SCHOOL:2,VOLUNTEERING_OPPORTUNITY:3,OTHER:4,UNDEFINED:5},venues=["club","sports centre","school","volunteering opportunities","other","undefined"],venueShowFlags=[!0,!0,!0,!0,!0,!0],venueListTitles=["clubs","sports-centres","schools","volunteering-opportunities","other-venues","other-venues"],venueMouseOverColours=["#00d","#d00","#b94","#090","#c62","#777"],mapVenuesLists=[],MAP_AREA={CENTRE:0,NORTH:1,EAST:2,SOUTH:3,WEST:4,NONE:5},mapAreaNames=["centre","north","east",
"south","west",""],mapAreaLongNames=["Central Warrington","Warrington North","Warrington East","Warrington South","Warrington West",""],mapAreaZoomOffsets=[2,2,2,1,1],polygonStrokeWeight=2,polygonStrokeColours=["#444444","#444444","#444444","#444444","#444444"],polygonStrokeOpacity=1,polygonStrokeColourActive="#000000",polygonColours=["#ffff00","#00ffff","#ff0000","#00ff00","#ff00ff"],polygonOpacity=0.2,polygonOpacityActive=0.4,polygonStrokeWeightActive=4,polygonStrokeOpacityActive=1,map,markers=
[],markerIcons=[],currentActivePolygon=null,currentActiveMapArea=MAP_AREA.NONE,mapZoomedOutCentre,mapZoomedOutLevel;function map_pageLoad(){google.load("maps","2",{callback:mapLoad})}
function mapLoad(){if(google.maps.BrowserIsCompatible()){document.getElementById("resetMap").style.display="inline";mapVenuesLists[VENUE.CLUB]=document.getElementById("map-clubs-list");mapVenuesLists[VENUE.SPORTS_CENTRE]=document.getElementById("map-sports-centres-list");mapVenuesLists[VENUE.SCHOOL]=document.getElementById("map-schools-list");mapVenuesLists[VENUE.VOLUNTEERING_OPPORTUNITY]=document.getElementById("map-volunteering-opportunities-list");mapVenuesLists[VENUE.OTHER]=document.getElementById("map-other-venues-list");
mapVenuesLists[VENUE.UNDEFINED]=document.getElementById("map-other-venues-list");map=new google.maps.Map2(document.getElementById("map"));mapZoomedOutCentre=new google.maps.LatLng(53.392,-2.585);mapZoomedOutLevel=11;map.addControl(new GSmallMapControl);map.addControl(new GMenuMapTypeControl);map.enableContinuousZoom();resetMap();var a=new google.maps.Polygon([new GLatLng(53.423445,-2.582817),new GLatLng(53.427537,-2.555007),new GLatLng(53.423241,-2.554664),new GLatLng(53.420581,-2.561531),new GLatLng(53.41567,
-2.563934),new GLatLng(53.413317,-2.568397),new GLatLng(53.407894,-2.56771),new GLatLng(53.404415,-2.571659),new GLatLng(53.400116,-2.561187),new GLatLng(53.391928,-2.560501),new GLatLng(53.388857,-2.564277),new GLatLng(53.389983,-2.573032),new GLatLng(53.385273,-2.575435),new GLatLng(53.386399,-2.590026),new GLatLng(53.391518,-2.583847),new GLatLng(53.39766,-2.5914),new GLatLng(53.407689,-2.592086),new GLatLng(53.41608,-2.596893),new GLatLng(53.422218,-2.619552),new GLatLng(53.423445,-2.582817)],
polygonStrokeColours[MAP_AREA.CENTRE],polygonStrokeWeight,polygonStrokeOpacity,polygonColours[MAP_AREA.CENTRE],polygonOpacity);map.addOverlay(a);var d=new google.maps.Polygon([new GLatLng(53.440423,-2.581443),new GLatLng(53.448397,-2.571487),new GLatLng(53.458619,-2.565994),new GLatLng(53.462299,-2.545394),new GLatLng(53.467817,-2.548828),new GLatLng(53.481508,-2.493209),new GLatLng(53.476604,-2.483253),new GLatLng(53.465569,-2.48703),new GLatLng(53.448602,-2.471237),new GLatLng(53.444512,-2.47364),
new GLatLng(53.437355,-2.46437),new GLatLng(53.434287,-2.471237),new GLatLng(53.437355,-2.478103),new GLatLng(53.434696,-2.526855),new GLatLng(53.427537,-2.555007),new GLatLng(53.440423,-2.581443)],polygonStrokeColours[MAP_AREA.NORTH],polygonStrokeWeight,polygonStrokeOpacity,polygonColours[MAP_AREA.NORTH],polygonOpacity);map.addOverlay(d);var b=new google.maps.Polygon([new GLatLng(53.437355,-2.478103),new GLatLng(53.434287,-2.471237),new GLatLng(53.437355,-2.46437),new GLatLng(53.437355,-2.457504),
new GLatLng(53.423855,-2.444114),new GLatLng(53.419354,-2.447204),new GLatLng(53.416284,-2.444458),new GLatLng(53.398888,-2.465744),new GLatLng(53.396636,-2.474327),new GLatLng(53.384147,-2.532691),new GLatLng(53.38599,-2.541275),new GLatLng(53.390904,-2.547798),new GLatLng(53.389266,-2.553291),new GLatLng(53.391928,-2.560501),new GLatLng(53.400116,-2.561187),new GLatLng(53.404415,-2.571659),new GLatLng(53.407894,-2.56771),new GLatLng(53.413317,-2.568397),new GLatLng(53.41567,-2.563934),new GLatLng(53.420581,
-2.561531),new GLatLng(53.423241,-2.554664),new GLatLng(53.427537,-2.555007),new GLatLng(53.427537,-2.555007),new GLatLng(53.434696,-2.526855),new GLatLng(53.437355,-2.478103)],polygonStrokeColours[MAP_AREA.EAST],polygonStrokeWeight,polygonStrokeOpacity,polygonColours[MAP_AREA.EAST],polygonOpacity);map.addOverlay(b);var c=new google.maps.Polygon([new GLatLng(53.391928,-2.560501),new GLatLng(53.389266,-2.553291),new GLatLng(53.390904,-2.547798),new GLatLng(53.38599,-2.541275),new GLatLng(53.384147,
-2.532691),new GLatLng(53.396636,-2.474327),new GLatLng(53.392951,-2.467803),new GLatLng(53.395817,-2.461624),new GLatLng(53.396022,-2.447891),new GLatLng(53.387628,-2.420082),new GLatLng(53.375546,-2.423515),new GLatLng(53.367557,-2.434158),new GLatLng(53.366123,-2.443084),new GLatLng(53.368991,-2.454414),new GLatLng(53.365099,-2.45613),new GLatLng(53.364074,-2.461967),new GLatLng(53.367762,-2.482566),new GLatLng(53.348092,-2.517242),new GLatLng(53.343173,-2.515525),new GLatLng(53.336818,-2.535781),
new GLatLng(53.330667,-2.542304),new GLatLng(53.332923,-2.548828),new GLatLng(53.323491,-2.559127),new GLatLng(53.330052,-2.58419),new GLatLng(53.32267,-2.59346),new GLatLng(53.332103,-2.618522),new GLatLng(53.343377,-2.604103),new GLatLng(53.347477,-2.609252),new GLatLng(53.346862,-2.630195),new GLatLng(53.359157,-2.625045),new GLatLng(53.364791,-2.628993),new GLatLng(53.367864,-2.611141),new GLatLng(53.375341,-2.603588),new GLatLng(53.374624,-2.597923),new GLatLng(53.386399,-2.590026),new GLatLng(53.385273,
-2.575435),new GLatLng(53.389983,-2.573032),new GLatLng(53.388857,-2.564277),new GLatLng(53.391928,-2.560501)],polygonStrokeColours[MAP_AREA.SOUTH],polygonStrokeWeight,polygonStrokeOpacity,polygonColours[MAP_AREA.SOUTH],polygonOpacity);map.addOverlay(c);var g=new google.maps.Polygon([new GLatLng(53.454531,-2.675857),new GLatLng(53.44758,-2.649078),new GLatLng(53.444921,-2.633972),new GLatLng(53.436128,-2.626419),new GLatLng(53.443899,-2.609596),new GLatLng(53.44349,-2.594146),new GLatLng(53.451055,
-2.593803),new GLatLng(53.440423,-2.581443),new GLatLng(53.427537,-2.555007),new GLatLng(53.423445,-2.582817),new GLatLng(53.422218,-2.619552),new GLatLng(53.41608,-2.596893),new GLatLng(53.407689,-2.592086),new GLatLng(53.39766,-2.5914),new GLatLng(53.391518,-2.583847),new GLatLng(53.386399,-2.590026),new GLatLng(53.374624,-2.597923),new GLatLng(53.375341,-2.603588),new GLatLng(53.367864,-2.611141),new GLatLng(53.364791,-2.628993),new GLatLng(53.362128,-2.644615),new GLatLng(53.355264,-2.673454),
new GLatLng(53.360387,-2.693023),new GLatLng(53.370015,-2.697486),new GLatLng(53.385171,-2.696456),new GLatLng(53.389471,-2.675857),new GLatLng(53.402163,-2.671051),new GLatLng(53.422832,-2.671394),new GLatLng(53.43081,-2.661437),new GLatLng(53.436128,-2.67311),new GLatLng(53.44349,-2.666244),new GLatLng(53.439809,-2.682037),new GLatLng(53.454531,-2.675857)],polygonStrokeColours[MAP_AREA.WEST],polygonStrokeWeight,polygonStrokeOpacity,polygonColours[MAP_AREA.WEST],polygonOpacity);map.addOverlay(g);
google.maps.Event.addListener(a,"click",function(){currentActiveMapArea!=MAP_AREA.CENTRE&&setActiveMapArea(a,MAP_AREA.CENTRE,!0)});google.maps.Event.addListener(d,"click",function(){currentActiveMapArea!=MAP_AREA.NORTH&&setActiveMapArea(d,MAP_AREA.NORTH,!0)});google.maps.Event.addListener(b,"click",function(){currentActiveMapArea!=MAP_AREA.EAST&&setActiveMapArea(b,MAP_AREA.EAST,!0)});google.maps.Event.addListener(c,"click",function(){currentActiveMapArea!=MAP_AREA.SOUTH&&setActiveMapArea(c,MAP_AREA.SOUTH,
!0)});google.maps.Event.addListener(g,"click",function(){currentActiveMapArea!=MAP_AREA.WEST&&setActiveMapArea(g,MAP_AREA.WEST,!0)})}}function resetMap(){map.setCenter(mapZoomedOutCentre,mapZoomedOutLevel);currentActiveMapArea!=MAP_AREA.NONE?(setActiveMapArea(null,MAP_AREA.NONE,!0),document.getElementById("mapSearch").value=""):setActiveMapArea(null,MAP_AREA.NONE,!1)}
function setActiveMapArea(a,d,b){clearVenueLists();for(var c=0;c<markers.length;c++)map.removeOverlay(markers[c]);markers=[];if(b){if(currentActivePolygon&&setActiveMapArea(currentActivePolygon,currentActiveMapArea,!1),a)a.setFillStyle({color:polygonColours[d],opacity:polygonOpacityActive}),a.setStrokeStyle({color:polygonStrokeColourActive,opacity:polygonStrokeOpacityActive,weight:polygonStrokeWeightActive}),currentActivePolygon=a,currentActiveMapArea=d,document.getElementById("mapAreaTitle").innerHTML=
"Retrieving venues for "+mapAreaLongNames[d]+"...",document.getElementById("mapAreaTitle").style.color="orange",getMapAreaVenues(mapAreaNames[d]),map.setCenter(a.getBounds().getCenter(),mapZoomedOutLevel+mapAreaZoomOffsets[d])}else a&&(a.setFillStyle({color:polygonColours[d],opacity:polygonOpacity}),a.setStrokeStyle({color:polygonStrokeColours[d],opacity:polygonStrokeOpacity,weight:polygonStrokeWeight})),currentActivePolygon=null,currentActiveMapArea=MAP_AREA.NONE,document.getElementById("mapAreaTitle").innerHTML=
"Click on an area of Warrington to view its sporting venues",document.getElementById("mapAreaTitle").style.color="white"}
function getMapAreaVenues(a){GDownloadUrl("/vws-map/gen-kml.php?areas="+a,function(a){a=GXml.parse(a);if(a.documentElement==null)document.getElementById("mapAreaTitle").innerHTML="Error retrieving venue map markers from server!",document.getElementById("mapAreaTitle").style.color="#c00";else if(a=a.documentElement.getElementsByTagName("Placemark"),a.length==0)document.getElementById("mapAreaTitle").innerHTML="No results found!",document.getElementById("mapAreaTitle").style.color="#c00";else{markerIcons.length==
0&&(markerIcons[VENUE.CLUB]=createCustomIcon("blue_MarkerC","mm_20_shadow"),markerIcons[VENUE.SPORTS_CENTRE]=createCustomIcon("red_MarkerL","mm_20_shadow"),markerIcons[VENUE.SCHOOL]=createCustomIcon("yellow_MarkerS","mm_20_shadow"),markerIcons[VENUE.VOLUNTEERING_OPPORTUNITY]=createCustomIcon("green_MarkerV","mm_20_shadow"),markerIcons[VENUE.OTHER]=createCustomIcon("orange_MarkerO","mm_20_shadow"),markerIcons[VENUE.UNDEFINED]=createCustomIcon("purple_MarkerU","mm_20_shadow"));for(var b=new GLatLngBounds,
c=0;c<a.length;c++){a[c].getAttribute("id");var g=GXml.value(a[c].getElementsByTagName("name")[0]),j=GXml.value(a[c].getElementsByTagName("description")[0]),e=a[c].getElementsByTagName("Point"),f=GXml.value(e[0].getElementsByTagName("coordinates")[0]);e=GXml.value(a[c].getElementsByTagName("MapVenues")[0]);var i=GXml.value(a[c].getElementsByTagName("Tags")[0]);GXml.value(a[c].getElementsByTagName("PostId")[0]);var k=GXml.value(a[c].getElementsByTagName("PostName")[0]),h=f.split(",");f=parseFloat(h[0]);
h=parseFloat(h[1]);f=new GLatLng(h,f);e=createMarker(f,g,j,e,i,k);e.sidebarEntry=createMapSidebarEntry(e,g,j);map.addOverlay(e);markers.push(e);b.extend(f)}applyMapFilters();document.getElementById("mapAreaTitle").innerHTML="Click on a venue map marker for more details";document.getElementById("mapAreaTitle").style.color="white"}})}
function onVenueListTitleClicked(a){venueShowFlags[a]=!venueShowFlags[a];document.getElementById("map-venue-"+venueListTitles[a]).style.backgroundImage="url("+get_bloginfo_url()+"/wp-content/themes/hybrid-news/images/circle-arrow-"+(venueShowFlags[a]?"down":"right")+".gif)";applyMapFilters()}
function applyMapFilters(){var a=document.getElementById("mapSearch").value;a=a.toLowerCase();clearVenueLists();for(var d=[],b=0;b<venues.length;++b)d[b]=0;for(b=0;b<markers.length;++b){var c=venueShowFlags[markers[b].venue];c&&a!=""&&(c=(","+markers[b].tags).indexOf(","+a)!=-1);c?(markers[b].show(),mapVenuesLists[markers[b].venue].appendChild(markers[b].sidebarEntry),c=++d[markers[b].venue],markers[b].sidebarEntry.className=(c==1?"first":"")+((c&1)==0?"odd":"")):markers[b].hide()}}
function clearVenueLists(){for(var a=0;a<markers.length;++a)markers[a].sidebarEntry.parentNode&&markers[a].sidebarEntry.parentNode.removeChild(markers[a].sidebarEntry)}
function createMarker(a,d,b,c,g,j){for(var e=VENUE.UNDEFINED,f=0;f<venues.length;++f)if(c.indexOf(venues[f])!=-1){e=f;break}var i=new GMarker(a,markerIcons[e]);i.venue=e;i.tags=g;var k=[];k.push(""+d+"");var h=[];h.push('<div style="text-align: left; width: 300px;"><div style="font: 18px Verdana; text-align: center; margin-bottom: 8px; color: '+venueMouseOverColours[e]+';">'+d+'</div><div style="font: 12px/22px Verdana; margin-bottom: 8px; color: black;">'+(b!=""?b:"Short description to go here!")+
'</div><div style="position: absolute; top: -37px; left: -42px;"><img src="'+get_bloginfo_url()+'/vws-map/images/wasp.gif"/></div><div style="float: right; text-align: right; font: 12px Verdana;"><a href="'+get_bloginfo_url()+"/"+j+'">Click for more details...</a><br/></div></div>');GEvent.addListener(i,"click",function(){for(var a=[],b=0;b<h.length;b++)a.push(new GInfoWindowTab(k[b],h[b]));i.openInfoWindowTabsHtml(a)});return i}
function createCustomIcon(a,d){var b=new GIcon;b.image=get_bloginfo_url()+"/vws-map/images/markers/"+a+".png";b.shadow=get_bloginfo_url()+"/vws-map/images/markers/"+d+".png";b.iconSize=new GSize(18,30);b.shadowSize=new GSize(33,30);b.iconAnchor=new GPoint(6,20);b.infoWindowAnchor=new GPoint(5,1);return b}
function createMapSidebarEntry(a,d){var b=document.createElement("div");b.innerHTML='<img src="'+markerIcons[a.venue].image+'" style="padding: 0px 8px 0px 16px; color: #111; width: 12px; height: 18px; margin-top: 2px;" alt=""/><span style="position: relative; top: -4px;">'+d+"</span>";b.style.listStyleType="none";b.style.marginLeft="0px";b.style.paddingLeft="0px";b.style.cursor="pointer";GEvent.addDomListener(b,"click",function(){GEvent.trigger(a,"click")});GEvent.addDomListener(b,"mouseover",function(){b.style.color=
venueMouseOverColours[a.venue]});GEvent.addDomListener(b,"mouseout",function(){b.style.color="#111"});return b}function map_pageUnload(){google.maps.Unload()};
