function loadThis() {
	var URL='hotspots/searchbound.php';
	var Zoom = init_zoom;
	var map;
	var donotquery=false;
	
  if (new GBrowserIsCompatible()) {

		map = new GMap2(document.getElementById('map'));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GOverviewMapControl(new GSize(200,150)));
		map.setCenter(new GLatLng(init_lat,init_lng), Zoom);
		
		GEvent.addListener(map, "click", function(marker,point) {
			if(marker!==null){
				if(document.getElementById('currZoom').value<11){
					var newpoint=marker.getPoint();
					donotquery=true;
					map.setCenter(newpoint);
					
					if(map.getZoom() >= 0 && map.getZoom() < 3)
						map.setZoom(4);
					else if(map.getZoom() >= 3 && map.getZoom() <= 6)
						map.setZoom(7);
					else if(map.getZoom() >= 7 && map.getZoom() <= 10)
						map.setZoom(11);
					else 
					 map.zoomIn();
				}
			}
		});
		  
		GEvent.addListener(map, "moveend", function() {
											
			var om = new OverlayMessage(document.getElementById('map')); 
			bbox=map.getBounds();
			
			var latmin=bbox.getSouthWest().lat();
			var latmax=bbox.getNorthEast().lat();
			var lngmin=bbox.getSouthWest().lng();
			var lngmax=bbox.getNorthEast().lng();
			
			var prevlatmin=document.getElementById('latmin').value;
			var prevlatmax=document.getElementById('latmax').value;
			var prevlngmin=document.getElementById('lngmin').value;
			var prevlngmax=document.getElementById('lngmax').value;
		
			var doAgain=false;
			
			if(latmin<prevlatmin){
				doAgain=true;
				setBound(map);
			}
			if(latmax>prevlatmax){
				doAgain=true;
				setBound(map);
			}
			if(lngmin<prevlngmin){
				doAgain=true;
				setBound(map);
			}
			if(lngmax>prevlngmax){
				doAgain=true;
				setBound(map);
			}
			if(document.getElementById('currZoom').value!=map.getZoom()){
				doAgain=true;
				setBound(map);
			}
			
			if(donotquery){
				doAgain=false;
			}
				
			if(doAgain){				
				map.clearOverlays();
				om.Set("loading...");
				latmin=document.getElementById('latmin').value;
				latmax=document.getElementById('latmax').value;
				
				lngmin=document.getElementById('lngmin').value;
				lngmax=document.getElementById('lngmax').value;
				var searchBoundURL=URL+"?latmin="+latmin+"&latmax="+latmax+"&lngmin="+lngmin+"&lngmax="+lngmax+"&zoom="+map.getZoom();
				
				var baseIcon = new GIcon();
				baseIcon.iconSize = new GSize(13,15);
				baseIcon.iconAnchor = new GPoint(9,15);
				baseIcon.infoWindowAnchor = new GPoint(9, 2);

				var touristBaseIcon = new GIcon();
				touristBaseIcon.iconSize = new GSize(20,16);
				touristBaseIcon.iconAnchor = new GPoint(9, 16);
				touristBaseIcon.infoWindowAnchor = new GPoint(9, 2);
		
				var hotspotBaseIcon = new GIcon();
				hotspotBaseIcon.iconSize = new GSize(20,21);
				hotspotBaseIcon.iconAnchor = new GPoint(9, 21);
				hotspotBaseIcon.infoWindowAnchor = new GPoint(9, 2);
		
				var fishingBaseIcon = new GIcon();
				fishingBaseIcon.iconSize = new GSize(15,32);
				fishingBaseIcon.iconAnchor = new GPoint(9,32);
				fishingBaseIcon.infoWindowAnchor = new GPoint(9, 2);
		
				var beachBaseIcon = new GIcon();
				beachBaseIcon.iconSize = new GSize(22,23);
				beachBaseIcon.iconAnchor = new GPoint(9,23);
				beachBaseIcon.infoWindowAnchor = new GPoint(9, 2);
		
				var diningBaseIcon = new GIcon();
				diningBaseIcon.iconSize = new GSize(18,24);
				diningBaseIcon.iconAnchor = new GPoint(9,24);
				diningBaseIcon.infoWindowAnchor = new GPoint(9, 2);
		
				var tournamentBaseIcon = new GIcon();
				tournamentBaseIcon.iconSize = new GSize(14,20);
				tournamentBaseIcon.iconAnchor = new GPoint(9,20);
				tournamentBaseIcon.infoWindowAnchor = new GPoint(9, 2);
		
				var divingBaseIcon = new GIcon();
				divingBaseIcon.iconSize = new GSize(22,27);
				divingBaseIcon.iconAnchor = new GPoint(9,27);
				divingBaseIcon.infoWindowAnchor = new GPoint(9, 2);
		
		
				var listingBaseIcon = new GIcon();
				listingBaseIcon.iconSize = new GSize(19,19);
				listingBaseIcon.iconAnchor = new GPoint(9,19);
				listingBaseIcon.infoWindowAnchor = new GPoint(9, 2);

				
				GDownloadUrl(searchBoundURL, function(data) {
					
					var xml = GXml.parse(data);
					
					if(xml.documentElement){//check to see if data was present in xml document
						var markers = xml.documentElement.getElementsByTagName("point");
						var icon = new GIcon(baseIcon);
						for (var i = 0; i < markers.length; i++) {
							var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));
							var _info 	= markers[i].getAttribute("info");
							var _type 	= markers[i].getAttribute("type");
							var _title 	= markers[i].getAttribute("title");
							var _icon 	= markers[i].getAttribute("icon");
							var _ID 	= parseInt(markers[i].getAttribute("id"));
							if(_ID.length <= 0){
								_ID = 0;
							}
							
							if(_icon=="default"){
								// icon.image="/map/images/marker_20_red_dot.png";
								newmarker = new PdMarker(point);
							}
							else
							{
								if(_type == 'listing' || _type == 'featured')
								{
									var icon = new GIcon(listingBaseIcon,_icon);
								}
								else if(_type == 'counter')
								{
									var icon = new GIcon(baseIcon,_icon);
								}
								else if(_type == 'fishing')
								{
									var icon = new GIcon(fishingBaseIcon,_icon);
								}
								else if(_type == 'beaches')
								{
									var icon = new GIcon(beachBaseIcon,_icon);
								}
								else if(_type == 'diving')
								{
									var icon = new GIcon(divingBaseIcon,_icon);
								}
								else if(_type == 'tournament')
								{
									var icon = new GIcon(tournamentBaseIcon,_icon);
								}
								else if(_type == 'tourist_attractions')
								{
									var icon = new GIcon(touristBaseIcon,_icon);
								}
								else if(_type == 'dining')
								{
									var icon = new GIcon(diningBaseIcon,_icon);
								}
								else if(_type == 'bars')
								{
									var icon = new GIcon(beachBaseIcon,_icon);
								}
								else
								{
									var icon = new GIcon(baseIcon,_icon);
								}
								newmarker = new PdMarker(point,icon);
							}
							newmarker.setTooltip(_title);
							var html = _ID;
							if(_type == 'featured' || _type == 'listing')
							{
								html  = _ID + ':1';
							}
							else
							{
								html = _ID + ':2';
							}
							if(_type != 'country' && _type != 'state' && _type != 'city')
							{
								newmarker.setDetailWinHTML(html);
							}
							map.addOverlay(newmarker);
						}	
					}
					om.Clear(); // Clear the loading message
				});		
			}//end doagain
			donotquery=false;
		});
		map.setCenter(new GLatLng(init_lat,init_lng), Zoom);
   }
}

