
      // A function to create the marker and set up the event window
function newCreateMarker(point,name,html,pagelink,image,spot) {

        var linkid = "link"+ii;
        var bubbletext = '<table><tr><td rowspan="2"><img src=./'+image+' height="60px"/></td><td valign="top"><b>'+name+'</b></td></tr><tr><td valign="bottom">'+html+'</td></tr></table>';
        var markerspot = "http://stage.gsd.harvard.edu/inside/student_services/hypermap/poi/images/placemarkers/"+spot;
        
	// var baseIcon = new GIcon(G_DEFAULT_ICON);
        var greenIcon = new GIcon(G_DEFAULT_ICON);
        greenIcon.image = markerspot; 
        greenIcon.iconSize = ('2','5');
        greenIcon.iconSize = new GSize(5, 41);
        greenIcon.shadowSize = new GSize(10, 49);
 

        markerOptions = { icon:greenIcon };


        var marker = new GMarker(point,markerOptions);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(bubbletext);
          document.getElementById(linkid).style.background="#ffff00";
          document.getElementById('pageframe-iframe').src = pagelink;
          lastlinkid=linkid;
        });
        gmarkers[ii] = marker;
        htmls[ii] = bubbletext;
        pagelinks[ii] = pagelink;
        side_bar_html += '<div id="'+linkid+'"><a href="javascript:myclick(' + ii + ')">' + name + '</a></div>';
        ii++;
        return marker;
      }

      // A function to read the data
function newReadMap(url, divID) {
        var request = GXmlHttp.create();
        request.open("GET", url, 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");
            
            // hide the info window, otherwise it still stays open where the removed marker used to be
            map.getInfoWindow().hide();
            
            map.clearOverlays();            
            
            // empty the arrays
            gmarkers = [];
            htmls = [];
            ii = 0;

            // reset the side_bar
            side_bar_html="";
          
            for (var i = 0; i < markers.length; i++) {
              // obtain the attribues of each marker
              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 pagelink = markers[i].getAttribute("link");
              var image = markers[i].getAttribute("image");
              var spot = markers[i].getAttribute("spot");
              // create the marker
              var marker = newCreateMarker(point,label,html,pagelink,image,spot);
              map.addOverlay(marker);
            }
            // put the assembled side_bar_html contents into the side_bar div
            document.getElementById(divID).innerHTML = side_bar_html;

          }
        }
        request.send(null);
      }



//this function is run when there is no hierarchy in the sidebar
function noFlip() {
                var id = "arch";
		var e = document.getElementById('arch');
		var i = document.getElementById("t_" + "arch");
		var xmlfile = "arch" + "_spots.xml";

                 map.clearOverlays();
	         e.iner_html = newReadMap(xmlfile,id);
	         e.style.display = "block";

}



//this function is for flipping open and loading sub-divs in the sidebar
 function newFlip(id) {

		var e = document.getElementById(id);
		var i = document.getElementById("t_" + id);
		var xmlfile = id + "_spots.xml";

		if (!(e && i)) { return false; }
		
		if (e.style && e.style.display != "none") {

				e.style.display = "none";
				i.src = "images/plus.gif";
		}
		else if (e.style) {
                    map.clearOverlays();
		    e.iner_html = newReadMap(xmlfile,id);
				e.style.display = "block";
				i.src = "images/minus.gif";

		}
		else {

				return true;
		}
}





function hellogm(param) {
    alert("hi bye " + param);
}
