	var googAddress = { addr : null, city : null, state : null, zip : null };

	function goog_show_map( addr, city, state, zip )
	{
		var googMap_obj = getXmlHttpObject();
		var infoName = "genGoogleMap";
		var infoTitle = "Map";
		googAddress.addr = addr;
		googAddress.city = city;
		googAddress.state = state;
		googAddress.zip = zip;

		var post_data = GoogUtils.buildLocationsXML( new Array( googAddress ) );
		var url_data = "&locations=" + encodeURIComponent( post_data );
		var url = "/section/exec?name=googmaps_display.php5&omniture=0"+url_data;
		Floaters.createNew( infoName, null, "Generating Map...", "<br /><div style=\"text-align:center;\">Loading, please wait...</div>", 250, 100 );

		googMap_obj.onreadystatechange =
			function( googMap_obj, infoName, infoTitle )
			{
				return function()
				{
					if( googMap_obj.readyState == 4 )
					{
						var response = googMap_obj.responseText;
						Floaters.createNew( infoName, null, infoTitle, response, 515, 400 );
						GoogMap.removeInstance(0);
						GoogMap.getInstance().showMapSingleAddress( document.getElementById( "map_canvas" ), googAddress.addr, googAddress.city, googAddress.state, googAddress.zip, null, function(){ hideDisplay( "floater-1" ); } );
					}
				};
			}( googMap_obj, infoName, infoTitle );

		googMap_obj.open( "GET", url, true );
		googMap_obj.send( null );
	}

	function walkAndInsertNodes( startNode, targetNode )
	{
		var children = startNode.childNodes;
		for( var nodeCounter = 0; nodeCounter < children.length; nodeCounter++ )
		{
			curNode = children[nodeCounter].cloneNode( true );
			if( children[nodeCounter].text )
			{
				curNode.text = children[nodeCounter].text;
			}

			try
			{
				if( curNode != null )
				{
					if( curNode.tagName == "SCRIPT" )
					{
						//eval( curNode.innerText );
					}
				}

				targetNode.appendChild( curNode );
			}
			catch( e )
			{ alert(e.description); }
		}
	}

	var GoogUtils =
	{
		buildLocationsXML : function( addresses )
		{
			var returnstr = "<?xml version=\"1.0\"?><locations>";

			if( addresses instanceof Array )
			{
				for( var addr = 0; addr < addresses.length; addr++ )
				{
					var myaddr = addresses[addr];
					returnstr += "<location>";
					for( var prop in myaddr )
					{
						returnstr += "<" + prop + ">";
						returnstr += myaddr[prop].replace("&","&amp;").replace("<","&lt;").replace(">","&gt;");
						returnstr += "</" + prop + ">";
					}
					returnstr += "</location>";
				}
			}
			else
			{
				returnstr += "<location>";
				for( var prop in addresses )
				{
					returnstr += "<" + prop + ">";
					returnstr += addresses[prop].replace("&","&amp;").replace("<","&lt;").replace(">","&gt;");
					returnstr += "</" + prop + ">";
				}
				returnstr += "</location>";
			}
			returnstr += "</locations>";

			return returnstr;
		}
	}

	var GoogMap =
	{
		instance : new Array(),

		addInstance : function( index )
		{
			if( index > -1 && !(GoogMap.instance[index] instanceof GoogMaps) )
			{
				GoogMap.instance[index] = new GoogMaps();
			}
		},

		removeInstance : function( index )
		{
			if( index > -1 && index < GoogMap.instance.length && GoogMap.instance[index] instanceof GoogMaps )
			{
				GoogMap.instance[index] = null;
			}
		},

		getInstance : function( index )
		{
			index = ( index == null || index == undefined || index < 0 ? 0 : index );

			if( !( GoogMap.instance[index] instanceof GoogMaps ) )
			{
				GoogMap.instance[index] = new GoogMaps();
			}
			return GoogMap.instance[index];
		}
	}

	function GoogMapsLocation( marker, addr, city, state, zip, contenthtml )
	{
		this.marker = marker;
		this.addr = addr;
		this.city = city;
		this.state = state;
		this.zip = zip;
		this.contenthtml = contenthtml;
		this.setMarker = setMarker;
		this.getMarker = getMarker;
		this.setAddr = setAddr;
		this.getAddr = getAddr;
		this.setCity = setCity;
		this.getCity = getCity;
		this.setState = setState;
		this.getState = getState;
		this.setContentHTML = setContentHTML;
		this.getContentHTML = getContentHTML;
		this.setZip = setZip;
		this.getZip = getZip;

		function setContentHTML( contenthtml )
		{
			this.contenthtml = contenthtml;
		}

		function getContentHTML()
		{
			return this.contenthtml;
		}

		function setMarker( marker )
		{
			this.marker = marker;
		}

		function getMarker()
		{
			return this.marker;
		}

		function setAddr( addr )
		{
			this.addr = addr;
		}

		function getAddr()
		{
			return this.addr;
		}

		function setCity( city )
		{
			this.city = city;
		}

		function getCity()
		{
			return this.city;
		}

		function setState( state )
		{
			this.state = state;
		}

		function getState()
		{
			return this.state;
		}

		function setZip( zip )
		{
			this.zip = zip;
		}

		function getZip()
		{
			return this.zip;
		}
	}

	function GoogMaps()
	{
		this.googLocations = new Array();
		this.googMap = null;
		this.googGeocoder = new GClientGeocoder();
		this.showMapSingleAddress = showMapSingleAddress;
		this.panToLocation = panToLocation;
		this.init = init;
		this.getMap = getMap;

		function getMap()
		{
			return this.googMap;
		}

		function init( mapcontainer )
		{
			if( !( this.googMap instanceof GMap2 ) )
			{
				this.googMap = new GMap2( mapcontainer );
				this.googMap.addControl( new GSmallMapControl() );
				this.googMap.addControl( new GMapTypeControl() );

				if( document.body.addEventListener )
				{
					document.body.removeEventListener( "unload", GUnload, false );
					document.body.addEventListener( "unload", GUnload, false );
				}
				else
				{
					document.body.detachEvent( "onunload", GUnload );
					document.body.attachEvent( "onunload", GUnload );
				}
			}
		}

		function showMapSingleAddress( mapcontainer, addr, city, state, zip, onlookupsuccess, onlookupfail, contenthtml )
		{
			if( GBrowserIsCompatible() )
			{
				this.init( mapcontainer );
				var fullAddr = addr + ", " + city + ", " + state + " " + zip;

				//initialize map, controls, and center on omaha
				this.googMap.setCenter( new GLatLng( 41.269033, -96.04248 ), 11);
				var thisref = this;

				this.googGeocoder.getLatLng( fullAddr,
					function( point )
					{
						if( !point )
						{
							alert( "Address not found.");
							if( onlookupfail instanceof Function )
							{
								onlookupfail();
							}
						}
						else
						{
							var letter = String.fromCharCode("A".charCodeAt(0) + 0);
							var letteredIcon = new GIcon( G_DEFAULT_ICON );
							letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
							var marker = new GMarker( point, { icon:letteredIcon } );

							thisref.googMap.addOverlay( marker );

							//store this in our locations array
							var googmapsloc = new GoogMapsLocation( marker, addr, city, state, zip );
							googmapsloc.setContentHTML( contenthtml != null && contenthtml != undefined ? contenthtml : "<p>" + fullAddr + "</p>" );
							thisref.googLocations.push( googmapsloc );

							marker.openInfoWindowHtml( googmapsloc.getContentHTML() );
							GEvent.addListener( thisref.googMap, "click", function( overlay, point ){ if( overlay && overlay.openInfoWindowHtml ){ overlay.openInfoWindowHtml( googmapsloc.getContentHTML() ); } } );
							thisref.googMap.panTo( point );
							thisref.googMap.setZoom(15);

							if( onlookupsuccess instanceof Function )
							{
								onlookupsuccess();
							}
						}
					}
				);
			}
		}

		function panToLocation( locationIndex )
		{
			this.googMap.panTo( this.googLocations[locationIndex].getMarker().getPoint() );
			GEvent.trigger( this.googMap, "click", this.googLocations[locationIndex].getMarker(), this.googLocations[locationIndex].getMarker().getPoint() );
		}
	}