function setBound(map){
	var bbox=map.getBounds();
		
	var minlat=-90.0;
	var maxlat=90.0;
	
	var minlng=-180.0;
	var maxlng=180.0;

	
	
	//get current viewport coordinates	
	var latmin=bbox.getSouthWest().lat();
	var latmax=bbox.getNorthEast().lat();
	var lngmin=bbox.getSouthWest().lng();
	var lngmax=bbox.getNorthEast().lng();
	
	//get half of the 2 points
	
	var half_lng=0;
	var wrapFlag=false;
	if(lngmin>=0 && lngmax>=0 && lngmin>lngmax ){
		wrapFlag=true;
	}
	else if(lngmin>=0 && lngmax<=0){
		half_lng=((180+lngmax)+lngmin)/2;
	}
	else if(lngmin<=0 && lngmax>=0){
		half_lng=(lngmax-lngmin)/2;
	}
	else if(lngmin<=0 && lngmax<=0){
		half_lng=((lngmin*-1)+lngmax)/2;
	}
	else if(lngmin>=0 && lngmax>=0){
		half_lng=(lngmax-lngmin)/2;
	}
	
	if(latmin>=0 && latmax<=0){
		half_lat=((90+latmax)+latmin)/2;
	}
	else if(latmin<=0 && latmax>=0){
		half_lat=(latmax-latmin)/2;
	}
	else if(latmin<=0 && latmax<=0){
		half_lat=((latmin*-1)+latmax)/2;
	}
	else if(latmin>=0 && latmax>=0){
		half_lat=(latmax-latmin)/2;
	}

	
//	var half_lat=((latmax-latmin)/2);
//	var half_lng=((lngmax-lngmin)/2);
	
	//add half as the padding
	var padd_latmin=latmin-half_lat;
	var padd_latmax=latmax+half_lat;
	var padd_lngmin=lngmin-half_lng;
	var padd_lngmax=lngmax+half_lng;
	
	
	if(wrapFlag==true){
	padd_lngmin=minlng;
	padd_lngmax=maxlng;	
	}
	else{
		if(padd_lngmin<minlng){
			padd_lngmin=minlng;
		}
		if(padd_lngmax>maxlng){
			padd_lngmax=maxlng;
		}
	}
	
	if(padd_latmin<minlat){
		padd_latmin=minlat;
	}
	if(padd_latmax>maxlat){
		padd_latmax=maxlat;
	}

	
	document.getElementById('latmin').value=padd_latmin;
	document.getElementById('latmax').value=padd_latmax;
	document.getElementById('lngmin').value=padd_lngmin;
	document.getElementById('lngmax').value=padd_lngmax;
	
	document.getElementById('currZoom').value=map.getZoom();	
}



