function initializeStateMap(statecode,zoom) {
    if (GBrowserIsCompatible()) {
 
      var gmarkers = [];
      var htmls = [];
      var i = 0;
	  var zoomlevel = zoom;
      
      // 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;
        // add a line to the side_bar html

        return marker;
      }


      var map = new GMap2(document.getElementById("mapstate"),{size: new GSize(450,350)});
	  var bounds = new GLatLngBounds();
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(33.94869481,-117.972393), zoomlevel);


      // Read the data from custom.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 state = markers[i].getAttribute("state");
			if (state == statecode) {
	            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
	            var marker = createMarker(point,label,html,icontype);
	            map.addOverlay(marker);
				bounds.extend(point);
			}
          }
		  map.setCenter(bounds.getCenter());
        }
      }
      request.send(null);
    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

}
$(document).ready(function(){
	vstate = $("div#mapstate").attr("statecode");
	vzoom = $("div#mapstate").attr("zoomlevel");
	initializeStateMap(vstate,10);
	/*
	$("div#mapstate").each(function(){
		vzoom = $(this).attr("zoomvalue");
		vstate = $(this).attr("statecode");
		initializeStateMap(vstate,vzoom);
	});
	*/
});
