var map;


//var icon = new GIcon();
//icon.image = "http://www.google.com/mapfiles/marker.png";
//icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
//icon.iconSize = new GSize(20, 34);
//icon.shadowSize = new GSize(37, 34);
//icon.iconAnchor = new GPoint(10, 34);
//icon.text = "Hello!";
var icon = new GIcon();
    icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
    icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    icon.iconSize = new GSize(12, 20);
    icon.shadowSize = new GSize(22, 20);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);      

    iconblue = new GIcon(icon,"http://labs.google.com/ridefinder/images/mm_20_blue.png"); 
    icongreen = new GIcon(icon,"http://labs.google.com/ridefinder/images/mm_20_green.png"); 
    iconyellow = new GIcon(icon,"http://labs.google.com/ridefinder/images/mm_20_yellow.png");

function usePointFromPostcode(postcode, html, club_status) 
{
	var localSearch = new GlocalSearch();
	localSearch.setSearchCompleteCallback(null, 
		function() {
			if (localSearch.results[0])
			{		
				var resultLat = localSearch.results[0].lat;
				var resultLng = localSearch.results[0].lng;
				var point = new GLatLng(resultLat,resultLng);
				placeMarkerAtPoint(html,club_status,point);
			}
		});
	localSearch.execute(postcode + ", UK");
}

function placeMarkerAtPoint(html,club_status,point)
{
  if(club_status==2) {
		var marker = new GMarker(point, {icon:iconyellow});
	}
	else {
		var marker = new GMarker(point, {icon:iconblue});
	}
  GEvent.addListener(marker, "click", function() {
   marker.openInfoWindowHtml(html);
  });
	map.addOverlay(marker);
}




$(document).ready(function () 
{
  if(!document.getElementById("map"))
    return false;
	if (GBrowserIsCompatible()) 
	{
		map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(50.7851,-3.9331 ), 7);
    map.setUIToDefault();
	}
});