/***************OVERLAY MESSAGE FUNCTIONS********************/

OverlayMessage = function ( container ){
    // Get the parent.
    var parent = container.parentNode;

    // Make the wrapper div.
    var wrapper = document.createElement('div');
    wrapper.style.cssText = container.style.cssText;
    parent.insertBefore( wrapper, container );

    // Move the container into the wrapper.
    parent.removeChild( container );
    wrapper.appendChild( container );
    container.style.cssText = 'position: relative; width: 100%; height: 100%;';

    // Add the overlay div.
    this.overlay = document.createElement( 'div' );
    wrapper.appendChild(this.overlay);
    this.overlay.style.cssText = 'display:none;';
};

OverlayMessage.prototype.Set = function ( message ){
	this.overlay.innerHTML = message;
	this.overlay.className = 'messageOverlay';
	this.overlay.style.cssText = 'display:block;';
};

OverlayMessage.prototype.Clear = function (){
	this.overlay.className = 'messageOverlay_hidden';
	this.overlay.style.cssText = 'display:none;';
};

/*******pdmarker PACKED ******/
/*
 PdMarker

 Purpose: extends Google Map API GMap and GMarker (hover effects, image swapping, moving)
 Details: http://www.pixeldevelopment.com/pdmarker.asp
 Updated: [see getPdMarkerRevisionInfo]
 Author:  Peter Jones
 Notes:   Relies on undocumented features of the Google Map API which may change.
	    Based on my own PJToolTip and ideas from GxMarker, TLabel and the Google Maps API forum.

 Contact http://www.pixeldevelopment.com for your custom Google Map needs
*/


function handleDetailInfo(svalue,uni)
{
	xajax_getDetailedInfo(svalue,uni);
	svalue="<center><img src='../images/ajax_activity2.gif'></center>";
	return svalue;
}


function latLongToPixel(map,coord,zoom) {
    return map.fromLatLngToDivPixel(coord);
}


var pdMarkerExtList = [];

function PdMarkerAddToExtList(marker) {
	pdMarkerExtList.push(marker);
}

function PdMarkerRemoveFromExtList(id) {
	for (var i=0; i<pdMarkerExtList.length; i++){
		if (pdMarkerExtList[i].internalId == id){
			pdMarkerExtList.splice(i,1);
		}
	}
}

function PdMarkerFindInExtList(id) {
	for (var i=0; i<pdMarkerExtList.length; i++){
		if (pdMarkerExtList[i].internalId == id){
			return pdMarkerExtList[i];
		}
	}
}

function PdMarkerClose(id) {
	for (var i=0; i<pdMarkerExtList.length; i++){
		if (pdMarkerExtList[i].internalId == id)
			{
				pdMarkerExtList[i].closeDetailWin();
				pdMarkerExtList.splice(i,1);
			}
	}
}

function PdMarkerBlinkOnOff(id) {
	var marker = PdMarkerFindInExtList(id);
	if (marker)
	{
		if (!marker.blinking){ return;}
		marker.blinkOn = !marker.blinkOn;
		marker.display(marker.blinkOn);
		setTimeout("PdMarkerBlinkOnOff(" + marker.getId() + ");", marker.blinkSpeed);
	}
}

