	var map = null;
	var Debug = false;
	var Verbose = false;
	
	var maxZoomLevel = 10;
	
	var tileServerDirectory = '/TileMaps';
	if( window.location.toString().match('/Pages/') != null )
		tileServerDirectory = '/Pages' + tileServerDirectory;
	
	function GetMap()
	{
		GetMap_Meta( false );
	}
	
	function GetFixedMap()
	{
		GetMap_Meta( true );
	}
	
	function GetMap_Meta( isFixed )
	{
		if ( document.getElementById('myMap') == null)
			return;

		map = new VEMap('myMap');
		map.SetDashboardSize(VEDashboardSize.Tiny);
		map.LoadMap(new VELatLong(41.5086, -98.0859),3,'r', isFixed);

		if( VEMap.GetVersion() >= 6 )
			map.SetMouseWheelZoomToCenter( false );
		//map.AttachEvent("onstartzoom", StartZoomHandler);
		map.AttachEvent("onendzoom",EndZoomHandler);
		map.AttachEvent("onmousewheel", MouseWheelEventHandler);
		map.AttachEvent("ondoubleclick", MouseDoubleClickEventHandler);

		GetTiles();
	}
	
	function MouseDoubleClickEventHandler( mapEvent )
	{
		if( mapEvent.zoomLevel == maxZoomLevel )
			return true;
		else
			return false;
	}

	function MouseWheelEventHandler( mapEvent )
	{
		if( mapEvent.mouseWheelChange > 0 && mapEvent.zoomLevel == maxZoomLevel )
			return true;
		else
			return false;
	}
	/*
	function StartZoomHandler( mapEvent )
	{
		var e_zoom = mapEvent.zoomLevel;
		if( e_zoom >= maxZoomLevel )
			return true;
		else
			return false;
	}
	*/
	function EndZoomHandler( mapEvent )
	{
		var e_zoom = mapEvent.zoomLevel;
		if( e_zoom > maxZoomLevel )
		{
			//alreadyZooming = true;
			map.SetZoomLevel( maxZoomLevel );
		}
	}
	
	function GetTiles()
	{
		var bounds = null;

		var tileSourceSpec = new VETileSourceSpecification("DirectBandCoverage", tileServerDirectory+"/%4-baked.PNG");
		tileSourceSpec.NumServers = 1;
		tileSourceSpec.Bounds = bounds;
		tileSourceSpec.MinZoomLevel = 0;
		tileSourceSpec.MaxZoomLevel = 10;
		//tileSourceSpec.Opacity = 0.65;
		tileSourceSpec.ZIndex = 100;

		map.AddTileLayer(tileSourceSpec, false);
		map.ShowTileLayer("DirectBandCoverage");
	}
	
	
	function Find()
	{
		var where = document.getElementById('coverageMapSearchWhereQueryBox').value;
		if( where == null || where == "")
			return;
		//var where = "98115";
		map.Find("", where, null, null, null, null, null, false, null, null, null);
	}


	function FindSelected(id)
	{
	    var ctrl = document.getElementById(id);
	    if (ctrl != null)
	    {
	        var where = ctrl.options[ctrl.selectedIndex].text;

	        if ("Alberta,British Columbia,Manitoba,Ontario,Quebec".indexOf(where) != -1)
	            where += ", CANADA";
	        else if ("Washington".indexOf(where) != -1)
	            where = "Seattle, USA";	        
	        else	            
	            where += ", USA";

	        map.Find("", where, null, null, null, 1, true, false, false, false, FindCallBack);
	    }
	}



	function FindCallBack(layer, resultsArray, places, hasMore, veErrorMessage) {
	    if (places != null && places.length != 0) {
	        var vePlace = places[0];
	        var zoomLevel = 6;

	        if ("Alberta,British Columbia,Manitoba,Ontario,Quebec".indexOf(vePlace.Name) != -1)
	            zoomLevel = 5;
	        if ("Alaska".indexOf(vePlace.Name) != -1)
	            zoomLevel = 4;

	        map.SetCenterAndZoom(vePlace.LatLong, zoomLevel);
	    }	    
	}