/***********************************************************************************************

 ( Google Maps JavaScript Interface )

	@ The following is an interface overtop the Google Maps API.  HTML code can access the
	  functions to interact with and manipulate the displayed map. 

************************************************************************************************/

document.write("\<script type='text/javascript' src='/DesktopModules/GoogleMaps/misc/ConvertUTMLatLng.js'\>\</script\>");


GOOGLE_MAPS_JavaScipt_Interface:
{	
	var WebServiceUrl = "http://"+location.hostname+"/desktopmodules/tourism/localgeocode.aspx";
	var CountyMapUrl  = "http://webmaps.tourismoxford.ca/Map.aspx";
	
	var ModuleFolder = "/DesktopModules/GoogleMaps";
	var LastGoogleMapInstance = null;

	// Settings for Map display positions
	var SCREEN_CENTER = 1000;
	var SCREEN_MOUSE  = 1001
	var WINDOW_CENTER = 1002;
	var ANCHOR_MOUSE  = 1003;
	var ANCHOR_OBJECT = 1004
	var RELATIVE      = 1005;
	
	// Store whether this is an IE browser or not
	var IsIE         = true;
	var evtMouseDown = false;
	var DEBUGGING    = false;
	
	var Custom_Map = null;
	var OxfordLatLngBounds = null;
	var gmholdtext = null, tmpInfo = null; 

	// For Firefox set up a listener to capture all click events on the page.  The Document parent is informed 
	// to set the Window.event property so that we always have access to the consistent Event object like IE
	if (document.addEventListener)
		document.addEventListener('click',function(event){window.event = event;},true)

	// Related to the GMaps_Class.  Remaining object mappings once the GMAPS_Initialize() is called	
	function GMaps_Class_PostProcess()
	{
		// Check arguments for a parameter.  This is an opntional Window object to map the objects to
		if (arguments.length > 0)
			win = arguments[0];
		else
			win = window;	
			
		// Store the HTML objects in convenient variables
		this.MapContainer     = win.document.getElementById("MapContainer_"+this.ID);
		this.ProgDisplay      = win.document.getElementById("ProgDisplay_"+this.ID);
		this.ProgDisplay_C1   = win.document.getElementById("ProgDisplay_C1_"+this.ID);
		this.ProgDisplay_C2   = win.document.getElementById("ProgDisplay_C2_"+this.ID);
		this.GMapTable        = win.document.getElementById("GMapTable_"+this.ID);
		this.GMaps            = win.document.getElementById("GMaps_"+this.ID);
		this.GMapTourismCell  = win.document.getElementById("GMapTourismCell_"+this.ID);	
		this.MapContainerResizeBar = win.document.getElementById("MapContainerResizeBar_"+this.ID);	
		this.MapContainerTitleBar  = win.document.getElementById("MapContainerTitleBar_"+this.ID);	
		this.GMapSaveMarker        = win.document.getElementById("GMapSaveMarker_"+this.ID);
		this.TourismBack		   = win.document.getElementById("TourismBack_"+this.ID)	
		this.TourismIndexArea	   = win.document.getElementById("index_"+this.ID);
		this.TourismCell2          = win.document.getElementById("TourismCell2_"+this.ID);
	
		this.MyWindow         = win;
	}
	
	// Used to store address info.  Used by GMaps_Class to hold default locations
	function GMaps_Marker()
	{
		this.Name     = arguments[0] ? arguments[0] : "";
		this.Address  = arguments[1] ? arguments[1] : "";
		this.Phone    = arguments[2] ? arguments[2] : "";	
		this.Info     = arguments[3] ? arguments[3] : "";	
		this.LatPos   = arguments[4] ? arguments[4] : "0";
		this.LngPos   = arguments[5] ? arguments[5] : "0";
		this.RecordType = arguments[6] ? arguments[6] : "";
		
		this.marker   = null;
		this.OrgInfoHtml = "";
		this.DirectionsHtml = "";
		this.ID = "";
	}
	
	// Once the page has loaded this is the first function to be called to initialize everything
	function GMAPS_Initialize()
	{	
		if (typeof(GUnload) == "undefined" || typeof(GMap2) == "undefined" || typeof(GMaps_Class) == "undefined")
		{setTimeout("GMAPS_Initialize()",150); return;}		

		// Setup Google Maps GUnload for the window
		if (typeof (window.onunload) != 'function') 
			window.onunload = GUnload;
		else 
		{
			var oldonunload = window.onunload;
			window.onunload = function() 
			{
				oldonunload();
				GUnload();
			}
		}	
			
		// Determine if this is IE or Firefox
		IsIE = CheckBrowser();
		DoneInitialize = 1;
		
		// Check the GMaps_Class_Object_Array for the list of GMaps_Class objects to create. Are there any items stored?
		if (typeof(GMaps_Class_Object_Array) != "undefined" && GMaps_Class_Object_Array.length > 0)
		{		
			// Iterate thru all items in array			
			for (var index in GMaps_Class_Object_Array)
			{
				GMaps_Class_Object_Array[index] = new GMaps_Class(index, GMaps_Class_Object_Array[index]);
				
				// Post process the remaining class object members
				GMaps_Class_Object_Array[index].PostProcess();
				
				SetupCustomMap(GMaps_Class_Object_Array[index]);
				
				// With this, users can use their provided GOOGLEMAPS_UNIQUE_ID as the variable name to access all functionality within the class (ie. GMaps.ShowMap())
				eval(GMaps_Class_Object_Array[index].ID + " = GMaps_Class_Object_Array[index]");  
		
				// Is there some default to display, if not default to Oxford County
				if (GMaps_Class_Object_Array[index].UseDataElement.length == 0)
				{					
					GMaps_Class_Object_Array[index].UseDataElement[0] = new GMaps_Marker();
					with (GMaps_Class_Object_Array[index].UseDataElement[0])
					{
						Name    = "Tourism Oxford";
						Address = "580 Bruin Blvd, Woodstock, Ontario";
						Phone   = "(519) 539 - 9800<br>Email: <a href='mailto:tourism@county.oxford.on.ca'>tourism@county.oxford.on.ca</a>";
						Info    = "We provide travel information, maps and tourism attractions literature for Oxford County and Ontario, as well as support and advice to tourism-related businesses located in Oxford County.";
						LatPos  = "43.112421000";
						LngPos  = "-80.738267000";
					}
				}
				
				// Check for all map objects that are inlined.  We need to call it's ShowMap() to get it displayed
				if (GMaps_Class_Object_Array[index].PopUpWindow == "inline")
					GMaps_Class_Object_Array[index].ShowMap();			
				else if (GMaps_Class_Object_Array[index].PopUpWindow == "hide") // If the window was set for hide, switch now to inline for the user to manually show it
					GMaps_Class_Object_Array[index].PopUpWindow = "inline";
			}			
						
			// Remove the temporary variable 
			tmpGMaps_Class_Object_DEFLocations = null;
		}				
	}
	
	function SetupCustomMap(thisObj)
	{
		// Setup the Custom Map	
		OxfordLatLngBounds = new GLatLngBounds(new GLatLng(42.8172748, -81.13233804), new GLatLng(43.35298804, -80.43647646));//new GLatLngBounds(new GLatLng(42.716638,-81.132583), new GLatLng(43.35375,-80.439611)); //(new GLatLng(42.832194,-81.145805), new GLatLng(43.350944,-80.438388));
		var copyright = new GCopyright(1, OxfordLatLngBounds, 1, "2006 County of Oxford");
		var copyCollection = new GCopyrightCollection('');

		copyCollection.addCopyright(copyright);

		var tilelayers = [new GTileLayer(copyCollection, 1, 17)];
		
		tilelayers[0].getTileUrl = function (tile,zoom)
		{
			var Tile_TL = G_NORMAL_MAP.getProjection().fromPixelToLatLng(new GPoint(tile.x*256,tile.y*256),zoom);
			var Tile_BR = G_NORMAL_MAP.getProjection().fromPixelToLatLng(new GPoint((tile.x*256)+256,(tile.y*256)+256),zoom);

			if (OxfordLatLngBounds.intersects(new GLatLngBounds(new GLatLng(Tile_BR.lat(),Tile_TL.lng()),new GLatLng(Tile_TL.lat(),Tile_BR.lng()))))
				return CountyMapUrl + "?x=" + tile.x + "&y=" + tile.y + "&z=" + zoom + "&l=" +thisObj.ShowMapLayers;
			else
				return G_NORMAL_MAP.getTileLayers()[0].getTileUrl(tile,zoom);
		}

		Custom_Map = new GMapType(tilelayers, new GMercatorProjection(18), "Oxford County", {errorMessage:"No Map Data Available"});

		G_NORMAL_MAP.getName = function(short) 
		{ 
			if(short) {return "Google"} 
			return "Google Maps"; 
		} 			
	}
	
	// Begin the process of showing the map of the object
	// @ Arguments:
	//     + NONE: The object's UseData array will be used instead and default UsePosition will be applied
	//     + Name, Address, Phone, Info, LatPos, LngPos, [Zoom_Level, Map_Position, Map_Pos_OffsetX, Map_Pos_OffsetY]
	//     + new Array(new GMaps_Marker(),new GMaps_Marker(),...), [Zoom_Level, Map_Position, Map_Pos_OffsetX, Map_Pos_OffsetY]
	function ShowMap()
	{	
		if (arguments.length == 0 || typeof(arguments[0]) != "number")
			this.UseData = this.UseDataElement;
		else
			this.UseData = this.UseDataTourism;
	
		// If hover windows exist, capture all click events for the page to make sure all hover items are auto closed
		if (this.PopUpWindow == "hover")
		{		
			var thisObj = this;
			var oldMD=null, oldMU=null, oldMM=null;
			
			if (typeof(document.onmousedown) == "function")
				oldMD = document.onmousedown;
			if (typeof(document.onmouseup) == "function")
				oldMU = document.onmouseup;
			if (typeof(document.onmousemove) == "function")
				oldMM = document.onmousemove;
				
			document.onmousedown = function (e) 
			{
				if (oldMD) oldMD();
				if (thisObj.MapContainerBarMouseDown == 0 && !(thisObj.MapContainer.style.display != "none" && window.event.clientX + document.body.scrollLeft >= parseInt(thisObj.MapContainer.style.left) && window.event.clientX+ document.body.scrollLeft <= parseInt(thisObj.MapContainer.style.left)+parseInt(thisObj.MapContainer.style.width) && window.event.clientY+document.body.scrollTop >= parseInt(thisObj.MapContainer.style.top) && window.event.clientY+document.body.scrollTop <= parseInt(thisObj.MapContainer.style.top)+parseInt(thisObj.MapContainer.style.height)))
					evtMouseDown = true;
			};				

			document.onmouseup = function (e) 
			{
				if (evtMouseDown == true)
				{thisObj.GMapSaveMarker.style.display="none"; thisObj.TourismBack.style.display="none"; thisObj.ShowProgressWindow(0); if (thisObj.GMapTourismCell.style.display !="none") thisObj.RestoreTourismDisplay(); document.onmousedown = oldMD; document.onmouseup = oldMU; document.onmousemove = oldMM; thisObj.MapContainer.style.cursor="default";}
				evtMouseDown=false;	
				thisObj.MapContainerBarMouseDown=0;
		
				if (oldMU) oldMU();
			};						
			
			document.onmousemove = function(e)
			{	
				if (thisObj.MapContainerBarMouseDown == 1) // Move window
				{
					if (IsIE)
					{
						if (window.event.button != 1)
						{thisObj.MapContainerBarMouseDown = 0; return;}
						
						var diffX = (window.event.clientX) - thisObj.MCPrevX; thisObj.MCPrevX = window.event.clientX;
						var diffY = (window.event.clientY) - thisObj.MCPrevY; thisObj.MCPrevY = window.event.clientY;

						thisObj.MapContainer.style.pixelLeft +=diffX;
						thisObj.MapContainer.style.pixelTop +=diffY;
					}
					else
					{
						var diffX = (e.pageX) - thisObj.MCPrevX; thisObj.MCPrevX = e.pageX;
						var diffY = (e.pageY) - thisObj.MCPrevY; thisObj.MCPrevY = e.pageY;
					
						thisObj.MapContainer.style.left = parseInt(thisObj.MapContainer.style.left)+diffX;
						thisObj.MapContainer.style.top  = parseInt(thisObj.MapContainer.style.top)+ diffY;
					}	
				}
				else if (thisObj.MapContainerBarMouseDown == 2) // Resize
				{
					if (IsIE)
					{
						if (window.event.button != 1)
						{thisObj.MapContainerBarMouseDown = 0; return;}
						
						var diffX = (window.event.clientX) - thisObj.MCPrevX; thisObj.MCPrevX = window.event.clientX;
						var diffY = (window.event.clientY) - thisObj.MCPrevY; thisObj.MCPrevY = window.event.clientY;
					}
					else
					{
						var diffX = (e.pageX) - thisObj.MCPrevX; thisObj.MCPrevX = e.pageX;
						var diffY = (e.pageY) - thisObj.MCPrevY; thisObj.MCPrevY = e.pageY;
					}
					
					var newW = parseInt(thisObj.MapContainer.style.width)+diffX;
					var newH = parseInt(thisObj.MapContainer.style.height)+ diffY;
				
					if ((!thisObj.ShowTourism && newW > 310) || (thisObj.ShowTourism && newW > 480))
						thisObj.MapContainer.style.width = newW;
					if (newH > 190)	
						thisObj.MapContainer.style.height = newH;											
					
					if (!IsIE) {thisObj.TourismCell2.style.height="";thisObj.TourismCell2.style.height = thisObj.TourismCell2.clientHeight + "px";}
					
					if (thisObj.GMapsInstance && thisObj.ProcessState == 2)
						thisObj.GMapsInstance.checkResize();						
				}
				
				if (oldMM) oldMM();
			};
		}		

		// Check the incoming arguments and their type.
		if (arguments.length > 0 && typeof(arguments[0]) == "string" || typeof(arguments[0]) == "object")
		{
			// Reset the UseData array to store a new collection
			this.UseData.length = 0; this.UseData[0] = new GMaps_Marker();

			// Check last argument to set display position, if necessary
			if (typeof(arguments[arguments.length-3]) == "number" && arguments[arguments.length-3] >= SCREEN_CENTER)
			{this.UsePosition.Type = arguments[arguments.length-3]; this.UsePosition.offsetX = arguments[arguments.length-2]; this.UsePosition.offsetY = arguments[arguments.length-1];}
	
			if (typeof(arguments[0]) == "string")
			{
				with (this.UseData[0])
				{
					// First check for special ID concat to name
					if (arguments[0])
					{
						if (arguments[0].indexOf("#%") >=0)
						{
							var tmp = arguments[0].split("#%");
							ID = tmp[0];
							Name = tmp[1];
						}	
						else
							Name =  arguments[0];
					}	
					
					Address = (arguments[1] ? arguments[1] : Address);
					Phone   = (arguments[2] ? arguments[2] : Phone);
					Info    = (arguments[3] ? arguments[3] : Info);
					LatPos  = (arguments[4] ? arguments[4] : LatPos);
					LngPos  = (arguments[5] ? arguments[5] : LngPos);
					
					if (parseFloat(LatPos) < -180 || parseFloat(LatPos) > 180)
					{
						var res = ConvertUTMXY2LatLng(parseFloat(LatPos),parseFloat(LngPos));
						LatPos = res.lat + "";
						LngPos = res.lng + "";
					}	
				}	
				
				if (typeof(arguments[6]) == "string" && parseInt(arguments[6]) > 0)
				{this.GMapZoomLevel = parseInt(arguments[6]); this.UsingNewZoomLevel = true;}
			}
			else
			{
				// The user has supplied an array of GMaps_Marker
				for (var i = 0; i < arguments[0].length; i++)
				{
					this.UseData[i] = arguments[0][i];

					with (this.UseData[i])
					{
						if (Name.indexOf("#%") >=0)
						{
								var tmp = Name.split("#%");
								ID = tmp[0];
								Name = tmp[1];
						}
					}	
				}	

				if (typeof(arguments[1]) == "string" && parseInt(arguments[1]) > 0)
				{this.GMapZoomLevel = parseInt(arguments[1]); this.UsingNewZoomLevel = true;}
			}
		}
		else if (typeof(arguments[0]) == "number")
		{
			// Tourism callling with a new display
			// Reset the UseData array to store a new collection
			this.UseData.length = 0;

			// The user has supplied an array of GMaps_Marker
			for (var i = 0; i < arguments[1].length; i++)
			{
				this.UseData[i] = arguments[1][i];			
				
				with (this.UseData[i])
				{
					if (Name.indexOf("#%") >=0)
					{
							var tmp = Name.split("#%");
							ID = tmp[0];
							Name = tmp[1];
					}
				}					
			}	
				
			if (typeof(arguments[2]) == "string" && parseInt(arguments[2]) > 0)
			{this.GMapZoomLevel = parseInt(arguments[2]); this.UsingNewZoomLevel = true;}
		}

		// Call GeocodeCheck to verify all UseData.  If an item needs a lat/lng conversion it will be handled.
		if (this.UseData.length > 0)
		{
			// Clean up any illegal characters in use data before moving on
			this.DoUseDataCleanUp();

			// Show the progress window now.  In the case of a popup window, open a new window and show the display		
			if (this.ShowProgressWindow(1))
				this.GeocodeCheck(0); 	// Start the geocode checking					
		}	
	}
	
	function DoUseDataCleanUp()
	{
		for (var i=0;i<this.UseData.length;i++)
		{
			this.UseData[i].Name    = this.UseData[i].Name.replace(/^\s+|\s+$/g,"");
			this.UseData[i].Address = this.UseData[i].Address.replace(/^\s+|\s+$/g,"");
			this.UseData[i].Phone   = this.UseData[i].Phone.replace(/['"]|^\s+|\s+$/g,"");
			this.UseData[i].Info    = this.UseData[i].Info.replace(/^\s+|\s+$/g,"");
			this.UseData[i].LatPos  = this.UseData[i].LatPos.replace(/['"]|^\s+|\s+$/g,"");
			this.UseData[i].LngPos  = this.UseData[i].LngPos.replace(/['"]|^\s+|\s+$/g,"");
		}
	}
	
	// Geocode the provided address into corresponding Lat/Lng values
	// This function is also called by GeocodeResponse
	function GeocodeCheck(curIndex)
	{	
		// Reset the signature value to 0
		this.GeoSig = 0;
		
		// Iterate from the curIndex to end of array looking for the next lat/lng that needs translating
		var i;
		
		// See if this is not a tourism call.  If it is then dont bother checking for improper lat/lng since already done	
		if (this.UseData != this.UseDataTourism)	
		{
			for (i = curIndex; i < this.UseData.length; i++)
			{
				if (this.UseData[i].LatPos == "0" && this.UseData[i].LngPos == "0" && this.UseData[i].Address != "")
					break;
			}
			curIndex = i;
		}
		else
			curIndex = this.UseData.length;			

		// Is the curIndex still a valid index in the array? If so, we have more data to geocode
		if (curIndex < this.UseData.length)
		{
			// Generate a unqiue signature for this round to synchronize the callback functions with possibly changing UseData
			// This is mostly for the benefit of the hover window and inline
			var lGeoSig = Math.floor(Math.random()*1000000+1);
			
			this.GeoSig = lGeoSig;
			
			var URL = WebServiceUrl + "?type=lookup&addr="+escape(this.UseData[curIndex].Address);

			this.MakeWebRequest(URL, lGeoSig, curIndex, 1);
		}
		else // No more indexes to check
		{
			// Iterate over UseData for useful Lat/Lng values, if any then we can close progress and show map, otherwise inform user there is nothing valid
			var AnyValidEntry = false;

			for (var i = 0; i < this.UseData.length; i++)
			{
				if (this.UseData[i].LatPos != 0 || this.UseData[i].LngPos != 0)
				{AnyValidEntry = true; break;}
			}

			if (AnyValidEntry && GBrowserIsCompatible())
			{
				// Show Google Maps
				this.ShowProgressWindow(2);
				this.DoGMapDisplay();							
			}
			else // No valid Lat/Lng, error message
				this.ShowProgressWindow(-1);				
		}			
	}

	function FindThis()
	{
		this.lastScrollTop = this.TourismIndexArea.scrollTop;
		
		// Hide searchbox
		document.getElementById("n0_"+this.ID).style.display="none";
		this.ActiveTourismNodeID = 0;
		
		// Hide all other categories using idval
		var i=0, tmpElem;
		while (tmpElem = document.getElementById("AA"+i+"_"+this.ID))
		{
			var t = document.getElementById("AA"+i+"b_"+this.ID); if (t){t.style.display = "none";}
			
			tmpElem.style.display = "none";
			i++;
		}

		// Now show the Back button and township filter
		document.getElementById("TourismBack_"+this.ID).style.display=(IsIE)? "block" : "table-row";
		
		document.getElementById("ddTourismTown_"+this.ID).selectedIndex = 0;

		var pNode = document.createElement("ul");
		pNode.id ="u0_"+this.ID;
		pNode.className = "u0";
		pNode.style.display="block";
		document.getElementById("FindThisBlock_"+this.ID).appendChild(pNode);
		document.getElementById("FindThisBlock_"+this.ID).style.display="block";
		this.ActiveTourismNodeParent = pNode;

		var newNode = document.createElement("li");
		newNode.className = "a1";
		newNode.innerHTML="<div align=center><b>Search Results</b></div>";
		pNode.appendChild(newNode);	
		
		newNode = document.createElement("li");
		newNode.className = "ax";
		newNode.innerHTML="<p align=center style='margin:0; padding:0; font-family:arial;font-size:7pt'><b>Please wait ...</b><br><img src='"+ModuleFolder+"/img/prog.gif'></p>";
		this.ProgressBarNode = newNode;

		pNode.appendChild(newNode);	
		this.ActiveProgress = newNode;
		this.ActiveProgressIndex = null;
		
		this.TourismSig = Math.floor(Math.random()*1000000+1);
		var lSig = this.TourismSig;

		// Now make the request for the busineses
		// Use <script> to make the cross-domain call for geocoding.  Its CB function also contains the GeoSig and curIndex.
		var URL = WebServiceUrl + "?type=lookup2&addr="+escape(document.getElementById("findthis_"+this.ID).value);
		this.MakeWebRequest(URL, lSig, 0, 2);		
	}
	
	function MakeWebRequest(URL, lGeoSig, curIndex, type)
	{
		var ScriptID = "script_"+this.ID;

		if (document.getElementById(ScriptID))
			document.getElementsByTagName("head")[0].removeChild(document.getElementById(ScriptID));
				
		// Set the timeout to cancel the geocoding
		var thisObj = this;	
		
		if (type == 1)
			thisObj.tmrProgressBar = setTimeout(function(){thisObj.GeocodeResponse(lGeoSig,curIndex,true, ScriptID);},120000);
		else if (type == 2)
			thisObj.tourismTimer   = setTimeout(function(){thisObj.ResponseMapLocations(lGeoSig,true, ScriptID);},120000);
		else
		{			
			URL += "&addr=";
			for (var key in this.MarkerUpdates)
				URL += escape(key)+":"+this.MarkerUpdates[key]+"|";
			this.MarkerUpdates = null;
			this.MarkerUpdatesLength = 0;	
			this.GMapSaveMarker.style.display="none";
		}	

		// Compose the request for the geocoding
		var headObj   = document.getElementsByTagName("head")[0];
		var scriptObj = document.createElement("script");
		scriptObj.src = URL + "&geosig=" + lGeoSig + "&index=" + curIndex + "&myid=" + this.ID + "&mysid=" + ScriptID;
		scriptObj.id  = ScriptID;
		headObj.appendChild(scriptObj);
	}
	
	function GeocodeResponse(lGeoSig, curIndex, timeOut, scriptID)
	{
		// Check the timer value.  If it is already null then either the setTimeout or script has already called back so leave now
		// This is mostly to stop a late arriving <script> response from doing anything further once a timeout has occured
		if (this.tmrProgressBar != null)
		{
			// Cancel the timer
			clearTimeout(this.tmrProgressBar); this.tmrProgressBar = null;

			// Make sure the call back matches the current Geo Signature (the UseData is in sync with what it was before callback)
			// If not then leave now
			if (lGeoSig == this.GeoSig)		
			{
				// Make sure this call isnt by the Timeout event
				if (!timeOut)
				{
					// Try to extract Lat/Lng geocode valuee. Resp_Geocode variable is dynamically created to store the lat/lng
					if (this.Resp_Geocode)
					{
						var m = this.Resp_Geocode.split(",");					

						// Is there a match
						if (m != null && m.length == 2)
						{
							this.UseData[curIndex].LatPos = m[0];
							this.UseData[curIndex].LngPos = m[1]
						}
					}	
				}	
			}	
		}

		// If this was a dynamic script, remove it from head		
		if (document.getElementById(scriptID))
			document.getElementsByTagName("head")[0].removeChild(document.getElementById(scriptID));
		
		// Call GeocodeCheck again to test the next index
		this.GeocodeCheck(curIndex+1);		
	}			
	
	// Make visible the Progress Window while the process is busy or an error.
	function ShowProgressWindow(stage)
	{					
		switch (stage)
		{
			case 1: // Show Progress Bar
					
					this.ProcessState = 1;
										
					// Hide and show the appropiate elements.  Resize the container
					this.GMapTable.style.display = "none";
					
					if (this.ShowTourism) 
					{
						if (this.GMapTourismCell.style.display == "none")
						{
							// Show the items that arent meant to be seen
							var tmp = this.ShowTourism.split(";"), i=0;
							this.ShowingFindThis = true;
						
							while (document.getElementById("n"+i+"_"+this.ID))
							{
								for(var j=0; j < tmp.length; j++)
								{
									if (tmp[j] == i || tmp[j]=="all")
									{
										document.getElementById("n"+i+"_"+this.ID).style.display="block";
										if (document.getElementById("u"+i+"_"+this.ID))
											document.getElementById("u"+i+"_"+this.ID).style.display="none";
										break;
									}
								}
								
								if (j == tmp.length)
								{
									var t = document.getElementById("AA"+i+"b_"+this.ID); if (t) {t.style.display = "none"; this.ShowingFindThis = false;}
									document.getElementById("AA"+i+"_"+this.ID).style.display="none";
									document.getElementById("n"+i+"_"+this.ID).style.display="none";
									if (document.getElementById("u"+i+"_"+this.ID))
										document.getElementById("u"+i+"_"+this.ID).style.display="none";
								}				
								
								i++;						
							}
							
							this.GMapTourismCell.style.display = "block";
							//if (!IsIE) this.TourismIndexArea.style.height = this.TourismIndexArea.offsetHeight + "px";
						}	
					}	
					else 
						this.GMapTourismCell.style.display = "none";
					
					// Oddly, Google Maps seems to persist its visual display of the previous map even though
					// the parent element is hidden.  So if parent element is hidden, the child is still fully
					// visible, in this case.  The only way around this I've discovered is to remove the GMaps
					// DIV element and create a new one each time a new request is made.
					this.GMapTable.removeChild(this.GMaps);
					var a = document.createElement("div");
					if (IsIE)
					{
						a.style.width="100%"; 
						a.style.height="100%";
						a.style.border="solid #aaaaff";			
						a.style.borderWidth="1";
						a.id="GMaps_"+this.ID;
					}
					else
					{
						a.setAttribute("style","width:100%; height:100%; border: 1px solid #aaaaff");
						a.setAttribute("id","GMaps_"+this.ID);
					}
					
					this.GMapTable.appendChild(a);
					this.GMaps = document.getElementById("GMaps_"+this.ID);
					
					this.ProgDisplay_C2.style.display = "none";
					this.ProgDisplay_C1.style.display = (IsIE ? "block" : "table");
					this.ProgDisplay.style.display = "block";						
				
					// Is this just a tourism click, then leave now.  no need to reposition
					if (this.PopUpWindow == "hover" && this.MapContainer.style.display != "none")
						return true;
						
					this.MapContainer.style.width = this.Width;
					this.MapContainer.style.height = this.Height;									
								
					// Now reposition the MapContainer and show everything
					var xpos, ypos, posType = (this.PopUpWindow == "hover" ? "absolute" : "relative");
					var curWidth = this.MapContainer.style.width, curHeight = this.MapContainer.style.height;
					
					// Get the current width/height of the container to be used to adjust the x/ypos
					curWidth  = (curWidth.charAt(curWidth.length-1) == "%" ? (this.PopUpWindow != "inline" ?675:0) : parseInt(curWidth));
					curHeight = (curHeight.charAt(curHeight.length-1) == "%" ? (this.PopUpWindow != "inline" ?535:0) : parseInt(curHeight));

					if(this.PopUpWindow == "hover")
					{
						if (curWidth > 0)
							this.MapContainer.style.width = curWidth;
						if (curHeight >0)	
							this.MapContainer.style.height = curHeight;
						this.MapContainerTitleBar.style.display=(IsIE ? "block" : "table-row");	
						this.MapContainerResizeBar.style.display=(IsIE ? "block" : "table-row");						
					}	
					else
					{
						this.MapContainerTitleBar.style.display="none";	
						this.MapContainerResizeBar.style.display="none";
						//this.MapContainer.style.width="100%"; this.MapContainer.style.height="100%";
					}

					switch (this.UsePosition.Type)
					{
						case ANCHOR_MOUSE:  // Position near the mouse click position based inside the window
											xpos = (window.event.clientX + document.body.scrollLeft) - curWidth;
											ypos = (window.event.clientY + document.body.scrollTop);

											// If this is supposed to be a popup window then we need to add the actual screen X/Y pos
											if (this.PopUpWindow == "window")
											{
												if (IsIE)
												{
													xpos += window.screenLeft;
													ypos += window.screenTop;
												}
												else
												{
													xpos += window.screenX;
													ypos += window.screenY;												
												}
											}											
											break;							

						case ANCHOR_OBJECT: // Position near the clicked object
		
											var pos = (window.event.srcElement ? FindElementPos(window.event.srcElement) : FindElementPos(window.event.target));

											xpos = pos[0] - curWidth;
											ypos = pos[1];

											// If this is supposed to be a popup window then we need to add the actual screen X/Y pos
											if (this.PopUpWindow == "window")
											{
												if (IsIE)
												{
													xpos += window.screenLeft;
													ypos += window.screenTop;
												}
												else
												{
													xpos += window.screenX;
													ypos += window.screenY;												
												}
											}				

											break;					

						case SCREEN_MOUSE:
											xpos = window.event.screenX - parseInt(curWidth/2);
											ypos = window.event.screenY - parseInt(curHeight/2);
											break;											
	
						case SCREEN_CENTER:
											xpos = parseInt(screen.availWidth/2) - parseInt(curWidth/2);
											ypos = parseInt(screen.availHeight/2) - parseInt(curHeight/2);
											break;
	
						case WINDOW_CENTER:
											if (this.PopUpWindow == "hover")
											{
												xpos = parseInt(document.body.scrollLeft + document.body.clientWidth/2);
												ypos = parseInt(document.body.scrollTop + document.body.clientHeight/2);
											}
											else
											{
												if (IsIE)
												{
													xpos = parseInt(window.screenLeft + document.body.offsetWidth/2);
													ypos = parseInt(window.screenTop + document.body.offsetHeight/2);
												}
												else
												{
													xpos = parseInt(window.screenX + window.outerWidth/2);
													ypos = parseInt(window.screenY + window.outerHeight/2);
												}											
											}	
											
											xpos -= parseInt(curWidth/2);
											ypos -= parseInt(curHeight/2);
											
											break;
											
						default:
											xpos = 0;
											ypos = 0;
											break;
					}

					// Position the MapContainer
					with (this.MapContainer.style)
					{
						// Apply user offsets if any
						xpos += this.UsePosition.offsetX;
						ypos += this.UsePosition.offsetY;

						// Apply these values to MapContainer to adjust its position
						position = posType;				

						// Show the full MapContainer now
						if (this.PopUpWindow != "window")
						{
							// If x and y are off screen, shift back on
							left     = (xpos > 0 ? xpos : 0);
							top      = (ypos > 0 ? ypos : 0);
							
							if (this.PopUpWindow == "hover") zIndex = 10;
							
							display  = (IsIE ? "block" : "table");
						}	
						else // This is a popup window.  Copy the adjusted MapContainer contents into a new window and show it.
						{
							// Make adjustments to the xpos/ypos if offscreen values (first left edge, then right edge)
							xpos     = (xpos < 0 ? 0 : xpos);
							ypos     = (ypos < 0 ? 0 : ypos);

							xpos     = (xpos + curWidth > screen.availWidth ? xpos - ((xpos + curWidth) - screen.availWidth) : xpos);
							ypos     = (ypos + curHeight > screen.availHeight ? ypos - ((ypos + curHeight) - screen.availHeight) : ypos);

							// Since the map will appear within a different window, its left/top is set to 0 and the xpos/ypos adjust the window's position
							left = 0;
							top  = 0;
							
							// All the variables habe been set up for the window and display.  But the new window has no contents.  We need to 
							// copy the contents of this class into a new instance within the window and copy the MapContainer to the new window and start things rolling there.

							// Compose a new Global class object for the window
							var str = "GMap_Class_Instance = new GMaps_Class(0,new Array(\""+this.ID+"\",\""+this.ShowMapType+"\",\""+this.ShowNav+"\",\""+this.ShowTourism+"\",\"none\",\""+this.Width+"\",\""+this.Height+"\",\""+this.GMapZoomLevel+"\"));";	
							
							for (var i = 0; i < this.UseData.length; i++)					
							{
								str+="GMap_Class_Instance.UseDataElement["+i+"] = new GMaps_Marker(\""+this.UseData[i].Name+"\",\""+this.UseData[i].Address+"\",\""+this.UseData[i].Phone+"\",\""+this.UseData[i].Info+"\",\""+this.UseData[i].LatPos+"\",\""+this.UseData[i].LngPos+"\");";
							}
						
							str+="GMap_Class_Instance.UsePosition.Type = "+RELATIVE+"; GMap_Class_Instance.UsePosition.offsetX = 0; GMap_Class_Instance.UsePosition.offsetY = 0;";
							str+="GMap_Class_Instance.GeoSig = "+this.GeoSig+";";
							str+="GMap_Class_Instance.ProcessState = "+this.ProcessState+";";							
							str+="GMap_Class_Instance.PostProcess();";
							str+="GMAPS_Initialize(); eval(GMap_Class_Instance.ID + \" = GMap_Class_Instance;\"); GMap_Class_Instance.UseData = GMap_Class_Instance.UseDataElement;";			
							
							var strMapContainerElement = "<table id='"+this.MapContainer.getAttribute("id")+"' cellspacing=0 cellpadding=0 border=0 style'width:100%; height:100%;'>";

							// Create a new pop up window
							var newWindow = window.open("", "", "width="+curWidth+",height="+curHeight+",top="+ypos+",left="+xpos+",resizable=1");													
							if (newWindow && !newWindow.closed)
							{
								newWindow.document.write("<html><head><title>"+this.UseData[0].Name+"</title><link rel=\"stylesheet\" type=\"text/css\" href=\""+ModuleFolder+"/misc/GMapTourism.css\"><link rel='stylesheet' href='/Design/Themes/Tourism/default.css' type='text/css'/><"+"script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=" + GKEY + "' type='text/javascript'>"+"<\/"+"script><"+"script  src='"+ModuleFolder+"/misc/GoogleMapsModule.js' type='text/javascript'>"+"<\/"+"script><"+"script>var tmr1=setInterval('if (typeof(GMaps_Class) != \"undefined\"){clearInterval(tmr1); "+str+"}',300); tmr2 = setInterval('if (typeof(DoneInitialize) != \"undefined\"){clearInterval(tmr2);GMap_Class_Instance.GeocodeCheck(0);}',300);<\/"+"script></head><body style='margin:0px'>"+strMapContainerElement+this.MapContainer.innerHTML+"</table></body></html>");
								
								newWindow.document.close();
								newWindow.history.go();
							}

							// This informs the caller that this was a window and should not bother with Gecode calling, if necessary
							return false;
						}
					}
					
					break;
			
			case -1: // Error
					// If theres some pending timer, clear it now	
					clearTimeout(this.tmrProgressBar); this.tmrProgressBar = null;
					
					//this.GMapSaveMarker.style.display="none";
					this.ProcessState = -1;
					this.ProgDisplay_C1.style.display = "none";
					this.ProgDisplay_C2.style.display = (IsIE ? "block" : "table");
								
					break;
			
		    case 2: // Hide progress bar, Show Map
					// If theres some pending timer, clear it now	
					clearTimeout(this.tmrProgressBar); this.tmrProgressBar = null;

					this.ProcessState = 2;
					this.ProgDisplay.style.display = "none";
					this.GMapTable.style.display = "block";			

					break;
					
			default:			
					this.ProcessState = 0;
					this.MapContainer.style.display = "none";
		}

		return true;
	}

	function GetCurrentScrollBarTop()
	{
		if (document.body && document.body.scrollTop)
		return document.body.scrollTop;
		if (document.documentElement && document.documentElement.scrollTop)
		return document.documentElement.scrollTop;
		if (window.pageYOffset)
		return window.pageYOffset;
		return 0;
	}

	// If the map is already populated, the user can call with an index # related to UseData and have the marked item centered and info window shown
	function ShowMarker(caller, index)
	{
		if (caller == null)
			this.UseData = this.UseDataElement;  // Still need to update DoGMapDisplay to handle it
		else 
			this.UseData = this.UseDataTourism;

		// Verify the Current map is still valid
		if (this.GMapsInstanceTourism == null && !this.DisableTourism)
		{	
			// Call DoGMapDisplay to rebuild the map and plot markers, then reshow the point
			this.DoGMapDisplay();
		}		
		
		if (this.UseData[index].marker)
		{
			this.UseData[index].marker.openInfoWindowHtml(this.UseData[index].OrgInfoHtml + this.UseData[index].DirectionsHtml,{maxWidth:300});		
			
			if (this.DisableTourism)
				this.GMaps.scrollIntoView(true);
		}	
		else if (typeof(AUTHUSER) != "undefined") // Check to see if this is a 0,0 item
		{
			if (this.UseData[index].LatPos == 0 && this.UseData[index].LngPos == 0)
			{
				// Get city of this object and pass to Google Maps geocoder
				var city = caller.getAttribute("city");
			
				if (city != "")
				{
					var geocoder = new GClientGeocoder();

					var thisObj = this;
					geocoder.getLatLng(city+",ontario",
					function(point) 
					{		
						if (point) 
						{
							var icon = new GIcon();

							icon.image = ModuleFolder+"/img/icong.png";
							icon.shadow = ModuleFolder+"/img/iconps.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.transparent = ModuleFolder+"/img/markerTransparent.png";
					
							thisObj.GMapsInstance.setCenter(point, thisObj.GMapsInstance.getZoom(),thisObj.GMapsInstance.getCurrentMapType());
							thisObj.UseData[index].marker= new GMarker(point,icon);

							thisObj.GMapsInstance.addOverlay(thisObj.UseData[index].marker);
							
							var tmpAddr = thisObj.UseData[index].Address.split(",");
							var Addr, City, Prov;
							if (tmpAddr.length >= 1)
								Addr = tmpAddr[0].replace(/^\s+|\s+$/g,""); 
							if (tmpAddr.length >= 2)	
								City = tmpAddr[1].replace(/['"]|^\s+|\s+$/g,"");
							if (tmpAddr.length >= 3)		
								Prov = tmpAddr[2].replace(/['"]|^\s+|\s+$/g,"");
		
							thisObj.UseData[index].OrgInfoHtml = "<div align=center><span style='font-family:arial;font-size:8pt;'><b>" + thisObj.UseData[index].Name+"</b>" + (Addr != "" ? "<br>" + Addr : "")+ (City != "" ? ", " + City : "") + (thisObj.UseData[index].Phone != "" ? "<br>Phone: " + thisObj.UseData[index].Phone : "") + (thisObj.UseData[index].Info != "" ? "<br><br><div style='text-align:justify;'>"+thisObj.UseData[index].Info+"</div>"+(thisObj.UseData[index].ID != "" ? "<br><div style='text-align:left;'><a style='text-decoration:underline' href='http://www.cooloxford.ca/cool/report.cfm?listType="+(thisObj.UseData[index].RecordType == "Events" ? "Events": "Orgs_Base")+"&ID="+thisObj.UseData[index].ID+"' target=_blank>More Info</a></div>": "") : "")+"</span></div>";			
							thisObj.UseData[index].DirectionsHtml = "";
							
							thisObj.UseData[index].LatPos = point.x;
							thisObj.UseData[index].LngPos = point.y;
							
							SetListener(thisObj.UseData[index], thisObj);							
							
							thisObj.UseData[index].marker.openInfoWindowHtml(thisObj.UseData[index].OrgInfoHtml + thisObj.UseData[index].DirectionsHtml,{maxWidth:300});	
						}
					});
				}			
			}		
		}
	}
	

	// Take the list of data to mark on the map and show the map on screen
	function DoGMapDisplay()
	{	
		var ShowFirstMarker = true;
		
		// Check for any incoming arguments
		if (arguments.length > 0)
		{
			// Do we show the first marker automatically
			if (arguments[0] == false)
				ShowFirstMarker = false;			
		}
	
		// Time to show the items on the map.  Iterate thru UseData for all items to be placed onto the map and place a marker and related info
		// The last item to be marked will be centered and info window shown		
		var ShowObj = null;
		
		// If there is already a current instance of GMaps, then extract the previous zoom for use now
		if (this.GMapsInstance && !this.UsingNewZoomLevel)
			this.GMapZoomLevel = this.GMapsInstance.getZoom();

		this.UsingNewZoomLevel = false;

		var curMapType = Custom_Map;
		if (this.GMapsInstance)
			curMapType = this.GMapsInstance.getCurrentMapType();

		this.GMapsInstance = new GMap2(this.GMaps,{mapTypes:[G_NORMAL_MAP]});		
		this.GMapsInstance.addMapType(Custom_Map);
		
		this.GMapsInstance.enableScrollWheelZoom();
		this.GMapsInstance.enableContinuousZoom();
		
		if (this.GMaps.addEventListener)
				this.GMaps.addEventListener("DOMMouseScroll", function(e) { e.preventDefault(); }, false);
		else if (this.GMaps.attachEvent)
				this.GMaps.attachEvent("onmousewheel", function() { event.returnValue =	false; }); 		
		
		LastGoogleMapInstance = this.GMapsInstance;		
		
/*	
		if (curMapType == Custom_Map)
		{
			Custom_Map.getTileLayers()[0].getOpacity = function() {return 0.4;};
			this.GMaps.style.backgroundColor="#ffffff";
		}
*/	
		if (DEBUGGING == true)
		{
			GEvent.addListener(this.GMapsInstance, "click", 
			function(mark, point)
			{ 
				window.status = point; 
			}); 	
		}	
		
		if (typeof(AUTHUSER) != "undefined")
		{
			var myMap = this.GMaps;
			var myMapInst = this.GMapsInstance;
			
			var thisObj = this;
			
			thisObj.MarkerUpdates = new Object();
			thisObj.MarkerUpdatesLength = 0;
			this.GMapSaveMarker.style.display="none";
					
			thisObj.curMarkerOffset = Math.pow(2,(4 - thisObj.GMapsInstance.getZoom()));
			GEvent.addListener(myMapInst, "mousemove", 
			function(pint)
			{
				if (thisObj.mbutton == 1)
				{
					if (!thisObj.MarkerMoved)
					{
						thisObj.GMapsInstance.closeInfoWindow();
					}	
					thisObj.MarkerMoved = true;
					
					//thisObj.curMarker.setPoint(new GLatLng(pint.y-thisObj.curMarkerOffset,pint.x)); 
					thisObj.curMarker.setPoint(new GLatLng(pint.lat()-thisObj.curMarkerOffset,pint.lng())); 
					thisObj.curMarker.redraw(true);	
					thisObj.ShowSave(0);
				}
			});	
			
			GEvent.addListener(thisObj.GMapsInstance, "moveend", 
			function()
			{
				thisObj.curMarkerOffset = Math.pow(2,(4 - thisObj.GMapsInstance.getZoom()));
			});				
		}
		
		// Is this call for Tourism, then store this object for later comparison
		if (this.UseData == this.UseDataTourism)
			this.GMapsInstanceTourism = this.GMapsInstance;
		else
			this.GMapsInstanceTourism = null;

		if (this.ShowNav == 1)
			this.GMapsInstance.addControl(new GLargeMapControl());
		else if (this.ShowNav == 2)
			this.GMapsInstance.addControl(new GSmallMapControl());
		else if (this.ShowNav == 3)	
			this.GMapsInstance.addControl(new GSmallZoomControl());
		
		this.GMapsInstance.addControl(new GOverviewMapControl(new GSize(100,100)));
		
		if (this.ShowMapType == "1")	
			this.GMapsInstance.addControl(new GMapTypeControl());
		
		this.GMapsInstance.addControl(new GScaleControl()) ; 

		var LatLng = 0; var centered = false, iconCnt=0, myBounds = null;

		// Iterate thru all UseData for plots to point
		for (var i = 0; i < this.UseData.length; i++)
		{
			// Do we have a valid Lat/Lng to show
			if (this.UseData[i].LatPos != 0 || this.UseData[i].LngPos != 0)
			{
				// Create a legit Lat/Lng object from the provided Lat/Lng values
				LatLng = new GLatLng(parseFloat(this.UseData[i].LatPos),parseFloat(this.UseData[i].LngPos));
				
				var icon;
				if (this.UseData.length > 1)
				{
					icon = new GIcon();
					var iconName = (iconCnt < 26 ? String.fromCharCode(97+(iconCnt++)) : "");

					icon.image = ModuleFolder+"/img/micon"+iconName+".png";

					icon.shadow = ModuleFolder+"/img/iconps.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.transparent = ModuleFolder+"/img/markerTransparent.png";
					
					if (myBounds == null)
						myBounds = new GLatLngBounds();

					myBounds.extend(LatLng);					
				}
				
				// Create a new marker for the display to represent the Lat/Lng value
				this.UseData[i].marker = new GMarker(LatLng, icon);
				this.UseData[i].marker.lindex = i;			

				var tmpAddr = this.UseData[i].Address.split(",");
				var Addr, City, Prov;
				if (tmpAddr.length >= 1)
					Addr = tmpAddr[0].replace(/^\s+|\s+$/g,""); 
				if (tmpAddr.length >= 2)	
					City = tmpAddr[1].replace(/['"]|^\s+|\s+$/g,"");
				if (tmpAddr.length >= 3)		
					Prov = tmpAddr[2].replace(/['"]|^\s+|\s+$/g,"");
	
				var LL = this.UseData[i].LatPos+","+this.UseData[i].LngPos;			

				this.UseData[i].OrgInfoHtml = "<div align=center><span style='font-family:arial;font-size:8pt;'><b>" + this.UseData[i].Name+"</b>" + (Addr != "" ? "<br>" + Addr : "")+ (City != "" ? ", " + City : "") + (this.UseData[i].Phone != "" ? "<br>Phone: " + this.UseData[i].Phone : "") + (this.UseData[i].Info != "" ? "<br><br><div style='text-align:justify;'>"+this.UseData[i].Info+"</div>"+(this.UseData[i].ID != "" ? "<br><div style='text-align:left;'><a style='text-decoration:underline' href='http://www.cooloxford.ca/cool/report.cfm?listType="+(this.UseData[i].RecordType == "Events" ? "Events": "Orgs_Base")+"&ID="+this.UseData[i].ID+"' target=_blank>More Info</a></div>": "") : "")+"</span></div>";			
				this.UseData[i].DirectionsHtml = "<div align=center><span style='font-family:arial;font-size:8pt; position: relative; top:0px'><br>Directions: <a style='font-family:arial;font-size:8pt' href=\"javascript:DirectionsDisplay(1,"+i+",\'"+this.ID+"\',\'"+Addr+"',\'"+City+"\')\">To Here</a> - <a style='font-family:arial;font-size:8pt' href=\"javascript:DirectionsDisplay(2,"+i+",\'"+this.ID+"\',\'"+Addr+"',\'"+City+"\')\">From Here</a></span></div>";						

				SetListener(this.UseData[i], this);

				// This seems required to get GMaps to display properly
				if (!centered)
				{
					this.GMapsInstance.setCenter(LatLng, parseInt(this.GMapZoomLevel),(curMapType ? curMapType : Custom_Map)); 
					centered = true;
				}
				
				this.GMapsInstance.addOverlay(this.UseData[i].marker);
				
				//this.GMapsInstance.setCenter(LatLng, lastZoom);
				if (ShowFirstMarker && this.UseData.length == 1)
				{this.UseData[i].marker.openInfoWindowHtml(this.UseData[i].OrgInfoHtml + this.UseData[i].DirectionsHtml,{maxWidth:300}); ShowFirstMarker = false;}
			}
		}	
				
		if (this.GMapsInstance)
			this.GMapsInstance.checkResize();						
			
		if (myBounds)
			centerAndZoomOnBounds(this.GMapsInstance, myBounds);	
			
		if (!IsIE) this.TourismCell2.style.height = this.TourismCell2.clientHeight + "px";	
	}
	
	
	function centerAndZoomOnBounds(map, bounds) 
	{ 
          map.setZoom(map.getBoundsZoomLevel(bounds));

          var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
          var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
          map.setCenter(new GLatLng(clat,clng));	        
	}
	
	
	function ShowSave(val)
	{	
		if (!this.MarkerShowChanges)
		{
			if (val == 0 && this.MarkerUpdatesLength < 2000)
				this.GMapSaveMarker.style.display="inline";
			else
			{
				this.MakeWebRequest(WebServiceUrl+"?type=update", 0, 0, 3);
			}			
		}	
	}
	

	
	function SetListener(obj, obj2)
	{
		var thisObj = obj, thisObj2 = obj2;
		
		GEvent.addListener(thisObj.marker, "click",
		function()
		{
			if (thisObj2.MarkerMoved == false)
				thisObj.marker.openInfoWindowHtml(thisObj.OrgInfoHtml + thisObj.DirectionsHtml,{maxWidth:300});
			else
			{
				if (thisObj2.MarkerShowChanges)
				{
					if (thisObj2.GMapSaveMarker.onclick)
					{
						thisObj2.GMapSaveMarker.title = "";
						thisObj2.GMapSaveMarker.onclick = null;
						thisObj2.GMapSaveMarker.innerHTML = "";
						thisObj2.GMapSaveMarker.style.display="inline";
						thisObj2.GMapSaveMarker.style.top = "-26px";
					}
					
					var pt = thisObj.marker.getPoint()
					thisObj2.GMapSaveMarker.innerHTML = "Lat/Lng: " + pt.lat() + ", " + pt.lng() + " <input type=button value='Copy' onclick='if (window.clipboardData) window.clipboardData.setData(\"Text\",\""+thisObj.Name.replace("\"","") + " = " + pt.lat() + "," + pt.lng()+"\")'>";						
				}	
			}	
			thisObj2.MarkerMoved = false;	
		});	
		
		
		GEvent.addListener(thisObj2.GMapsInstance, "maptypechanged",
		function()
		{
			// Is the current map type Oxford County and the current display boundaries don't intersect, then recenter the display
			if (Custom_Map == thisObj2.GMapsInstance.getCurrentMapType() && !thisObj2.GMapsInstance.getBounds().intersects(OxfordLatLngBounds))
			{thisObj2.GMapsInstance.setCenter(new GLatLng(43.13757082270374,-80.74831008911133), 10, Custom_Map);}
		
		});
		
		if (typeof(AUTHUSER) != "undefined")
		{
			GEvent.addListener(thisObj.marker, "mouseup", 
			function()
			{
				thisObj2.mbutton = 0; thisObj2.curMarker = thisObj.marker;					
				var name = thisObj2.curMarkerAddress.replace(/ /g,"").toLowerCase();
				var cord = TruncNum(thisObj2.curMarker.getPoint().lat(),7) + "," + TruncNum(thisObj2.curMarker.getPoint().lng(),7);
				
				if (thisObj2.MarkerUpdates[name] == null)
					thisObj2.MarkerUpdatesLength += name.length + cord.length + 2;
					
				thisObj2.MarkerUpdates[name] = cord;				
			});		
			
			GEvent.addListener(thisObj.marker, "mousedown", 
			function()
			{
				thisObj2.MarkerMoved = false;
				thisObj2.mbutton = 1; thisObj2.curMarker = thisObj.marker;
				thisObj2.curMarkerAddress = thisObj.Address;
			});		
		}
	}
	
	function DirectionsDisplay(val,index, ID, Addr, City)
	{
		eval("var thisObj = "+ID+".UseData[index];");
		
		// Directions to Here
		var LL = thisObj.LatPos+","+thisObj.LngPos;
		if (val == 1)
			thisObj.marker.openInfoWindowHtml(thisObj.OrgInfoHtml + '<div align=center><span style="font-family:arial;font-size:8pt; position: relative; top:0px"><br>Directions: <b>To Here</b> - <a style="font-family:arial;font-size:8pt" href="javascript:DirectionsDisplay(2,'+index+',\''+ID+'\',\''+Addr+'\',\''+City+'\')">From Here</a><form name="gmapdir" style="position:relative; margin:0; padding:0; top:4" action="http://maps.google.com/maps" method="get" target="_blank">Start Address:<br><input type="text" SIZE=21 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br><INPUT style="font-size:8pt" name="submit" value="Get Directions" TYPE="SUBMIT"><input type="hidden" name="daddr" value="' + LL + '('+ Addr + ',' + City + ',Ontario)"/></span></div>',{maxWidth:300});
		else
			thisObj.marker.openInfoWindowHtml(thisObj.OrgInfoHtml + '<div align=center><span style="font-family:arial;font-size:8pt; position: relative; top:0px"><br>Directions: <a style="font-family:arial;font-size:8pt" href="javascript:DirectionsDisplay(1,'+index+',\''+ID+'\',\''+Addr+'\',\''+City+'\')">To Here</a> - <b>From Here</b><form name="gmapdir" style="position:relative; top:4px; margin:0; padding:0" action="http://maps.google.com/maps" method="get" target="_blank">End Address:<br><input type="text" SIZE=21 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br><INPUT style="font-size:8pt" name="submit"  value="Get Directions" TYPE="SUBMIT"><input type="hidden" name="saddr" value="' + LL + '('+ Addr + ',' + City + ',Ontario)"/></span></div>',{maxWidth:300});
	}

	function HoverToggleWindowSize()
	{
		with (this.MapContainer.style)
		{	
			var hoverLeft   = parseInt(left);
			var hoverWidth  = parseInt(this.MapContainer.style.width);
			var hoverTop    = parseInt(top);
			var hoverHeight = parseInt(this.MapContainer.style.height);
			var doc = document.body;
		
			// Is the hover window currently sized to consume the entire client window? If not make it so			
			if (!(hoverLeft == doc.scrollLeft && hoverLeft + hoverWidth == doc.scrollLeft + doc.clientWidth && hoverTop == doc.scrollTop && hoverTop + hoverHeight == doc.scrollTop + doc.clientHeight) || !(this.HoverPrevWidth > 0 && this.HoverPrevHeight > 0))
			{
				this.HoverPrevLeft = hoverLeft;
				this.HoverPrevTop  = hoverTop;
				this.HoverPrevWidth = hoverWidth;
				this.HoverPrevHeight = hoverHeight;
				
				left  = doc.scrollLeft;
				top   = doc.scrollTop;
				this.MapContainer.style.width = doc.clientWidth;
				this.MapContainer.style.height = doc.clientHeight;
				
				if (this.GMapsInstance && this.ProcessState == 2)
					this.GMapsInstance.checkResize();
			}
			else
			{
				// Resize to previous, smaller size
				if (this.HoverPrevWidth > 0 && this.HoverPrevHeight > 0)
				{
					left  = this.HoverPrevLeft;
					top   = this.HoverPrevTop;
					this.MapContainer.style.width = this.HoverPrevWidth;
					this.MapContainer.style.height = this.HoverPrevHeight;				

					this.HoverPrevLeft = 0;
					this.HoverPrevTop  = 0;
					this.HoverPrevWidth = 0;
					this.HoverPrevHeight = 0;
					
					if (this.GMapsInstance && this.ProcessState == 2)
						this.GMapsInstance.checkResize();
				}
			}
		}					
	}

	// Tourism Functions
	function high(val)
	{	
		if (!IsIE) return; 

		if (val) // Store the bkg
		{
			obj = (IsIE ? window.event.srcElement : window.event.target);									
				
			key = obj.getAttribute("key");
			
			if (obj.nodeName.toLowerCase() != "li" || (key != null && key.indexOf("mrk") == -1 && document.getElementById("TourismBack_"+this.ID).style.display!="none"))
			{
				if (this.oldbkg != null)
				{	
					this.lastobj.style.backgroundColor=this.oldbkg;
					this.oldbkg = null;
				}	
			}	
			else
			{
				this.lastobj = obj;									
				this.oldbkg  = obj.style.backgroundColor;
				
				if (obj.parentNode == document.getElementById("u0_"+this.ID))
					obj.style.backgroundColor='#d7ebf2';				
				else if (obj.parentNode == document.getElementById("u1_"+this.ID))
					obj.style.backgroundColor='#d7ebf2';
				else if (obj.parentNode == document.getElementById("u2_"+this.ID))
					obj.style.backgroundColor='#f4e1eb';
				else if (obj.parentNode == document.getElementById("u3_"+this.ID))
					obj.style.backgroundColor='#f9ebde';
				else if (obj.parentNode == document.getElementById("u4_"+this.ID))
					obj.style.backgroundColor='#eae2f8';
				else if (obj.parentNode == document.getElementById("u5_"+this.ID))
					obj.style.backgroundColor='#eee4e4';
				else if (obj.parentNode == document.getElementById("u6_"+this.ID))
					obj.style.backgroundColor='#f3f6d8';
				else if (obj.parentNode == document.getElementById("u7_"+this.ID))
					obj.style.backgroundColor='#e7e7e7';
				else if (obj.parentNode == document.getElementById("u8_"+this.ID))
					obj.style.backgroundColor='#dcf9e6';
			}	
		}
		else
			if (this.oldbkg != null) this.lastobj.style.backgroundColor=this.oldbkg;
	}

	function GoogleMapMarkerShow(obj, val)
	{
		// Iterate over the entire list for any previous marked item to remove it
		//var theChildren = obj.parentNode.childNodes, theChildrenCnt = obj.parentNode.childNodes.length;
	/*
		for (var i=0; i < theChildrenCnt; i++)
		{
			if (theChildren[i].innerHTML.match(/^<span.+?arrow1.gif.+?span>/i))
			{theChildren[i].innerHTML = theChildren[i].innerHTML.replace(/^<span.+?arrow1.png.+span>/i,""); break;}
		}
	*/	
		//if (this.lastPointerObj != null)
		//	this.lastPointerObj.innerHTML = this.lastPointerObj.innerHTML.replace(/^<span.+?arrow.png.+span>/i,"");						
									
		// First place a arrow marker next to the selected item
		//obj.innerHTML="<span style='position:relative;'><span style=\"width:10; height:17; position:absolute; top:2; left:-19; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ModuleFolder+"/img/arrow1.png', sizingMethod='image')\"></span></span>"+obj.innerHTML;
		this.ShowMarker(obj,val);
	}

	function GetBusinessInfo(e, tmpArr)
	{
		this.ActiveTourismNode = null; this.ActiveTourismNodeParent = null; this.ActiveTourismNodeID = 0; this.ActiveProgress=null; this.ActiveProgressIndex = 0; this.ProgressBarNode = null;
		this.lastPointerObj = null;

		// Store the current scrollbar position of Tourism
		this.lastScrollTop = this.TourismIndexArea.scrollTop;

		// First we need to hide all items on screen to make way for the list
		
		// Store the current node for later
		this.ActiveTourismNode = e;
		
		// Call this to dehighlight the tourism highlight.  Necessary for a subtle IE error.
		this.high();
		
		// Get the parent node
		var parent = this.ActiveTourismNodeParent = e.parentNode;
		var parentID = e.parentNode.id;

		var idval = parentID.match(/(\d+)_/); idval = idval[idval.length-1]; this.ActiveTourismNodeID = idval;
		var child = parent.childNodes;

		// Iterate over all children for this parent to hide them
		for (var i=0; i < child.length; i++)
		{
			if (child[i] != e && child[i].nodeName.toLowerCase() == "li")
				child[i].style.display="none";
		}

		// Now we must hide all other categories using idval
		var i=0, tmpElem;
		while (tmpElem = document.getElementById("AA"+i+"_"+this.ID))
		{
			if ("AA"+i != "AA"+idval)
			{
				tmpElem.style.display = "none";
				var t = document.getElementById("AA"+i+"b_"+this.ID); if (t) t.style.display = "none";				
			}	
			i++;
		}

		// Now show the Back button and township filter
		document.getElementById("TourismBack_"+this.ID).style.display=(IsIE)? "block" : "table-row";
		
		document.getElementById("ddTourismTown_"+this.ID).selectedIndex = 0;

		// Because we have to retrieve the list of businesses show progress bar while user waits
		var nn = this.ActiveTourismNodeParent.nodeName.toLowerCase();

		// Is there a UL parent already.  Then we can just add the new LI entry
		var pNode = this.ActiveTourismNodeParent;
		if (nn != "ul")
		{
			pNode = document.createElement("ul");
			pNode.id ="u"+this.ActiveTourismNodeID+"_"+this.ID;
			pNode.className = "u"+this.ActiveTourismNodeID;
			pNode.style.display="block";
			document.getElementById("AA"+this.ActiveTourismNodeID+"_"+this.ID).appendChild(pNode);
			this.ActiveTourismNodeParent = pNode;
		}

		var newNode = document.createElement("li");
		newNode.className = "ax";
		newNode.innerHTML="<p align=center style='margin:0; padding:0; font-family:arial;font-size:7pt'><b>Please wait ...</b><br><img src='"+ModuleFolder+"/img/prog.gif'></p>";
		this.ProgressBarNode = newNode;

		pNode.appendChild(newNode);

		if (nn=="ul")
			this.ActiveProgress = newNode;
		else
			this.ActiveProgress = pNode;

		this.TourismSig = Math.floor(Math.random()*1000000+1);
		var lSig = this.TourismSig;

		// Now make the request for the busineses
		// Use <script> to make the cross-domain call for geocoding.  Its CB function also contains the GeoSig and curIndex.
		this.MakeWebRequest(WebServiceUrl+"?type="+tmpArr[0]+"&gpc="+tmpArr[1]+"&naics="+tmpArr[2]+"&loc="+tmpArr[3],lSig,0, 2);
	}

	function ResponseMapLocations(lSig,timeOut, scriptID)
	{
		var doingShowMap = false;
		
		clearTimeout(this.tourismTimer);

		if (lSig == this.TourismSig)
		{		
			// Make sure this call isnt by the Timeout event
			if (!timeOut)
			{
				// Try to extract Lat/Lng geocode values
				
				if (this.Resp_Geocode)
				{
					var m = this.Resp_Geocode.split("~~~");

					// Is there a match
					if (m != null && m.length == 3)
					{								
						// Build Township dropdown
						// Build Township dropdown
						var towns = m[0].split(",");
						var newOpt;

						for (var i=0;i<towns.length;i++)
						{
							newOpt = document.createElement("option");
							newOpt.innerHTML=towns[i];
							document.getElementById("ddTourismTown_"+this.ID).appendChild(newOpt);
						}

						doingShowMap = true;
						
						// Do Showmap with GMarker
						eval("this.ShowMap(1,new Array("+m[2]+"));");

						// Build LIList
						if (this.ActiveProgress.nodeName.toLowerCase() == "ul")
							this.ActiveProgress.innerHTML = m[1];
						else
						{
							var par = this.ActiveProgress.parentNode;
							par.removeChild(this.ActiveProgress);
							var lastChildIndex = this.ActiveProgressIndex = par.childNodes.length;
							
							par.innerHTML+=m[1];
							this.ActiveProgress = par.childNodes[lastChildIndex];
						}
					}
					else
					{	
						this.ProgressBarNode.className="b";
						this.ProgressBarNode.innerHTML = "<div align=center style='font-family:arial; font-size:7pt'><b>Sorry, No Results Found.<br>Please Check Back Later.</b></div>";
					}
				}	
				else
				{	
					this.ProgressBarNode.className="b";
					this.ProgressBarNode.innerHTML = "<div align=center style='font-family:arial; font-size:7pt'><b>Sorry, No Results Found.<br>Please Check Back Later.</b></div>";
				}
			}
			else
			{
				this.ProgressBarNode.className="b";
				this.ProgressBarNode.innerHTML = "<div align=center style='font-family:arial; font-size:7pt'><b>Sorry, No Results Found.<br>Please Check Back Later.</b></div>";
			}	
		}

		// If this was a dynamic script, remove it from head		
		if (!doingShowMap && document.getElementById(scriptID))
			document.getElementsByTagName("head")[0].removeChild(document.getElementById(scriptID));
		
		this.TourismSig = 0;
	}

	function NAV(val)
	{
		var x = document.getElementById("u"+val+"_"+this.ID);
		x.style.display = (x.style.display =="block" ? "none":"block");
	}

	function RestoreTourismDisplay()
	{
		// First hide all remaining display
		document.getElementById("TourismBack_"+this.ID).style.display="none";

		// Just in case called from ShowProgress to reset the tourism display
		if (this.ActiveProgress == null)
			return;

		// Is ActiveProgress the last child in the group, if not then theres more to remove
		if (this.ActiveProgress.nodeName.toLowerCase() =="li" && this.ActiveProgressIndex > 0 && this.ActiveTourismNodeID != 0)
		{
			var par = this.ActiveProgress.parentNode;
			while (par.childNodes[this.ActiveProgressIndex] != null)
				par.removeChild(par.childNodes[this.ActiveProgressIndex]);
		}
		else if (this.ActiveProgress.nodeName.toLowerCase() =="li" && this.ActiveProgressIndex == 0)
		{
			this.ActiveProgress.parentNode.removeChild(this.ActiveProgress);
		}
		else
		{
			this.ActiveTourismNodeParent.parentNode.removeChild(this.ActiveTourismNodeParent);
			this.ActiveTourismNodeParent = null;
		}

		var t = document.getElementById("AA"+this.ActiveTourismNodeID+"b_"+this.ID); if (t) t.style.display = "none";
		document.getElementById("AA"+this.ActiveTourismNodeID+"_"+this.ID).style.display="none";
		document.getElementById("ddTourismTown_"+this.ID).options.length=1;

		// Now show all children of the earlier active node
		if (this.ActiveTourismNodeParent)
		{
			var child = this.ActiveTourismNodeParent.childNodes;
			for (var i=0; i < child.length; i++)
			{
				if (child[i].nodeName.toLowerCase() == "li")
					child[i].style.display="block";
			}
		}
		else if (this.ActiveTourismNodeID == 0) // Is this a search box request, then show its contents
		{
			document.getElementById("n0_"+this.ID).style.display="block";
		}
		
		// Now show all blocks
		// Now we must restore all other categories using idval
		var i=0, tmpElem;
		while (tmpElem = document.getElementById("AA"+i+"_"+this.ID))
		{
			if (i==0 && this.ShowingFindThis) {document.getElementById("AA0b_"+this.ID).style.display = (IsIE) ? "block":"table-row"; document.getElementById("FindThisBlock_"+this.ID).style.display="none";}
			tmpElem.style.display = "block";
			i++;
		}

		//Restore the last scroll position in the main window
		this.TourismIndexArea.scrollTop = this.lastScrollTop;		

		this.ActiveTourismNode = null; this.ActiveTourismNodeParent = null; this.ActiveTourismNodeID = 0; this.ActiveProgress=null; this.ActiveProgressIndex = 0; this.ProgressBarNode = null;
		this.lastPointerObj = null;
		
		this.TourismSig = 0;
	}

	function Find()
	{
		var e = (IsIE ? window.event.srcElement : window.event.target);
		var attrib =  e.getAttribute("key");
					
		if (attrib != null)
		{
			var tmp = attrib.split("-");

			if (this.ActiveTourismNode == null || tmp[0] =="back" || tmp[0]=="mrk")
			{
				switch (tmp[0])
				{
					case "nav":
							this.NAV(tmp[1]);
							break;

					case "mrk":
							this.GoogleMapMarkerShow(e,tmp[1]);
							break;

					case "back":
							this.RestoreTourismDisplay();
							break;
					default:
							this.GetBusinessInfo(e,tmp);
				}
			}
		}
	}

	function TownChange()
	{
		// We need to filter the list to show only a certain town
		var e = (IsIE ? window.event.srcElement : window.event.target);
		var city = e.options[e.selectedIndex].text;

		var cnt = this.ActiveTourismNodeParent.childNodes.length;

		for (var i=0; i < cnt; i++)
		{
			var node = this.ActiveTourismNodeParent.childNodes[i];
			if (node.nodeName.toLowerCase() == "li")
			{
				var nodeVal = node.getAttribute("city");

				if (nodeVal != null)
				{
					if ( nodeVal != city && city !="All Towns")
						this.ActiveTourismNodeParent.childNodes[i].style.display="none";
					else
						this.ActiveTourismNodeParent.childNodes[i].style.display="block";
				}
			}	
		}
	}

	
///////////// MISC FUNCTIONS ////////////////
	
	function CheckBrowser()
	{
		try
		{
			var span = document.createElement("span");
			span.style.display="table";
			return false;
		}
		catch (err)
		{
			return true;
		}
	}
	
	// Find the X/Y location of a DOM element on the page
	function FindElementPos(iobj)
	{
		obj = iobj;

		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;

		obj = iobj;
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop;
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;

		return [curleft, curtop];
	}
	
	function URLEncode(plaintext)
	{
		// The Javascript escape and unescape functions do not correspond
		// with what browsers actually do...
		var SAFECHARS = "0123456789" +					// Numeric
						"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
						"abcdefghijklmnopqrstuvwxyz" +
						"-_.!~*'()";					// RFC2396 Mark characters
		var HEX = "0123456789ABCDEF";

		var encoded = "";
		for (var i = 0; i < plaintext.length; i++ ) {
			var ch = plaintext.charAt(i);
			if (ch == " ") {
				encoded += "+";				// x-www-urlencoded, rather than %20
			} else if (SAFECHARS.indexOf(ch) != -1) {
				encoded += ch;
			} else {
				var charCode = ch.charCodeAt(0);
				if (charCode > 255) {
					/*
					alert( "Unicode Character '"
							+ ch
							+ "' cannot be encoded using standard URL encoding.\n" +
							"(URL encoding only supports 8-bit characters.)\n" +
							"A space (+) will be substituted." );*/
					encoded += "+";
				} else {
					encoded += "%";
					encoded += HEX.charAt((charCode >> 4) & 0xF);
					encoded += HEX.charAt(charCode & 0xF);
				}
			}
		} // for

		return encoded;
	}

	function createCookie(name,value,days)
	{
		if (days)
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

	function readCookie(name)
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++)
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	function eraseCookie(name)
	{
		createCookie(name,"",-1);
	}

	function TruncNum(num, digits)
	{
 		var retNum = num;
		var snum = num+'';
		var pos = snum.indexOf(".");

		if (pos >= 0 && pos + digits < snum.length)
		{
			retNum = snum.substr(0, pos+digits+(digits > 0 ? 1:0));
		}

		return retNum;
	}

	// Class Type stores info and offers functionality for each map added to page
	// This is placed at the bottom of this file to make sure that any timer that waits for its existence will have
	// to wait till the entire file is loaded letting all other functions come into existence.
	function GMaps_Class()
	{	
		this.ID					 = arguments[1][0];
		this.ShowMapType		 = arguments[1][1];
		this.ShowNav			 = arguments[1][2];
		this.ShowTourism		 = arguments[1][3];
		this.PopUpWindow		 = arguments[1][4];
		this.Width				 = arguments[1][5];
		this.Height				 = arguments[1][6];
		this.GMapZoomLevel		 = arguments[1][7];
		this.MarkerShowChanges   = arguments[1][8];
		this.DisableTourism      = arguments[1][9];
		
		this.UseData		 	 = null;        // A reference to point to either UseDataElement or UseDataTourism
		this.UseDataElement 	 = new Array(); // An array of non-Tourism GMaps_Marker() objects		
		this.UseDataTourism      = new Array(); // An array of Tourism GMaps Marker objects		
		this.UsePosition		 = new Object(); 
		this.UsePosition.offsetX = 0;
		this.UsePosition.offsetY = 0;
		this.GeoSig				 = 0;
		this.tmrProgressBar		 = null;
		this.ProcessState        = 0;
		this.GMapsInstance       = null;
		this.GMapsInstanceTourism= null;
		this.Resp_Geocode        = "";
		this.HoverWindowIsFullScreen  = false;
		this.HoverPrevLeft = 0;
		this.HoverPrevTop = 0;
		this.HoverPrevWidth = 0;
		this.HoverPrevHeight = 0;
		this.mbutton = 0;
		this.curMarker = null;
		this.curMarkerAddress = "";
		this.curMakerOffset = 0;
		this.MarkerUpdates = null;
		this.MarkerUpdatesLength = 0;
		this.MarkerMoved = false;
		this.ShowMapLayers = "";
		
		// Tourism variable
		this.ActiveTourismNode = null;
		this.ActiveTourismNodeParent = null;
		this.ActiveTourismNodeID = 0;
		this.ActiveProgress=null;
		this.ActiveProgressIndex = 0;
		this.ProgressBarNode = null;
		this.TourismSig = 0;
		this.tourismTimer = null;
		this.oldbkg = null;
		this.lastobj = null;
		this.lastPointerObj = null;
		
		this.MapContainerBarMouseDown=0;
		this.MCPrevX = 0;
		this.MCPrevY = 0;			
		this.UsingNewZoomLevel = false;
		this.lastScrollTop = 0;
		this.ShowingFindThis = true;
		
		// Check tmpGMaps_Class_Object_DEFLocations for contents.  These values hold default locations to plot onto the map stored in this class objects UseData variable
		if (typeof(tmpGMaps_Class_Object_DEFLocations) != "undefined")
		{
			var tmpStr = tmpGMaps_Class_Object_DEFLocations[arguments[0]];

			if (typeof(tmpStr) != "undefined" && tmpStr != "")
			{
				var tmpArr = tmpStr.split("|||");
				for (var i = 0; i < tmpArr.length; i++)
				{
					var tmpItems = tmpArr[i].split(":::");
					
					this.UseDataElement[i] = new GMaps_Marker(tmpItems[0],tmpItems[1],tmpItems[2],tmpItems[3],tmpItems[4],tmpItems[5]);
				}
			}	
		}
		
		// If PopupWindow member is set for default display of Hover/Window/None, then set the default position types	
		if (this.PopUpWindow == "hover")
			this.UsePosition.Type = WINDOW_CENTER; //ANCHOR_OBJECT;
		else if (this.PopUpWindow == "window")	
			this.UsePosition.Type = WINDOW_CENTER;
		else
			this.UsePosition.Type = RELATIVE;	
		
		// Establish the class's methods
		this.ShowMap            = ShowMap;
		this.DoGMapDisplay      = DoGMapDisplay;
		this.GeocodeCheck       = GeocodeCheck;
		this.GeocodeResponse    = GeocodeResponse;
		this.ShowProgressWindow = ShowProgressWindow;
		this.ShowMarker         = ShowMarker;
		this.PostProcess        = GMaps_Class_PostProcess;		
		this.DoUseDataCleanUp   = DoUseDataCleanUp;
		this.high               = high;
		this.GoogleMapMarkerShow= GoogleMapMarkerShow;
		this.GetBusinessInfo	= GetBusinessInfo;
		this.ResponseMapLocations  = ResponseMapLocations;
		this.NAV				   = NAV;
		this.RestoreTourismDisplay = RestoreTourismDisplay;
		this.Find				   = Find;
		this.TownChange			   = TownChange;
		this.MakeWebRequest        = MakeWebRequest;
		this.HoverToggleWindowSize = HoverToggleWindowSize;
		this.FindThis			   = FindThis;
		this.ShowSave	  	    = ShowSave;
		this.MapContainer       = null;
		this.ProgDisplay		= null;
		this.ProgDisplay_C1		= null;
		this.ProgDisplay_C2		= null;
		this.GMapTable			= null;
		this.GMaps				= null;
		this.GMapTourismCell	= null;
		this.MyWindow			= null;
		this.TourismIndexArea   = null;
		this.TourismCell2       = null;
		//this.CurrentlyWindowed	= (arguments[1][7] ? arguments[1][7] : false);
	}
}
