(function()
{
  if (window.addEventListener)
  {
    window.addEventListener("load", setup, false);
    window.addEventListener("unload", close, false);
  }
  else
  {
    window.attachEvent("onload", setup);
    window.attachEvent("onunload", close);
  }
})();

function setup()
{
  var location = document.getElementById("maparea1");
	
  if (GBrowserIsCompatible())
  {
    var map = new GMap2(location);
    //Change the latitude and longitude as well as the zoom level in the line below.
    map.setCenter(new GLatLng(52.2740565,-1.3466655), 8);
    map.setUIToDefault();
		
    addMarkers(map);
  }
}

function addMarkers(map)
{
  var number = 7;	//Set this to the number of markers that will be used
			
  var latlngs = new Array(number);
	
  for (var i = 0; i < latlngs.length; i++)
  {
    latlngs[i] = new Array(2);	
  }
	
  //Add the latitude, longitude, and description of all of your marker locations to the array
  latlngs[0][0] = new GLatLng(52.2398493, -0.8808784);
  latlngs[0][1] = "<font style='font-size:13px;font-weight:bold;color:#455660;'>39-43 St Edmunds Road<br>Northampton<br>Northamptonshire<br>NN1 5DY</font><br><a href='schools/school-northampton.html'><font style='font-size:13px;font-weight:bold;'>View Details</font></a>";

latlngs[1][0] = new GLatLng(52.4095, -1.5072);
  latlngs[1][1] = "<font style='font-size:13px;font-weight:bold;color:#455660;'>Coventry Sports Complex<br>Fairfax<br>Coventry<br>CV1 5RP</font><br><a href='schools/school-coventry.html'><font style='font-size:13px;font-weight:bold;'>View Details</font></a>";	

  latlngs[2][0] = new GLatLng(52.2861129, -1.5396321);
  latlngs[2][1] = "<font style='font-size:13px;font-weight:bold;color:#455660;'>The Old Library<br>Avenue Road<br>Leamington Spa<br>Warwickshire<br>CV31 3PG</font><br><a href='schools/school-leamington.html'><font style='font-size:13px;font-weight:bold;'>View Details</font></a>";

  latlngs[3][0] = new GLatLng(52.187316, -1.708066);
  latlngs[3][1] = "<font style='font-size:13px;font-weight:bold;color:#455660;'>The Holy Trinity Parish Centre<br>Old Town<br>Stratford Upon Avon<br>CV37 6BG</font><br><a href='schools/school-stratford.html'><font style='font-size:13px;font-weight:bold;'>View Details</font></a>";

  latlngs[4][0] = new GLatLng(52.218158, -1.86767);
  latlngs[4][1] = "<font style='font-size:13px;font-weight:bold;color:#455660;'>The Greig<br>Kinwarton Road<br>Alcester<br>Warwickshire<br>B49 6AD</font><br><a href='schools/school-alcester.html'><font style='font-size:13px;font-weight:bold;'>View Details</font></a>";
  
  latlngs[5][0] = new GLatLng(52.307271,-1.941267);
  latlngs[5][1] = "<font style='font-size:13px;font-weight:bold;color:#455660;'>Redditch</font><br><a href='schools/school-redditch.html'><font style='font-size:13px;font-weight:bold;'>View Details</font></a>";

  latlngs[6][0] = new GLatLng(52.285835,-1.537838);
  latlngs[6][1] = "<font style='font-size:13px;font-weight:bold;color:#455660;'>The Basement<br>The Old Library<br>Avenue Road<br>Leamington Spa<br>Warwickshire<br>CV31 3PG</font><br><a href='schools/school-midlands-regional.html'><font style='font-size:13px;font-weight:bold;'>View Details</font></a>";
  
  
  //latlngs[4][0] = new GLatLng(52.440527, -1.848588);
  //latlngs[4][1] = "<font style='font-size:13px;font-weight:bold;color:#455660;'>Hall Green Methodist Church<br>609 Reddings Lane<br>Hall Green<br>Birmingham<br>B28 8TE</font><br><a href='schools/school-birmingham.html'><font style='font-size:13px;font-weight:bold;'>View Details</font></a>";
			
  for (var i = 0; i < latlngs.length; i++)
  {						
    addMarker(map, latlngs[i][0], latlngs[i][1]);    
  }
}

function addMarker(map, latlng, descr)
{
  var marker = new GMarker(latlng);
  GEvent.addListener(marker, "click", function()
  {		    		   
    map.openInfoWindowHtml(latlng, descr);
  });
  map.addOverlay(marker);	
}

function close()
{
  GUnload();	
}

