function initialize() {
  var myOptions = {
    zoom: 14,
    center: new google.maps.LatLng(51.381991, -0.46656175),
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  var map = new google.maps.Map(document.getElementById("map_canvas"),
                                myOptions);

  setMarkers(map, schools);
}

/**
 * Data for the markers consisting of a name, a LatLng and a zIndex for
 * the order in which these markers should display on top of each
 * other.
 */
var sgc = '<div style="font-family:arial;font-size:76.92%;float:left;width:102px">'+
'St George\'s College<br/>'+
'Weybridge Road<br/>'+
'Addlestone, Surrey<br/>'+
'KT15 2QS<br/>'+
'01932 839300'+
'</div><div style="float:left;width:112px;"><img src="/images/sgc/sgc-col.png" width="112" height="112" /></div>';
var sgcjs = '<div style="font-family:arial;font-size:76.92%;float:left;width:102px">'+
'St George\'s College Junior School<br/>'+
'Thames Street,<br/>'+
'Weybridge,<br/>'+
'Surrey<br/>'+
'KT13 8NL<br/>'+
'01932 839400'+
'</div><div style="float:left;width:119px;"><img src="/images/sgc/sgc-colj.png" width="119" height="119" /></div>';

var schools = [
  ['St George\'s College', 51.3766960, -0.4783960, 1,sgc],
  ['St George\'s College Junior School', 51.3772861, -0.4547275,2,sgcjs]
];
var markers = [];
var infowindows = [];

function setMarkers(map, locations) {
  var image = new google.maps.MarkerImage('/images/sgc/sgc-gm.png',
      new google.maps.Size(42, 42),
      new google.maps.Point(0,0),
      new google.maps.Point(24, 37));
      
   var shadow = new google.maps.MarkerImage('',
      new google.maps.Size(42, 42),
      new google.maps.Point(0,0),
      new google.maps.Point(24, 37));

  var shape = {
      coord: [1, 1, 1, 42,42,42,42 , 1],
      type: 'poly'
  };

  for (var i = 0; i < locations.length; i++) {
    var school = locations[i];
    var myLatLng = new google.maps.LatLng(school[1], school[2]);
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        shadow: shadow,
        icon: image,
        shape: shape,
        title: school[0],
        zIndex: school[3]
    });
    markers[i] = marker;
    infowindows[i]= new google.maps.InfoWindow({
       content: school[4]
    });
    google.maps.event.addListener(marker, 'click', (function(marker,map,i) { return function () {
        infowindows[i].open(map,markers[i]);
    }})(marker,map,i));

    infowindows[i].open(map,markers[i]);
  }
}

$(function(){
    $(window).unload( function () { GUnload(); } );
    $(window).load(function(){
      initialize(); 
    });
})