// JavaScript Document
//<![CDATA[

    var iconBlue = new GIcon(); 
    iconBlue.image = 'http://www.terrynagel.com/phpcms/images/markers/marker_5.png';
    iconBlue.shadow = 'http://www.terrynagel.com/phpcms/images/markers/marker_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

    var iconRed = new GIcon(); 
    iconRed.image = 'http://www.terrynagel.com/phpcms/images/markers/marker_6.png';
    iconRed.shadow = 'http://www.terrynagel.com/phpcms/images/markers/marker_shadow.png';
    iconRed.iconSize = new GSize(12, 20);
    iconRed.shadowSize = new GSize(22, 20);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);
	
	var iconYellow = new GIcon(); 
    iconYellow.image = 'http://www.terrynagel.com/phpcms/images/markers/marker_7.png';
    iconYellow.shadow = 'http://www.terrynagel.com/phpcms/images/markers/marker_shadow.png';
    iconYellow.iconSize = new GSize(12, 20);
    iconYellow.shadowSize = new GSize(22, 20);
    iconYellow.iconAnchor = new GPoint(6, 20);
    iconYellow.infoWindowAnchor = new GPoint(5, 1);
	
	var iconGreen = new GIcon(); 
    iconGreen.image = 'http://www.terrynagel.com/phpcms/images/markers/marker_8.png';
    iconGreen.shadow = 'http://www.terrynagel.com/phpcms/images/markers/marker_shadow.png';
    iconGreen.iconSize = new GSize(12, 20);
    iconGreen.shadowSize = new GSize(22, 20);
    iconGreen.iconAnchor = new GPoint(6, 20);
    iconGreen.infoWindowAnchor = new GPoint(5, 1);
	
	var iconGray = new GIcon(); 
    iconGray.image = 'http://www.terrynagel.com/phpcms/images/markers/marker_9.png';
    iconGray.shadow = 'http://www.terrynagel.com/phpcms/images/markers/marker_shadow.png';
    iconGray.iconSize = new GSize(12, 20);
    iconGray.shadowSize = new GSize(22, 20);
    iconGray.iconAnchor = new GPoint(6, 20);
    iconGray.infoWindowAnchor = new GPoint(5, 1);
	
	var iconYellow = new GIcon(); 
    iconYellow.image = 'http://www.terrynagel.com/phpcms/images/markers/marker_0.png';
    iconYellow.shadow = 'http://www.terrynagel.com/phpcms/images/markers/marker_shadow.png';
    iconYellow.iconSize = new GSize(12, 20);
    iconYellow.shadowSize = new GSize(22, 20);
    iconYellow.iconAnchor = new GPoint(6, 20);
    iconYellow.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons[2005] = iconBlue;    
	customIcons[2006] = iconRed;
	customIcons[2007] = iconYellow;
	customIcons[2008] = iconGreen;
	customIcons[2009] = iconGray;
	customIcons[2010] = iconYellow;


	
    function initialize() {
      if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(37.5810, -122.365), 13);
		map.addControl(new GSmallMapControl());
		GDownloadUrl('maps.xml', function(data) {
		var xml = GXml.parse(data);
		var markers = xml.documentElement.getElementsByTagName("location");
		for (var i = 0; i < markers.length; i++) {
			var postdate = markers[i].getAttribute("date");
			var year = markers[i].getAttribute("year");
			var address = markers[i].getAttribute("address");
			var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
									parseFloat(markers[i].getAttribute("lng")));
			var marker = createMarker(point,address,postdate,year);
			map.addOverlay(marker);

          	}
        });
      }
	}
    function createMarker(point,address,postdate,year) {
	var marker = new GMarker(point,customIcons[year]);
	var html =  postdate + "<br />" + address ;
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });

      return marker;
    }
    //]]>

