function initializeMap(campusid) {

if (GBrowserIsCompatible()) {
  var gmarkers = [];
  var htmls = [];
  var i = 0;
  
  /* Create some custom icons */
  
  /* This icon uses the same shape as the default Google marker */
  /* So we can use its details for everything except the image */

  var blueIcon = new GIcon(G_DEFAULT_ICON);        
  blueIcon.image = "/media/images/icons/ww-logo.png";			
  blueIcon.shadow = "/media/images/icons/ww-shadow.png";			
  blueIcon.iconSize = new GSize(20, 40);		
  blueIcon.shadowSize = new GSize(44, 40);						
  markerOptions = { icon:blueIcon };
  
  /* An array of GIcons, to make the selection easier */
  var icons = [];
  icons[0] = blueIcon;

  /* the icon information is passed to this function */
  function createMarker(point,name,html,icontype) {
	var marker = new GMarker(point,icons[icontype]);
	GEvent.addListener(marker, "click", function() {
	  marker.openInfoWindowHtml(html);
	});
	/* save the info we need to use later for the side_bar */
	gmarkers[i] = marker;
	htmls[i] = html;
	return marker;
  }

  function myclick(i) {
	gmarkers[i].openInfoWindowHtml(htmls[i]);
  }

  var map = new GMap2(document.getElementById("map"),{size: new GSize(550,450)});
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());

  /* Read the data from campusLocations.xml */
  var request = GXmlHttp.create();
  request.open("GET", "/media/files/xml/campusLocations.xml", true);
  request.onreadystatechange = function() {
	if (request.readyState == 4) {
	  var xmlDoc = GXml.parse(request.responseText);
	  /* obtain the array of markers and loop through it */
	  var markers = xmlDoc.documentElement.getElementsByTagName("marker");
	   
	  for (var i = 0; i < markers.length; i++) {
		/* obtain the attribues of each marker */
		var id = markers[i].getAttribute("id");
		var state = markers[i].getAttribute("state");
		var lat = parseFloat(markers[i].getAttribute("lat"));
		var lng = parseFloat(markers[i].getAttribute("lng"));
		var point = new GLatLng(lat,lng);
		var html = markers[i].getAttribute("html");
		var label = markers[i].getAttribute("label");
		var icontype = parseInt(markers[i].getAttribute("icontype"));
		/* create the marker */
		if (id == campusid) {
		map.setCenter(new GLatLng(lat, lng), 11);
		var marker = createMarker(point,label,html,icontype);
		map.addOverlay(marker);
		marker.openInfoWindowHtml(html);
		}
	  }          
	}
  }
  request.send(null);
}

else {
  alert("Sorry, the Google Maps API is not compatible with this browser");
}

}

$(document).ready(function(){
	$("div#map").each(function(){
		initializeMap($(this).attr("campusid"));
	});
});

