var theXML = 'inc/mapdata.xml';
var map, markers, xml;

function loadmap(){
      if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));
    map.setCenter(new GLatLng(37.4419, -122.1419), 13);
    
       map.setCenter(new GLatLng(10.153938,90.166875), 2);
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.addControl(new GScaleControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(20,35)));
    
      GDownloadUrl(theXML, function(data, responseCode) {
      xml = GXml.parse(data);
      //
      locations	= xml.documentElement.getElementsByTagName("Location");
      configuremap(locations);
      });
      
      
          }
}

function configuremap(locations) {
	if (GBrowserIsCompatible()) {
		// configure markers for projects
		for (var j = 1; j < locations.length; j++) {
			configureMarkers(locations[j],'location');
		}
	}
}
//
//
// configures markers based on supplied XML nodes and type
function configureMarkers(nodes, type) {
	var point, name, description;
	point = new GLatLng(parseFloat(nodes.getAttribute("lat")), parseFloat(nodes.getAttribute("long")));
	//latlong = new GLatLng(-21.153938,149.166875);
	namepre = nodes.getAttribute("name");
	var name = namepre.replace("`", "'");
	description = nodes.getAttribute("description");
	icon = new GIcon();				
	icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	icon.iconSize = new GSize(15, 15);
	icon.shadowSize = new GSize(5, 5);
	icon.iconAnchor = new GPoint(7, 7);
	icon.infoWindowAnchor = new GPoint(10, 1);
  	icon.image = "images/nodeproject.png";
  marker = new GMarker(point, icon);
  GEvent.addListener(marker, "click", function() {
    this.openInfoWindowHtml("<b>" + name + "</b><br>" + description + "");
  });
	map.addOverlay(marker);
}
