var map
// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(16, 28);
baseIcon.shadowSize = new GSize(40, 28);
baseIcon.iconAnchor = new GPoint(0, 28);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
var yellowIcon = new GIcon(baseIcon)
var blueIcon = new GIcon(baseIcon)
var orangeIcon = new GIcon(baseIcon)
var pinkIcon = new GIcon(baseIcon)
var greenIcon = new GIcon(baseIcon)

yellowIcon.image = "/img/maps/yellow.png"
blueIcon.image = "/img/maps/blue.png"
orangeIcon.image = "/img/maps/orange.png"
pinkIcon.image = "/img/maps/pink.png"
greenIcon.image = "/img/maps/green.png"

function changeOverlay(){
	var chkLacs = document.getElementById('chkLacs').checked
	var chkCentres = document.getElementById('chkCentres').checked
	var chkLibraries = document.getElementById('chkLibraries').checked
	var chkSchools = document.getElementById('chkSchools').checked
	var chkCafes = document.getElementById('chkCafes').checked
	map.clearOverlays()
	if (chkLacs){addLacs()}
	if (chkCentres){addCentres()}
	if (chkLibraries){addLibs()}
	if (chkSchools){addSchools()}
	if (chkCafes){addCafes()}
	document.getElementById('txtSearch').focus()
}

function createMarker(point, index, lacTitle, address, lacid, mapIcon) {
	  // Set up our GMarkerOptions object
	  markerOptions = { icon:mapIcon,title:lacTitle };
	  var marker = new GMarker(point, markerOptions);
	
	  GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml('<h3>' + lacTitle + '</h3><p>' + address + '</p><a href="/learning/showlac.asp?id=' + lacid + '">Centre Details</a>');
	  });
	  return marker;
	}
    
    function TextualZoomControl() {
    }
    
    TextualZoomControl.prototype = new GControl();

    // Creates a one DIV for each of the buttons and places them in a container
    // DIV which is returned as our control element. We add the control to
    // to the map container and return the element for the map class to
    // position properly.
    TextualZoomControl.prototype.initialize = function(map) {
      var container = document.createElement("div");

      var zoomInDiv = document.createElement("div");
      this.setButtonStyle_(zoomInDiv);
      container.appendChild(zoomInDiv);
      zoomInDiv.appendChild(document.createTextNode("+"));
      GEvent.addDomListener(zoomInDiv, "click", function() {
        map.zoomIn();
      });

      var zoomOutDiv = document.createElement("div");
      this.setButtonStyle_(zoomOutDiv);
      container.appendChild(zoomOutDiv);
      zoomOutDiv.appendChild(document.createTextNode("-"));
      GEvent.addDomListener(zoomOutDiv, "click", function() {
        map.zoomOut();
      });

      map.getContainer().appendChild(container);
      return container;
    }

    // By default, the control will appear in the top left corner of the
    // map with 7 pixels of padding.
    TextualZoomControl.prototype.getDefaultPosition = function() {
      return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
    }

    // Sets the proper CSS for the given button element.
    TextualZoomControl.prototype.setButtonStyle_ = function(button) {
      button.className = 'mapButton';
    }