// GMap extension for walking through PdMarker list
// Note: some overlays are not markers, some may not be PdMarkers

function isPdMarker(a) {
	if (a.isMarker){
		return true;
	}
	return false;
}

function getPdMarkerCount(a) {
	if (a.pdMarkers){
		return a.pdMarkers.length;
	}
	return 0;
}

GMap2.prototype.getMarkerById = function(id) {
	var count = getPdMarkerCount(this);
	for (var i = 0; i < count; i++){
		if (isPdMarker(this.pdMarkers[i])){
			if (this.pdMarkers[i].internalId == id)
			{
				this.cursor = i;
				return this.pdMarkers[i];
			}
		}
	}
	return null;
};

GMap2.prototype.getFirstMarker = function() {
	var count = getPdMarkerCount(this);
	for (var i = 0; i < count; i++){
		if (isPdMarker(this.pdMarkers[i]))
		{
			this.cursor = i;
			return this.pdMarkers[i];
		}
	}
	return null;
};

GMap2.prototype.getNextMarker = function() {
	var count = getPdMarkerCount(this);
	if (count > 0){
		if (this.cursor >= 0){
			for (var i = this.cursor+1; i < count; i++){
				if (isPdMarker(this.pdMarkers[i]))
				{
					this.cursor = i;
					return this.pdMarkers[i];
				}
			}
		}
	}
	return null;
};

GMap2.prototype.getNthMarker = function(nTh) {
	var count = getPdMarkerCount(this);
	for (var i = 0; i < count; i++){
		if (isPdMarker(this.pdMarkers[i]))
		{
			nTh--;
			if (nTh == 0)
			{
				this.cursor = i;
				return this.pdMarkers[i];
			}
		}
	}
	return null;
};

GMap2.prototype.getMarkerCount = function() {
	return getPdMarkerCount(this);
};

GMap2.prototype.boxMap = function(center, span) {
	var spec = this.spec;
	var zoom = spec.getLowestZoomLevel(center, span, this.viewSize);
	this.centerAndZoom(new GPoint(center.x, center.y), zoom);
};

GMap2.prototype.zoomToMarkers = function(slopPercentage, heightOffsetPct) {
	var count = 0;
	var thePoint, x, y, minX, maxX, minY, maxY, span;
	var marker = this.getFirstMarker();
	while (marker != null)
	{
		if (!marker.isHidden())
		{
			thePoint = marker.getPoint();
			// x = thePoint.x; y = thePoint.y;
			x = thePoint.lat(); 
			y = thePoint.lng();
			if (count == 0)
			{
				minX = x; 
				maxX = x;
				minY = y; 
				maxY = y;
			}
			else
			{
				if (x < minX){ minX = x;}
				if (x > maxX){ maxX = x;}
				if (y < minY){ minY = y;}
				if (y > maxY){ maxY = y;}
			}
			count++;
		}
		marker = this.getNextMarker();
	}
	if (count == 1){
		this.setCenter(new GLatLng(x,y), this.getZoom());
	}
	else if (count > 1)
	{
		var center = new GLatLng((minX + maxX) / 2, (minY + maxY) / 2);
		span = new GSize(Math.abs(maxX - minX), Math.abs(maxY - minY));
		slopWid = 0;
		slopHgt = 0;
		if (typeof slopPercentage != "undefined")
		{
			slopWid = span.width * slopPercentage / 200;
			slopHgt = span.height * slopPercentage / 200;
			span.width  *= 1 + slopPercentage / 100;
			span.height *= 1 + slopPercentage / 100;
		}
		deltaHgt = 0;
		if (typeof heightOffsetPct != "undefined")
		{
			deltaHgt = span.height * heightOffsetPct / 100;
			center = new GLatLng(center.lat() + deltaHgt, center.lng());
		}
		// needs slop
		var bounds = new GLatLngBounds(new GLatLng(minX-slopHgt, minY-slopWid), new GLatLng(maxX+slopHgt, maxY+slopWid)); // sw, ne
		var zoom = this.getBoundsZoomLevel(bounds);
		this.setCenter(center, zoom);
	}
};



