//<![CDATA[
var gmarkers = new Array();
var i = 0;
var baseicon = new GIcon();
baseicon.image = "http://stage.utah.com/art/maps/orange-marker.png";
baseicon.shadow = "http://stage.utah.com/art/maps/marker-background.png";
baseicon.iconSize = new GSize(20, 20);
baseicon.shadowSize = new GSize(20, 20);
baseicon.iconAnchor = new GPoint(9, 19);
baseicon.infoWindowAnchor = new GPoint(9, 10);
	
// This function picks up the click and opens the corresponding info window
function showMapMarker() {
  GEvent.trigger(gmarkers[0], "click");
}

function loadthingmap(clat, clong, zlevel, info) {
  if (GBrowserIsCompatible()) {				
	var map = new GMap2(document.getElementById("gmap"));
	map.addControl(new GMapTypeControl());
	map.addControl(new GSmallMapControl());
	map.setCenter(new GLatLng(clat, clong), zlevel);
	
	// Creates a marker at the given point with the given number label
	function createMarker(point, label, html) {
	  var marker = new GMarker(point, { icon: baseicon, title: label });
	  GEvent.addListener(marker, "click", function() {
	    marker.openInfoWindowHtml( html, { maxWidth: 275 }	);
	  });
	  gmarkers[i] = marker;
	  i++;
	  return marker;
	}				
	
	function showPoint(p, label, descr) {
	  var html = '<div style="padding: 10px;"><span style="font: 12px arial"><b>' + label + '</b>' + (descr ? '<br />' + descr : '') + '</span></div>';
	  var gps = p.split(/,\s*/);
	  var point = new GLatLng(gps[0], gps[1]);
	  if(point != null){
		map.addOverlay(createMarker(point, label, html));
	  }
	}
	var map_p = info[0];
	var map_l = info[1];
	var map_ld = info[2];
	for(x = 1; x < map_p.length; x++){
		showPoint(map_p[x], map_l[x], map_ld[x]);
	}
	setTimeout("showMapMarker()", 1000);
  }
}
//]]>
