function WmgMap(map_canvas) {	var _this = this;	setTimeout(function() { _this.init(map_canvas); }, 500);}WmgMap.EXTRA_PATH = "/";WmgMap.MOUSEOVER_CLASSNAME = "gm_tooltip_mouseover";WmgMap.prototype.init = function(map_canvas) {	this.canvas = document.getElementById(map_canvas);	this.data = document.getElementById(this.canvas.getAttribute("contentDivId"));		this.map = new GMap2(this.canvas);	this.geocoder = new GClientGeocoder();	this.loadSettings();	this.initialize_map();}/** * Performs client-side search for address. If a callback is passed in, then * it gets called whenever a disambiguation marker is selected. */WmgMap.prototype.findLocation = function(address, clickcallback, resultscallback) {	var _this = this;	this.geocoder.getLocations(address, function (response) {		callback.call(_this, response);	});		function callback(response) {		this.map.clearOverlays();		if (!response || response.Status.code != 200) {			alert("Sorry, we were unable to find that address");		} else {			// we only have 10 numbered markers and			// also more than 10 results is probably not helpful			var oldNumberFlag = this.showNumberMarker;			this.showNumberMarker = true;			var startIndex = Math.min(response.Placemark.length-1, 10);			for (var i=startIndex; i>=0; i--) {							var place = response.Placemark[i];				var latitude = place.Point.coordinates[1];				var longitude = place.Point.coordinates[0];				//alert("latitude = " + latitude + ", longitude = " + longitude);				//alert("place.AddressDetails.Accuracy = " + place.AddressDetails.Accuracy);				var point = new GLatLng(latitude, longitude);				this.map.setCenter(point, place.AddressDetails.Accuracy+2);				var markerContent = 'Result #' + (i+1)					+ '<br/>' + place.address					+ '<br/> Country Code: ' + place.AddressDetails.Country.CountryNameCode					+ '<br/>Accuracy: ' + place.AddressDetails.Accuracy;				markerContent = place.address;				var item = {					latlng: point,					index: i,					node: null,					movertext: markerContent				};				var marker = this.addMarker(this.map, item);				if (clickcallback)					closureFun(marker, clickcallback, place.address);			}			this.showNumberMarker = oldNumberFlag;						if (resultscallback)				resultscallback(response);		}				function closureFun(marker, callback, address) {			GEvent.addListener(marker,'click',function() {				callback(address);			});		}	};};WmgMap.prototype.loadSettings = function() {	this.mapMode=this.canvas.getAttribute("mapMode");	this.mapZoom=parseInt(this.canvas.getAttribute("mapZoom"));	this.showStreetView=this.canvas.getAttribute("showStreetView")=="true";	this.showTraffic=this.canvas.getAttribute("showTraffic")=="true";	this.showTerrain=this.canvas.getAttribute("showTerrain")=="true";	this.showNumberMarker=this.canvas.getAttribute("showNumberMarker")=="true";	this.showMapTypeControl=this.canvas.getAttribute("showMapTypeControl")=="true";	this.showSmallMapControl=this.canvas.getAttribute("showSmallMapControl")=="true";	this.showLargeMapControl=this.canvas.getAttribute("showLargeMapControl")=="true";	this.hideMapTypeHybrid=this.canvas.getAttribute("hideMapTypeHybrid")=="true";	this.hideMapTypeSatellite=this.canvas.getAttribute("hideMapTypeSatellite")=="true";	this.hideMapTypeNormal=this.canvas.getAttribute("hideMapTypeNormal")=="true";	this.showOverview=this.canvas.getAttribute("showOverview")=="true";	this.showInfo=this.canvas.getAttribute("showInfo")=="true";	this.showSearchPoint=this.canvas.getAttribute("showSearchPoint")=="true";};WmgMap.prototype.initialize_map = function() {	if (GBrowserIsCompatible()) {		var map = this.map;		var mapdata =  this.data;		var bounds = new GLatLngBounds();		map.setCenter(new GLatLng(37.090240, -95.712891), 4);		// set center of the map		var mapCenterLat = mapdata.getAttribute("mapCenterLat");		var mapCenterLng = mapdata.getAttribute("mapCenterLng");		if (mapCenterLat != "" && mapCenterLng != "") {			map.setCenter(new GLatLng(mapCenterLat, mapCenterLng), this.mapZoom);		}				// mark the search point		var searchLat = mapdata.getAttribute("searchLat");		var searchLng = mapdata.getAttribute("searchLng");		if (searchLat != "" && searchLng != "") {			if (this.showSearchPoint) {				var pt = new GLatLng(searchLat, searchLng);				bounds.extend(pt);				var marker = this.createMarker(pt, 0, true);				map.addOverlay(marker);			}		}				if (this.showSmallMapControl)			map.addControl(new GSmallMapControl());		if (this.showLargeMapControl)			map.addControl(new GLargeMapControl());		if (this.showMapTypeControl) {			if (this.showTerrain)				map.addMapType(G_PHYSICAL_MAP);			if (this.hideMapTypeHybrid)				map.removeMapType(G_HYBRID_MAP);			if (this.hideMapTypeSatellite)				map.removeMapType(G_SATELLITE_MAP);			if (this.hideMapTypeNormal)				map.removeMapType(G_NORMAL_MAP);						map.addControl(new GMapTypeControl());		}		if (this.mapMode == "satellite")			map.setMapType(G_SATELLITE_MAP);		if (this.mapMode == "hybrid")			map.setMapType(G_HYBRID_MAP);		if (this.mapMode == "terrain")			map.setMapType(G_PHYSICAL_MAP);		// else default to normal		if (this.showOverview)			map.addControl(new GOverviewMapControl());				var cn = mapdata.childNodes;		for (var i=0; i<cn.length; i++) {			var node = cn[i];			if (node.nodeType == 1) {				var item = {					latlng: new GLatLng(						node.getAttribute("lat"),						node.getAttribute("lng")					),					index: parseInt(node.getAttribute("ind")),					node: node,					url: node.getAttribute("url"),					movertext: node.getAttribute("movertext")				};				this.addMarker(map, item);				bounds.extend(item.latlng);			}		}		var zoom = map.getBoundsZoomLevel(bounds);		zoom--;		// alert('calc zoom to: ' + zoom);		map.setZoom(zoom);		map.setCenter(bounds.getCenter());	}};WmgMap.prototype.addMarker = function(map, item) {	var marker = this.createMarker(item.latlng, item.index, false);	map.addOverlay(marker);	marker.item = item;	if (!this.showInfo)		return;	if (item.movertext) {		var tooltip = new Tooltip(marker, item.movertext, 0);		tooltip.className = WmgMap.MOUSEOVER_CLASSNAME;		item.moverTooltip = tooltip;		map.addOverlay(tooltip);		GEvent.addListener(marker,'mouseover',function() {			if (!this.item.tooltip || !this.item.tooltip.isVisible()) {				map.closeInfoWindow();				this.item.moverTooltip.show();			}		});		GEvent.addListener(marker,'mouseout',function() {			if (!this.item.tooltip || !this.item.tooltip.isVisible()) {				map.closeInfoWindow();				this.item.moverTooltip.hide();			}		});	} 		if (item.node) {		var tooltip = new Tooltip(marker, item.node, 0);		marker.item.tooltip = tooltip;		map.addOverlay(tooltip);		GEvent.addListener(marker,'click',function() {			map.closeInfoWindow();			this.item.tooltip.show();		});	}		/*	if (this.popupMode!="click" && item.url) {		//only add url handling when we're not in click popup mode		GEvent.addListener(marker, "click", function() {			window.location.href=item.url;		});	}	*/	return marker;};/** creates a marker based on settings */WmgMap.prototype.createMarker = function(latlng, index, center) {	var icon;	if (center) {		var path = WmgMap.EXTRA_PATH + "images/locations/markers/center.png";		icon = new GIcon(G_DEFAULT_ICON);		icon.iconSize = new GSize(16, 23);		icon.iconAnchor = new GPoint(8, 22);		icon.image = path;	} else if (this.showNumberMarker) {		index += 1;		var path = WmgMap.EXTRA_PATH + "images/locations/markers/" + index + ".png";		icon = new GIcon(G_DEFAULT_ICON);		icon.iconSize = new GSize(16, 23);		icon.iconAnchor = new GPoint(8, 22);		icon.image = path;	} else {		var path = WmgMap.EXTRA_PATH + "images/locations/markers/generic.png";		icon = new GIcon(G_DEFAULT_ICON);		icon.iconSize = new GSize(16, 23);		icon.iconAnchor = new GPoint(8, 22);		icon.image = path;	}	icon.shadow = WmgMap.EXTRA_PATH + "images/locations/markers/shadow.png";	icon.shadowSize = new GSize(24, 23);	return new GMarker(latlng, {icon: icon});};/** * @author Marco Alionso Ramirez, marco@onemarco.com * @version 1.0 * The Tooltip class is an addon designed for the Google * Maps GMarker class. * * this class has modifications made by miguel, don't directly "upgrade" *//** * @constructor * @param {GMarker} marker * @param {String} content * @param {Number} padding */function Tooltip(marker, content, padding){	this.marker = marker;	this.content = content;	this.padding = padding;	this.div = null;	this.map = null;		this.innerContainer = null;	this._visible = false;	this.className = Tooltip.className;}Tooltip.prototype = new GOverlay();Tooltip.className = "tooltip";Tooltip.shadowImage = "images/locations/tooltip_shadow.png";Tooltip.prototype.initialize = function(map) {	var _this = this;	var closeFunc = function(event) {		if (_this.isVisible())			_this.hide();	}	GEvent.addListener(map, 'infowindowopen', closeFunc);	GEvent.addListener(map, 'click', closeFunc);	//GEvent.addListener(map, 'movestart', closeFunc);	this.div = document.createElement("div");	var innerContainer = this.div.cloneNode(false);	this.innerContainer = innerContainer;	this.div.appendChild(innerContainer);	this.div.style.position = 'absolute';	this.div.style.visibility = 'hidden';		this.shadowQuadrants = [{},{},{},{}]	this.shadowQuadrants[0].div = document.createElement('div');	this.shadowQuadrants[0].div.style.position = 'absolute';		this.shadowQuadrants[0].div.style.overflow = 'hidden';	this.shadowQuadrants[0].img = createPngElement(WmgMap.EXTRA_PATH + Tooltip.shadowImage);	this.shadowQuadrants[0].img.style.position = 'absolute';	this.shadowQuadrants[0].div.appendChild(this.shadowQuadrants[0].img);	this.shadowQuadrants[1].div = this.shadowQuadrants[0].div.cloneNode(false);	this.shadowQuadrants[1].img = this.shadowQuadrants[0].img.cloneNode(true);	this.shadowQuadrants[1].div.appendChild(this.shadowQuadrants[1].img);	this.shadowQuadrants[2].div = this.shadowQuadrants[0].div.cloneNode(false);	this.shadowQuadrants[2].img = this.shadowQuadrants[0].img.cloneNode(true);	this.shadowQuadrants[2].div.appendChild(this.shadowQuadrants[2].img);	this.shadowQuadrants[3].div = this.shadowQuadrants[0].div.cloneNode(false);	this.shadowQuadrants[3].img = this.shadowQuadrants[0].img.cloneNode(true);	this.shadowQuadrants[3].div.appendChild(this.shadowQuadrants[3].img);		this.shadowQuadrants[0].div.style.right = '0px';		this.shadowQuadrants[0].div.style.top = '0px';	this.shadowQuadrants[0].img.style.top = '0px';	this.shadowQuadrants[0].img.style.right = '0px';	this.shadowQuadrants[1].div.style.left = '0px';	this.shadowQuadrants[1].div.style.top = '0px';	this.shadowQuadrants[1].img.style.top = '0px';	this.shadowQuadrants[2].div.style.left = '0px';	this.shadowQuadrants[2].div.style.bottom = '0px';	this.shadowQuadrants[2].img.style.bottom = '0px';	this.shadowQuadrants[2].img.style.left = '0px';	this.shadowQuadrants[3].div.style.right = '0px';	this.shadowQuadrants[3].div.style.bottom = '0px';	this.shadowQuadrants[3].img.style.bottom = '0px';			this.shadow = this.div.cloneNode(false);	this.shadow.appendChild(this.shadowQuadrants[0].div);	this.shadow.appendChild(this.shadowQuadrants[1].div);	this.shadow.appendChild(this.shadowQuadrants[2].div);	this.shadow.appendChild(this.shadowQuadrants[3].div);		innerContainer.className = this.className;		var child = typeof this.content == 'string' ? 		document.createTextNode(this.content) :		this.content;	this.content = child; //mdeanda - remember new content div to re-add later	//innerContainer.appendChild(child);	map.getPane(G_MAP_FLOAT_PANE).appendChild(this.div);	map.getPane(G_MAP_MARKER_SHADOW_PANE).appendChild(this.shadow);	this.map = map;};Tooltip.prototype.redraw = function(force) {	//running thils while not visible on ie7 doesn't allow more than 1 to work :-(	if (!force || !this.isVisible()) return;		//mdeanda - add content again in case it got moved in dom	this.innerContainer.appendChild(this.content);	//draw tooltip	var markerPos = this.map.fromLatLngToDivPixel(this.marker.getPoint());	var iconAnchor = this.marker.getIcon().iconAnchor;	var xPos = Math.round(markerPos.x - this.div.clientWidth / 2);	var yPos = markerPos.y - iconAnchor.y - this.div.clientHeight - this.padding;	this.div.style.top = yPos + 'px';	this.div.style.left = xPos + 'px';		//draw shadow	//calculate shadow location	shadowAnchor = new GPoint(		markerPos.x + Math.round((this.marker.getIcon().iconSize.height + this.padding) / 2) ,		markerPos.y - Math.round((this.marker.getIcon().iconSize.height + this.padding) / 2) + 4);		//calculate shadow dimenstions	var shadowSize = new GSize(this.div.clientWidth + Math.round(this.div.clientHeight / 2) + 8,		Math.round(this.div.clientHeight / 2) + 10);	if(shadowSize.width % 2 == 1) shadowSize.width--;	if(shadowSize.height % 2 == 1) shadowSize.height--;		//apply shodaw location and dimensions	this.shadow.style.left = (shadowAnchor.x - (shadowSize.width - shadowSize.height - 10 )/ 2) + 'px';	this.shadow.style.top = (shadowAnchor.y - shadowSize.height) + 'px';	this.shadow.style.width = (shadowSize.width) + 'px';	this.shadow.style.height =  shadowSize.height + 'px';			//get quadrant dimensions	var qHeight = shadowSize.height / 2;	var qOddWidth = shadowSize.height > shadowSize.width ?		shadowSize.height / 2:		(shadowSize.width) / 2;	var qEvenWidth = shadowSize.width - qOddWidth;		//apply quadrant dimensions, calculate and apply Q2 and Q4 image offsets	this.shadowQuadrants[0].div.style.width = qOddWidth + 'px';	this.shadowQuadrants[0].div.style.height = qHeight + 'px';		this.shadowQuadrants[1].div.style.width = qEvenWidth + 'px';	this.shadowQuadrants[1].div.style.height = qHeight + 'px';	this.shadowQuadrants[1].img.style.left = -(160 - shadowSize.height) + 'px';		this.shadowQuadrants[2].div.style.width = qOddWidth + 'px';	this.shadowQuadrants[2].div.style.height = qHeight + 'px';		this.shadowQuadrants[3].div.style.width = qEvenWidth + 'px';	this.shadowQuadrants[3].div.style.height = qHeight + 'px';	this.shadowQuadrants[3].img.style.right = -(160 - shadowSize.height) +'px';	};Tooltip.prototype.remove = function() {	this.map.getPane(G_MAP_FLOAT_PANE).appendChild(this.div);	this.map.getPane(G_MAP_MARKER_SHADOW_PANE).appendChild(this.shadow);};Tooltip.prototype.isVisible = function() {	return this._visible;};Tooltip.prototype.show = function() {	if (!this._visible) {		this.div.style.visibility = 'visible';		this.shadow.style.visibility = 'visible';		//mdeanda - add content again in case it got moved in dom		this._visible = true;		this.redraw(true);	}};Tooltip.prototype.hide = function() {	if (this._visible) {		this.div.style.visibility = 'hidden';		this.shadow.style.visibility = 'hidden';		this._visible = false;	}};//utility function for png compatibility in IE6var IS_IE = false;var IS_LT_IE7 = false;//@cc_on IS_IE = true;//@cc_on IS_LT_IE7 = @_jscript_version < 5.7;function createPngElement(src){	var img = document.createElement('img');	img.setAttribute('src',src);		if(IS_IE && IS_LT_IE7){		img.style.visibility = 'hidden';		var div = document.createElement('div');		div.appendChild(img);		div.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\',sizingMethod=\'crop\')';		return div;	}	return img;	}