function PdMarkerNamespace() {

var userAgent = navigator.userAgent.toLowerCase();
var n4=(document.layers);
var n6=(document.getElementById&&!document.all);
var ie=(document.all);
var o6=(userAgent.indexOf("opera") != -1);
var safari=(userAgent.indexOf("safari") != -1);
var msie  = (userAgent.indexOf("msie") != -1) && (userAgent.indexOf("opera") == -1);
var msiePre7 = false;
if (msie){
	msiePre7 = userAgent.substr(userAgent.indexOf("msie")+5,2) < 7;   
}
var nextMarkerId = 10;
var permitLeft = true;

var icon = new GIcon();
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(20, 34);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(9, 34);
icon.infoWindowAnchor = new GPoint(9, 2);
icon.infoShadowAnchor = new GPoint(18, 25);
icon.image = "http://www.google.com/mapfiles/marker.png";

// Globals - careful of multiple maps
function PdMarker(a, b, tooltip) {
	this.inheritFrom = GMarker;
	if (typeof b == "undefined"){
		b = icon;
	}
	this.inheritFrom(a,b);
	if (typeof tooltip != "undefined"){
		this.pendingTitle = tooltip;
	}
	else{
		this.pendingTitle = "";
	}
	if (typeof b != "undefined"){
		this.oldImagePath = b.image;
	}
	else{
		this.oldImagePath = "http://www.google.com/mapfiles/marker.png";
	}
	this.internalId = nextMarkerId;
	nextMarkerId += 1;
	this.zIndexSaved = false;
	this.pendingCursor = "";
	this.percentOpacity = 70;
	this.mouseOutEnabled = true;
	this.setImageOn = true;
	this.hidingEnabled = true;
	this.showDetailOnClick = true;
	this.detailOpen = false;
	this.userData = "";
	this.displayed = true;
}

// PdMarker.prototype = new GMarker;
PdMarker.prototype = new GMarker(new GLatLng(1, 1));


function addMarkerToMapList(map,marker) {
	try {
		if (map.pdMarkers.length){
		}
	}
	catch(e) {
		map.pdMarkers = new Array();
	}
	// add to list
	map.pdMarkers.push(marker);
}

function removeMarkerFromMapList(map,marker) {
	var id = marker.internalId;
	for (var i=0; i<map.pdMarkers.length; i++){
		if (map.pdMarkers[i].internalId == id)
		{
			map.pdMarkers.splice(i,1);
			return;
		}
	}
};

PdMarker.prototype.initialize = function(a) {
	if (typeof a == "GMap")
	{
		GLog.write("PdMarker requires GMap2");
		return;
	}
	addMarkerToMapList(a,this);
	try
	{
		GMarker.prototype.initialize.call(this, a);
		this.isMarker = true;
		if (this.pendingTitle.length > 0){
			this.setTitle(this.pendingTitle);
		}
		if (this.pendingCursor.length > 0){
			this.setCursor(this.pendingCursor);
		}

		this.map = a;
		

		GEvent.bindDom(this, "mouseover", this, this.onMouseOver);
		GEvent.bindDom(this, "mouseout",  this, this.onMouseOut);
		GEvent.bindDom(this, "click",  this, this.onClick);
		GEvent.bind(this.map, "zoomend", this, this.reZoom);
	}
	catch(e) {
		alert("PdMarker initialize error: " + e);
	}
};

PdMarker.prototype.allowLeftTooltips = function(a){
	permitLeft = a;
};

PdMarker.prototype.reZoom = function(){
	var didSet = false;
	if (this.tooltipObject){
		if (this.tooltipObject.style.display == "block")
		{
			setTTPosition(this);
			didSet = true;
		}
	}
	if (this.detailObject)
	{
		if (!didSet){
			setTTPosition(this);
		}
		//setDetailPosition(this);
	}
};

PdMarker.prototype.setId = function(id) {
	this.internalId = id;
};

PdMarker.prototype.getId = function() {
	return this.internalId;
};

PdMarker.prototype.setName = function(a) {
	this.name = a;
};

PdMarker.prototype.getName = function() {
	if (this.name){
		return this.name;
	}
	else{
		return null;
	}
};

PdMarker.prototype.setUserData = function(a) {
	this.userData = a;
};

PdMarker.prototype.getUserData = function() {
	if (this.userData)
	{
		return this.userData;
	}
	else{
		return "";
	}
};

PdMarker.prototype.setUserData2 = function(a) {
	this.userData2 = a;
};

PdMarker.prototype.getUserData2 = function() {
	if (this.userData2){
		return this.userData2;
	}
	else{
		return "";
	}
};

PdMarker.prototype.setImageEnabled = function(a) {
	this.setImageOn = a;
};

var PdMIN = "";
var PdMIA = "";

function PdCompPdMIN(marker) {
	if (PdMIN.length == 0){
		for (var i in marker){
			if (eval("typeof marker." + i) == "object"){
				try {
					if (eval("typeof marker." + i + "[0].src") != "undefined")
					{
						PdMIA = "this." + i;
						PdMIN = PdMIA + "[0]";
					}
				}
				catch (e) {}
			}
		}
	}
}

PdMarker.prototype.setImageOld = function(a) {
	// 		GMarker.prototype.initialize.call(this, a);
	var msFilter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + a + '")';
	if (this.mouseOutEnabled && this.setImageOn)
	{
		PdCompPdMIN(this);
		try {
			if (this.oldImagePath.length == 0){
				eval("this.oldImagePath = " + PdMIN + ".src");
			}
			if (msie && msiePre7){
				eval(PdMIN + ".style.filter = msFilter");
			}
			else{
				eval(PdMIN + ".src = a");
			}
		}
		catch (e) {}
	}
};

PdMarker.prototype.setImage = function(a) {
	if (this.mouseOutEnabled && this.setImageOn){
		GMarker.prototype.setImage.call(this, a);
	}
};

PdMarker.prototype.restoreImage = function() {
	if (this.mouseOutEnabled && this.setImageOn && this.oldImagePath.length > 0){
		this.setImage(this.oldImagePath);
	}
};

PdMarker.prototype.display = function(a) {
	if (a){
		this.show();
	}
	else{
		this.hide();
	}
};

PdMarker.prototype.blink = function(a,b) {
	if (a)
	{
		this.blinkOn = true;
		this.blinkSpeed = b;
		if (!this.blinking)
		{
			this.blinking = a;
			PdMarkerAddToExtList(this);
			PdMarkerBlinkOnOff(this.getId());
		}
	}
	else
	{
		this.blinking = a;
		this.display(true);
		PdMarkerRemoveFromExtList(this);
	}
};

PdMarker.prototype.setIcon = function(a) {
	this.remove();
	this.icon = a;
	this.initialize(this.map);
	this.redraw(true); 
};

PdMarker.prototype.setMarkerZIndex = function(a) {
	if (!this.zIndexSaved)
	{
		this.zIndexSaved = true;
		this.oldZIndex = eval(PdMIN + ".style.zIndex");
	}
	eval(PdMIN + ".style.zIndex = a");
	this.redraw(true);
};

PdMarker.prototype.topMarkerZIndex = function() {
	this.setMarkerZIndex (600000);
};

PdMarker.prototype.restoreMarkerZIndex = function() {
	if (this.zIndexSaved)
	{
		this.zIndexSaved = false;
		eval(PdMIN + ".style.zIndex = this.oldZIndex");
		this.redraw(true);
	}
};

PdMarker.prototype.onInfoWindowOpen = function() {
	this.hideTooltip();
	GMarker.prototype.onInfoWindowOpen.call(this);
};

PdMarker.prototype.setHoverImage = function(a) {
	this.hoverImage = a;
};

var inMouseOver = false;

PdMarker.prototype.onMouseOver = function() {
	if (inMouseOver){
		return;
	}
	inMouseOver = true;
	if (this.hoverImage){
		this.setImage(this.hoverImage);
	}
	if (!this.detailOpen){
		this.showTooltip();
	}
	inMouseOver = false;
};

PdMarker.prototype.onMouseOut = function() {
	if (this.hoverImage){
		this.restoreImage();
	}
	if (!this.detailOpen){
		if (this.mouseOutEnabled){
			this.hideTooltip();
		}
	}
};

PdMarker.prototype.setMouseOutEnabled = function(a) {
	this.mouseOutEnabled = a;
};

PdMarker.prototype.getMouseOutEnabled = function() {
	return this.mouseOutEnabled;
};

PdMarker.prototype.setTooltipHiding = function(a) {
	this.hidingEnabled = a;
};

PdMarker.prototype.getTooltipHiding = function() {
	return this.hidingEnabled;
};

PdMarker.prototype.setTitle = function(a) {
	this.tooltipText = "";
	PdCompPdMIN(this);
	try {
		eval(PdMIN + ".title = a");
	}
	catch (e) {
		this.pendingTitle = a;
	}
};

PdMarker.prototype.setCursor = function(a) {
	PdCompPdMIN(this);
	try {
		eval(PdMIN + ".style.cursor = a");
	}
	catch (e) {
		this.pendingCursor = a;
	}
};

PdMarker.prototype.setTooltipClass = function(a) {
	this.pendingClassName = a;
	if (this.tooltipObject)
	{
		var showing = (this.tooltipObject.style.display != "none");
		this.deleteObjects();
		if (this.tooltipRaw){
			this.setTooltipNoResize(this.tooltipRaw);
		}
		if (showing){
			this.showTooltip();
		}

	}
	else{
		if (this.tooltipRaw){
			this.setTooltipNoResize(this.tooltipRaw);
		}
	}
};

PdMarker.prototype.resetTooltipClass = function() {
	this.setTooltipClass("markerTooltip");
};

PdMarker.prototype.getTooltip = function() {
	try {
		return this.tooltipRaw;
	}
	catch (e)
	{
		return "";
	}
};

PdMarker.prototype.setTooltipNoResize = function(a) {
	this.setTitle("");
	var ttClass = "markerTooltip";
	if (this.pendingClassName){
		ttClass = this.pendingClassName;
	}
	this.tooltipRaw = a;
	this.tooltipText = "<div class='" + ttClass + "'>" + a + "</div>";
	if (this.tooltipObject){
		this.tooltipObject.innerHTML = this.tooltipText;
	}
};

PdMarker.prototype.setTooltip = function(a) {
	this.setTooltipNoResize(a);
	this.deleteObjects();
};

PdMarker.prototype.showTooltip = function() {
	if (this.tooltipText)
	{
		if (!this.tooltipObject){
			initTooltip(this);
		}
		setTTPosition(this);
		this.tooltipObject.style.display = "block";
	}
};

PdMarker.prototype.hideTooltip = function() {
	if (this.tooltipObject){
		if (this.hidingEnabled){
			this.tooltipObject.style.display = "none";
		}
	}
};

PdMarker.prototype.onClick = function(a) {
	if (this.showDetailOnClick && this.detailWinHTML){
		this.showDetailWin();
	}
};

PdMarker.prototype.setShowDetailOnClick = function(a) {
	this.showDetailOnClick = a;
};

PdMarker.prototype.setDetailWinHTML = function(a) {
	this.detailWinHTML = a;
};

PdMarker.prototype.setDetailWinClass = function(a) {
	this.pendingDetailClassName = a;
};

PdMarker.prototype.resetDetailWinClass = function() {
	this.setDetailWinClass("markerDetail");
};



PdMarker.prototype.showDetailWin = function() {
	if (this.detailOpen)
	{
		this.closeDetailWin();
		return;
	}
	this.hideTooltip();
	this.setMouseOutEnabled(false);

	var winClass = "markerDetail";
	if (this.pendingWinClassName){
		winClass = this.pendingWinClassName;
	}
	var uni = new Date().getTime();
	var theInfo=handleDetailInfo(this.detailWinHTML,uni);
	var html = "<div class='" + winClass + "'>";
	html +="<div style=\"float:right; width:14px\"><a class='markerDetailClose' href='javascript:PdMarkerClose(" + this.internalId + ")'><img src='http://www.google.com/mapfiles/close.gif' width='14' height='13' border='0'><\/a></div>";
	html +="<div id='detailedInfoBox_"+uni+"' style=\"width:350px;\">" + theInfo + "</div>";
	html +="<div class=\"clearer\"></div></div>";

	this.detailOpen = true;
	if (!this.tooltipText)
	{
		this.ttWidth = 150;
		this.ttHeight = 30;
		setTTPosition(this); // compute ttTop, ttLeft
	}
	initDetailWin(this, this.ttTop, this.ttLeft, html);
	PdMarkerAddToExtList(this);
};


PdMarker.prototype.closeDetailWin = function() {
	this.detailOpen = false;
	if (this.detailObject)
	{
		this.setMouseOutEnabled(true);
		this.onMouseOut();
		// GEvent.trigger(this, "mouseout");
	      this.map.getPane(G_MAP_FLOAT_PANE).removeChild(this.detailObject);
		this.detailObject = null;
	}
};

PdMarker.prototype.deleteObjects = function() {
	if (this.tooltipObject)
	{
	      this.map.getPane(G_MAP_FLOAT_PANE).removeChild(this.tooltipObject);
		this.tooltipObject = null;
	}
	if (this.detailObject)
	{
		this.map.getPane(G_MAP_FLOAT_PANE).removeChild(this.detailObject);
		this.detailObject = null;
	}
};

PdMarker.prototype.remove = function(a) {
	removeMarkerFromMapList(this.map, this);
	PdMarkerRemoveFromExtList(this.getId());
	GMarker.prototype.remove.call(this);
	this.deleteObjects();
};

PdMarker.prototype.setOpacity = function(b) {
	if (b < 0){
		b=0;
	}
	if (b >= 100){
		b=100;
	}
	var c = b / 100;
	this.percentOpacity = b;
	var d = document.getElementById(this.objId);
	if (d)
	{
		if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
		if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
		if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
		if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
	}
};

PdMarker.prototype.setOpacityNew = function(b) {
	setObjOpacity(this.objId);
	this.percentOpacity = b;
};

// ***** Private routines *****

function setObjOpacity(objId, b) {
	if (b < 0){
		b=0;
	}
	if (b >= 100){
		b=100;
	}
	var c = b / 100;
	var d = document.getElementById(objId);
	if (d)
	{
		if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+b+')';}
		if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
		if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
		if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
	}
}

