//<![CDATA[
    if (GBrowserIsCompatible()) {
    						// this variable will collect the html which will eventualkly be placed in the side_bar
    	var side_bar_html = "";
        
    					// arrays to hold copies of the markers used by the side_bar
    					// because the function closure trick doesnt work there
    	var gmarkers = [];
        var i = 0;
        var id = 1;
				//subtract 1 to be in line with array iteration. Gets reset later.
        var this_one = id - 1;
					// If there are any parameters at the end of the URL, they will be in  location.search
					// looking something like  "?id=1"
					// skip the first character, we are not interested in the "?"
        var query = location.search.substring(1);
					// break each pair at the first "=" to obtain the argname and value
        var pos = query.indexOf("=");
					// argname should be id
        var argname = query.substring(0,pos).toLowerCase();
        var value = query.substring(pos+1).toLowerCase();
					// process each possible argname. in this case only id. id is now the number in the address bar
        if (argname == "id") {id = parseInt(value);}

//	***********************************   These are functions called by the code  ***********************************************************
//                var marker = createMarker(point,user_id,menu_item,html);
					// A function to create the marker and set up the event window
	function createMarker(point,user_id,menu_item,html) {
  	var marker = new GMarker(point);
  	GEvent.addListener(marker, "click", function() {
  		marker.openInfoWindowHtml(html);
  	});
					// save the info we need to use later for the side_bar
		gmarkers.push(marker);
		
					// add a line to the side_bar html
					var refresh_link = "<a href=\"http://www.bandeedigital.com/map.php?id=" + user_id + "\">"
			side_bar_html += refresh_link + user_id + ".&nbsp;" + menu_item + "<\/a><br />";
//		side_bar_html += '<a href="javascript:myclick(' + (gmarkers.length-1) + ')">' + user_id + '.&nbsp;' + menu_item + '<\/a><br>';

		return marker;
	}

					// This function picks up the click and opens the corresponding info window
	function myclick(i) {
		GEvent.trigger(gmarkers[i], "click");
	}
//	**********************************************************************************************************************

					// Read the data from the_markers.xml
    	GDownloadUrl("library/the_markers.xml", function(doc) {
    		var xmlDoc = GXml.parse(doc);
    		var markers = xmlDoc.documentElement.getElementsByTagName("marker");
    		var no_markers = markers.length
    		// Check which marker needs to be centered and opened when new map is drawn
            for (var i = 0; i < no_markers; i++) {
                var user_id = parseInt(markers[i].getAttribute("user_id"));
                if (id == user_id) {
                	this_one = i;
                	continue;
                }
            }
            var lat = parseFloat(markers[this_one].getAttribute("lat"));
            var lng = parseFloat(markers[this_one].getAttribute("lng"));
            var os_lat = parseFloat(markers[this_one].getAttribute("os_lat"));
            var os_lng = parseFloat(markers[this_one].getAttribute("os_lng"));
            var magnify = parseInt(markers[this_one].getAttribute("magnify"));
            var map_type = markers[this_one].getAttribute("map_type");

            var cntr_lat = lat + (os_lat*0.001);
            var cntr_lng = lng + (os_lng*0.001);

            if (map_type == "nml") {maptype = G_NORMAL_MAP;}
            if (map_type == "sat") {maptype = G_SATELLITE_MAP;}
            if (map_type == "hyb") {maptype = G_HYBRID_MAP;}

            					// create the map
            var map = new GMap2(document.getElementById("map"));
            map.addControl(new GLargeMapControl());
            map.addControl(new GMapTypeControl());
            map.setCenter(new GLatLng( cntr_lat, cntr_lng), magnify);
						map.setMapType(maptype);

            
            for (var i = 0; i < no_markers; i++) {
        					// obtain the attribues of each marker
                var user_id = parseInt(markers[i].getAttribute("user_id"));
                var menu_item = markers[i].getAttribute("menu_item");
                var name = markers[i].getAttribute("name");
                var link = markers[i].getAttribute("link");
                var lat = parseFloat(markers[i].getAttribute("lat"));
                var lng = parseFloat(markers[i].getAttribute("lng"));
                var html = "<b>" + user_id + ".  " + name + "</b><br /><a href= \"" + link + "\">more info...</a><br />";
                var point = new GLatLng(lat,lng);
        					// create the marker
                var marker = createMarker(point,user_id,menu_item,html);
                map.addOverlay(marker);
            }

  					// put the assembled side_bar_html contents into the side_bar div
		document.getElementById("side_bar").innerHTML = side_bar_html;
            if (this_one < no_markers) {GEvent.trigger(gmarkers[this_one],"click");}
	});
}

else {
	alert("Sorry, the Google Maps API is not compatible with this browser");
}

//]]>