   //<![CDATA[  
var map;
var marker = [];
var feed;
var bounds = new GLatLngBounds();
var markerImage = [
G_DEFAULT_ICON.image,
"http://maps.google.com/mapfiles/dd-start.png",
"http://maps.google.com/mapfiles/dd-end.png",
"http://esa.ilmari.googlepages.com/markeryellow.png",//3 yellow
"http://www.google.com/uds/samples/places/temp_marker.png"//4 turquoise
];
// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
var cm_baseIcon = new GIcon();

cm_baseIcon.iconSize = new GSize(20, 34);

cm_baseIcon.iconAnchor = new GPoint(9, 34);
cm_baseIcon.infoWindowAnchor = new GPoint(9, 2);
cm_baseIcon.infoShadowAnchor = new GPoint(18, 25);
// Change these parameters to customize map
var param_wsId = "od6";
var param_ssKey = "o16162288751915453340.4402783830945175750";
var param_titleColumn = "title";
var param_descriptionColumn = "description";
var param_latColumn = "latitude";
var param_lngColumn = "longitude";
var param_rankColumn = "rank";
var param_mainIconType = "blue";
var param_iconType = "green";
var param_iconOverType = "orange";
var maplink = " ";

function load(){
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(prefs.latitude, prefs.longitude), 12);


map.addControl(new GMapTypeControl(1));
map.addControl(new GLargeMapControl());
map.addControl(new GScaleControl(300));
        geocoder = new GClientGeocoder();
        gdir = new GDirections(map, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);
new GKeyboardHandler(map);
map.enableContinuousZoom();
map.enableDoubleClickZoom();
    var lat = prefs.latitude;
    var lng = prefs.longitude;
	if(prefs.address){
    var label = '<strong>'+prefs.dir+'</strong><Br>'+prefs.address+'<br>'+prefs.city+' '+prefs.state+' '+prefs.zip;
	}
	else{
	var label = '<strong>'+prefs.dir+'</strong><Br>';
	}

    var point = new GLatLng(lat,lng);
    ZMarker(point,label,1,0,0,null);
    bounds.extend(point);
		 

ajaxCallFunction("ajax.iml?mdl=get_client_attractions.aj&Listing="+prefs.listing+"&CLIENTID="+prefs.client+"&"+Date(),function(sc,st,rt,rxml){
 ent = rxml.getElementsByTagName('ent_item');
for(i=0; i<ent.length; i++){

	lat = getTagValue(ent[i],'latitude');
	lng = getTagValue(ent[i],'longitude');
	cat = getTagValue(ent[i],'cat');
	color = getTagValue(ent[i],'color');
	name = getTagValue(ent[i],'name');
	address = getTagValue(ent[i],'address');
	city = getTagValue(ent[i],'city');
	state = getTagValue(ent[i],'state');
	zip = getTagValue(ent[i],'zip');
	country = getTagValue(ent[i],'country');
	point = new GLatLng(lat,lng);
	label = getTagValue(ent[i],'text');
	markercount = getTagValue(ent[i],'listcount');
	groupcount = getTagValue(ent[i],'groupcount');


        ZMarker(point,label,1,0,markercount,groupcount,null,color);



 }
         }); 



// Fit and zoom 2 lines out
//map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds));
map.setCenter(new GLatLng(prefs.latitude, prefs.longitude), 12);
//map.zoomOut();map.zoomOut();
}
// A special createZMarker function
// 'infowindowclose' listener is attached to marker
// It deletes the marker and creates a copy with lower z-index
// Feel free to use but please include:
// Originally created by Esa 2007
var n=1;
function count(){
n++;
return n;
}
function ZMarker(point,label,n,imInd,i,group_num,visited,color) {
function sendBack(marker,b) {
return GOverlay.getZIndex(marker.getPoint().lat())-n*10000;
}
    var markerOpts = {};
    var nIcon = new GIcon(cm_baseIcon);
    var num = (group_num *1);
    if (i==0) {
        nIcon.imageOut = "http://www.google.com/uds/samples/places/temp_marker.png";
        nIcon.imageOver = "http://www.google.com/uds/samples/places/temp_marker.png";
    } else {
        nIcon.imageOut = "http://gmaps-samples.googlecode.com/svn/trunk/markers/" + color + "/marker" + num + ".png";
        nIcon.imageOver = "http://gmaps-samples.googlecode.com/svn/trunk/markers/" + param_iconOverType + "/marker" + num + ".png";
    }
    nIcon.image = nIcon.imageOut;
  markerOpts.icon = nIcon;
//marker[i] = new GMarker(point,{title:label, zIndexProcess:sendBack});
marker[i] = new GMarker(point,markerOpts);
map.addOverlay(marker[i]);
//marker[i].setImage(markerImage[imInd]);
marker[i].setImage(nIcon.imageOut);
marker[i].visited = visited;
GEvent.addListener(marker[i], "click", function() {
//marker[i].openInfoWindowHtml(label);
var foo = label.indexOf("~");      // first occurrence of :
if (foo==0) {
    var foo2 = label.indexOf("|");    // first occurrence of |
    var label1 = label.substring(foo2);
    alert(label1);
    var label2 = label.replace(/\|/g,"<Br>");
    var label3 = '<div align=left>'+label2.substring(foo+1)+'</div>';
} else {
    var foo2 = label.indexOf("|");    // first occurrence of |
    var label1 = label.substring(foo2);
    //alert(label1);
    var label2 = label1.replace(/\|/g,"<Br>");
    var label3 = '<div align=left>'+label2.substring(foo+1)+'</div>';
}
marker[i].openInfoWindowHtml(label3);
marker[i].visited = true;
GEvent.trigger(marker[i],"mouseout");
});
GEvent.addListener(marker[i],'mouseover',function(){
//marker[i].setImage(markerImage[3]);
marker[i].setImage(nIcon.imageOver);
});
GEvent.addListener(marker[i],'mouseout',function(){
if(marker[i].visited){
//marker[i].setImage(markerImage[4]);
marker[i].setImage(nIcon.imageOut);
}else{
//marker[i].setImage(markerImage[0]);
marker[i].setImage(nIcon.imageOut);
}
});

}
    function setDirections(fromAddress, toAddress, locale) {
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
    }
    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
	//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
	//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	   else alert("An unknown error occurred.");
	}
	function onGDirectionsLoad(){
      // Use this function to access information about the latest load()
      // results.
      // e.g.
      // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  // and yada yada yada...
	}
function checkrequired(which) {
var pass=true;
 var startAddr = document.dirForm.from.value.replace(" ","+");
 var endAddr = document.dirForm.to.value.replace(" ","+");
 var googleURL = "http://maps.google.com/maps?f=d&amp;hl=en&geocode=&saddr="+startAddr+"&daddr="+endAddr+"&ie=UTF8&z=8&pw=2";
 MM_openBrWindow(googleURL,'TTDirections','scrollbars=yes,width=800,height=900');
 return false;
}
function MM_openBrWindow(theURL,winName,features) { 
window.open(theURL,winName,features);
}

    //]]>