function idToElemId(id) {
	return "ttobj" + id;
}

function initTooltip(theObj) {
	theObj.objId = idToElemId(theObj.internalId);
	theObj.anchorLatLng = theObj.point;

	var b = document.createElement('span');
	theObj.tooltipObject = b;
	b.setAttribute('id',theObj.objId);
	b.innerHTML = theObj.tooltipText;

	// append to body for size calculations
	var c = document.body;
	var d = document.getElementById("pdmarkerwork");
	if (d){
		c = d;
	}
	c.appendChild(b);
	b.style.position = "absolute";
	b.style.bottom = "5px";
	b.style.left = "5px";
	b.style.zIndex = 1;
	if (theObj.percentOpacity){
		theObj.setOpacity(theObj.percentOpacity);
	}
	var tempObj = document.getElementById(theObj.objId);
	theObj.ttWidth  = tempObj.offsetWidth;
	theObj.ttHeight = tempObj.offsetHeight;
	c.removeChild(b);

	b.style.zIndex = 600000;
	b.style.bottom = "";
	b.style.left = "";
	theObj.map.getPane(G_MAP_FLOAT_PANE).appendChild(b);
}

function initDetailWin(theObj, top, left, html) {
	theObj.detailId = "detail" + theObj.internalId;
	var b = document.createElement('span');
	theObj.detailObject = b;
	b.setAttribute('id',theObj.detailId);
	b.innerHTML = html;
	b.style.display = "block";
	b.style.position = "absolute";
	b.style.top  = top + "px";
	if (theObj.rightSide){
		b.style.left = left + "px";
	}
	else{
		b.style.right = -left + "px";
	}
	b.style.zIndex = 600001;
	theObj.map.getPane(G_MAP_FLOAT_PANE).appendChild(b);
}

function setTTPosition(theObj) {
	var gap = 5;
	var map = theObj.map;
	var pt  = theObj.getPoint();
	var ttPos = latLongToPixel(map, pt, map.getZoom());
	var theIcon = theObj.getIcon();
	
	ttPos.y -= Math.floor(theIcon.iconAnchor.y/2);

	var rightSide = true;
	var bounds = map.getBounds();
	var boundsSpan	= bounds.toSpan();
	var longSpan = boundsSpan.lng();
	var mapWidth = map.getSize().width;

	var tooltipWidthInDeg = (theObj.ttWidth + theIcon.iconSize.width + 6) / mapWidth * longSpan;
	if (pt.lng() + tooltipWidthInDeg > bounds.getNorthEast().lng() && permitLeft){
		rightSide = false;
	}
	ttPos.y -= Math.floor(theObj.ttHeight/2);
	delta = (theIcon.iconSize.width - theIcon.iconAnchor.x) + gap;
	if (rightSide){
		ttPos.x += delta;
	}
	else{
		ttPos.x -= delta;
	}
	theObj.rightSide = rightSide;
	theObj.ttLeft = ttPos.x;
	theObj.ttTop  = ttPos.y;
	if (theObj.tooltipObject)
	{
		if (rightSide) {
			theObj.tooltipObject.style.left = ttPos.x + "px";
			theObj.tooltipObject.style.right = null;
		}
		else {
			theObj.tooltipObject.style.left = null;
			theObj.tooltipObject.style.right = -ttPos.x + "px";
		}
		theObj.tooltipObject.style.top  = ttPos.y + "px";
	}
}

function makeInterface(a) {
	var b = a || window;
	b.PdMarker = PdMarker;
}

makeInterface();

}
PdMarkerNamespace();
