function Map()
{
	var self = this;
	
	// properties
	this.Units = "METERS"; // Needed for calculating distance, scale, etc.
	this.Projection = "VALAM"; // projection of the map.  VALAM - VDOT Lambert, VAS - Virginia South...
	this.MapLeft;
	this.MapTop;
	this.MapWidth;
	this.MapHeight;
	this.XmlReqMap; // XMLHttpRequest object used to request the map images
	this.Scale;
	this.ActiveLayer = 32; // maintain active layer position number
	this.ExtentArray = new Array(); // Array of Extent objects
	this.ExtentIndex = 0;
	this.AcetatePoints = new Array(); // Array of Points to place on the acetate layer
	this.FromUserAction;
	
	// methods
	this.getMap = getMap;
	this.zoomToFeature = zoomToFeature;
	this.getFirstMap = getFirstMap;
	this.processGetMap = processGetMap;
	this.processAdjoinersGetMap = processAdjoinersGetMap;
	this.getAdjoiningFeaturesMap = getAdjoiningFeaturesMap;
	this.processFirstGetMap = processFirstGetMap;
	this.refreshMap = refreshMap;
	this.updateCoords = updateCoords;
	this.getMinX = getMinX;
	this.getMinY = getMinY;
	this.getMaxX = getMaxX;
	this.getMaxY = getMaxY;
	this.setMinX = setMinX;
	this.setMinY = setMinY;
	this.setMaxX = setMaxX;
	this.setMaxY = setMaxY;
	this.getLastMap = getLastMap;
	this.getNextMap = getNextMap;
	this.zoomToFullExtent = zoomToFullExtent;
	this.getAcetatePoints = getAcetatePoints;
	this.updateMap = updateMap;
	this.toMapPoint = toMapPoint;
	this.panNorth = panNorth;
	this.panSouth = panSouth;
	this.panWest = panWest;
	this.panEast = panEast;
	this.doTrans = doTrans;
	
	function getMap(command, mapx1, mapy1, mapx2, mapy2, fromUserAction)
	{
		showLoading();
		//updateCoords(mapx1, mapy1, mapx2, mapy2);
		self.FromUserAction = fromUserAction;
		checkVisScale();
		//url = server + "MapService.asmx/ProcessMap?command=" + command + "&imageWidth=" + map.MapWidth + "&imageHeight=" + map.MapHeight + "&x1=" + mapx1 + "&y1=" + mapy1 + "&x2=" + mapx2 + "&y2=" + mapy2 + "&layers=" + getVisibleLayerString() + "&showNorthArrow=true&acetatePoints=" + self.getAcetatePoints() + "&spatialQuery=";
		self.XmlReqMap = new TXmlHttp();
		//document.write(url);
		if(self.XmlReqMap)
		{
			self.XmlReqMap.onreadystatechange = processGetMap;
			url = server + "MapService.asmx/ProcessMap"; 
			self.XmlReqMap.open("POST", url, true); //async call
			self.XmlReqMap.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			var vars = "userGroup=" + user.userGroupName + "&command=" + command + "&imageWidth=" + map.MapWidth + "&imageHeight=" + map.MapHeight + "&x1=" + mapx1 + "&y1=" + mapy1 + "&x2=" + mapx2 + "&y2=" + mapy2 + "&layers=" + getVisibleLayerString() + "&showNorthArrow=true&acetatePoints=" + self.getAcetatePoints() + "&spatialQuery=";
			self.XmlReqMap.send(vars);

		}
		
		
	}
	
	function getAdjoiningFeaturesMap(objectId)
	{
		//updateCoords(self.getMinX(), self.getMinY(), self.getMaxX(), self.getMaxY(), true);
		//calcScale();
		self.FromUserAction = true;
		checkVisScale();
		
		//url = server + "MapService.asmx/ProcessMap?command=ADJOINERS&imageWidth=" + map.MapWidth + "&imageHeight=" + map.MapHeight + "&x1=" + self.getMinX() + "&y1=" + self.getMinY() + "&x2=" + self.getMaxX() + "&y2=" + self.getMaxY() + "&layers=" + getVisibleLayerString() + "&showNorthArrow=true&acetatePoints=" + self.getAcetatePoints() + "&spatialQuery=";
		self.XmlReqMap = new TXmlHttp();
		
		if(self.XmlReqMap)
		{
			self.XmlReqMap.onreadystatechange = processAdjoinersGetMap;
			url = server + "MapService.asmx/ProcessMap"; 
			self.XmlReqMap.open("POST", url, true); //async call
			self.XmlReqMap.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			var vars = "userGroup=" + user.userGroupName + "&command=" + command + "&imageWidth=" + map.MapWidth + "&imageHeight=" + map.MapHeight + "&x1=" + mapx1 + "&y1=" + mapy1 + "&x2=" + mapx2 + "&y2=" + mapy2 + "&layers=" + getVisibleLayerString() + "&showNorthArrow=true&acetatePoints=" + self.getAcetatePoints() + "&spatialQuery=";
			self.XmlReqMap.send(vars);
		}
	}
	
	function updateMap()
	{
		self.getMap("ZOOMIN", self.getMinX(), self.getMinY(), self.getMaxX(), self.getMaxY(), true);
	}
	
	function zoomToFeature(mapx1, mapy1, mapx2, mapy2, flayer)
	{
		var zoomTol = 100;
		
		// this is a point feature, add the buffer to the envelope
		if( (mapx1 == mapx2) && (mapy1 == mapy2) )
		{
			zoomTol = zoomTolerance;
			var x = mapx1;
			var y = mapy1;
			
			mapx1 = x - parseFloat(zoomTol);
			mapy1 = y - parseFloat(zoomTol);
			mapx2 = parseFloat(x) + parseFloat(zoomTol);
			mapy2 = parseFloat(y) + parseFloat(zoomTol);
		}
		else
		{
			mapx1 = mapx1 - parseFloat(zoomTol);
			mapy1 = mapy1 - parseFloat(zoomTol);
			mapx2 = parseFloat(mapx2) + parseFloat(zoomTol);
			mapy2 = parseFloat(mapy2) + parseFloat(zoomTol);
		
		}
		

	
		showLoading();
		//updateCoords(mapx1, mapy1, mapx2, mapy2, true);
		self.FromUserAction = true;
		calcScale();
		//url = server + "MapService.asmx/ProcessMap?command=ZOOMIN&imageWidth=" + map.MapWidth + "&imageHeight=" + map.MapHeight + "&x1=" + mapx1 + "&y1=" + mapy1 + "&x2=" + mapx2 + "&y2=" + mapy2 + "&layers=" + getVisibleLayerString() + "&showNorthArrow=true&acetatePoints=" + self.getAcetatePoints() + "&spatialQuery=";
		self.XmlReqMap = new TXmlHttp();
		
		spatialFilter = new SpatialFilter();
		spatialFilter.Points = "";
		
		var x = 0;
		var y = 0;
		if( mapx1 > mapx2)
		    x = parseFloat(mapx2) + parseFloat((mapx1 - mapx2)/2);
		else
		    x = parseFloat(mapx1) + parseFloat((mapx2 - mapx1)/2);
		if(mapy1 > mapy2)
		    y = parseFloat(mapy2) + parseFloat((mapy1 - mapy2)/2);
		else
		    y = parseFloat(mapy1) + parseFloat((mapy2-mapy1)/2);
		  
		spatialFilter.Points += x + "," + y + ",";
		spatialFilter.Points += (x + 1) + "," + y + ",";
		spatialFilter.Points += x + "," + (y + 1) + ",";        
		if( flayer) 
	    {
		    var layer;
    		
		    for( var i = 0; i < layerArray.length; i++ )
		    {
			    layer = layerArray[i];
    			
			    if( layer.Name == flayer )
			    {
				    // set that spatial filter object's "type" and "points"
				    spatialFilter.Points = spatialFilter.Points.substr(0, spatialFilter.Points.lastIndexOf(','));
    				
				    spatialFilter.Type = "Polygon";
    					
				    layer.SpatialFilter = spatialFilter;
				    break;
			    }
		    }
	    }
		
		if(self.XmlReqMap)
		{
			self.XmlReqMap.onreadystatechange = processGetMap;
			url = server + "MapService.asmx/ProcessMap"; 
			self.XmlReqMap.open("POST", url, true); //async call
			self.XmlReqMap.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			var vars = "userGroup=" + user.userGroupName+ "&command=ZOOMIN" + "&imageWidth=" + map.MapWidth + "&imageHeight=" + map.MapHeight + "&x1=" + mapx1 + "&y1=" + mapy1 + "&x2=" + mapx2 + "&y2=" + mapy2 + "&layers=" + getVisibleLayerString() + "&showNorthArrow=true&acetatePoints=" + self.getAcetatePoints() + "&spatialQuery=";
			self.XmlReqMap.send(vars);
		}
		
		activateMapTab(0);
	}
	
	function getFirstMap()
	{
		showLoading();
		// attempt to pull type/query from hidden textboxes on default.aspx page
		// this would happen if params were passed to the application to load 
		// only a certain set of layers to begin with
		var type = document.getElementById("type");
		var query = document.getElementById("query");
		var vars = "command=REFRESH&imageWidth=" + map.MapWidth + "&imageHeight=" + map.MapHeight + "&x1=0&y1=0&x2=0&y2=0";
		
		if( (type != null && type.value != "") && (query != null && query.value != "") )
		{
			if( type.value == 'layer' )
				url += "&layers=" + query.value;
		}
		else
		{
			url += "&layers=";
		}
		
		url += "&showNorthArrow=true&acetatePoints=" + self.getAcetatePoints() + "&spatialQuery=";
		
		self.XmlReqMap = new TXmlHttp();
		
		if(self.XmlReqMap)
		{
			self.XmlReqMap.onreadystatechange = processFirstGetMap();
			url = server + "MapService.asmx/ProcessMap"; 
			self.XmlReqMap.open("POST", url, true); //async call
			self.XmlReqMap.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			//var vars = "command=" + command + "&imageWidth=" + map.MapWidth + "&imageHeight=" + map.MapHeight + "&x1=" + mapx1 + "&y1=" + mapy1 + "&x2=" + mapx2 + "&y2=" + mapy2 + "&layers=" + getVisibleLayerString() + "&showNorthArrow=true&acetatePoints=" + self.getAcetatePoints() + "&spatialQuery=";
			self.XmlReqMap.send(vars);
		}
	}

	function processGetMap()
	{
		if(self.XmlReqMap.readyState == 4)
		{
			if(self.XmlReqMap.status == 200)
			{
				refreshMap(self.XmlReqMap.responseXML.documentElement, true);
			}
		}
	}
	
	function processAdjoinersGetMap()
	{
		if(self.XmlReqMap.readyState == 4)
		{
			if(self.XmlReqMap.status == 200)
			{
				refreshMap(self.XmlReqMap.responseXML.documentElement, false);
			}
		}
	}
	
	function processFirstGetMap()
	{	
		if(self.XmlReqMap.readyState == 4)
		{
			if(self.XmlReqMap.status == 200)
			{
				refreshMap(self.XmlReqMap.responseXML.documentElement, true);
				
				var layer = new Layer();
				layer.loadLayerList();
			}
		}
	}

    function refreshMap(response, doTurnOffLoading, check)
	{
	    
		try
		{
			self.mapUrl = response.getElementsByTagName('mapUrl')[0].firstChild.data;
			self.oldMapUrl = mapImage.src;
			var legendUrl = response.getElementsByTagName('legendUrl')[0].firstChild.data;
			
			updateCoords(response.getElementsByTagName('minX')[0].firstChild.data, response.getElementsByTagName('minY')[0].firstChild.data, response.getElementsByTagName('maxX')[0].firstChild.data, response.getElementsByTagName('maxY')[0].firstChild.data, self.FromUserAction);
			calcScale();
			checkVisScale();
			try{
			    
				var intMapScale = map.Scale;
				intMapScale = parseInt(map.Scale);
				if(map.Scale != intMapScale){
					intMapScale++;
				
				}
				
				//if(s.getMaximum() < intMapScale){
			//		s.setMaximum(intMapScale);
			//	}
				//document.getElementById("sliderMax_TextCell").innerHTML = "" + s.getMaximum();
			}
			catch(e){
				alert(e);
			}
			
			//s.setValue(map.Scale);
			
            
			// get legend html element
			var imgLegend = document.getElementById('legendImage');
			
			if(browser.isInternetExplorer())//no fade in
			{				
				
				//mapImage.src = self.mapUrl;
				divMapImage.innerHTML = divMapImage.innerHTML.replace("mapImage", "mapImage2");
				var h = divMapImage.innerHTML;
				divMapImage.innerHTML += "<img id=\"mapImage\" src=\"" + self.mapUrl + "\" style=\"position:absolute;top:0px;left:0px;width:" + self.MapWidth + ";height:" + self.MapHeight + ";\" onmousemove=\"return false;\">";
			    //alert("1");		    
			    doTrans();
			    //alert("2");
			    document.getElementById("divMapImage").removeChild(document.getElementById("mapImage2"));
			    //alert("3");
			    //divMapImage.innerHTML = divMapImage.innerHTML.replace(h, "");
				//alert(divMapImage.innerHTML);
			}
			else
				divMapImage.innerHTML = "<img id=\"mapImage\" src=\"" + self.mapUrl + "\" style=\"position:absolute;top:0px;left:0px;width:" + self.MapWidth + ";height:" + self.MapHeight + ";\" onmousemove=\"return false;\">";
			// set map image to the url
			//divMapImage.innerHTML = "<img id=\"mapImage\" src=\"" + mapUrl + "\" style=\"position:absolute;top:0px;left:0px;width:" + self.MapWidth + ";height:" + self.MapHeight + ";\" onmousemove=\"return false;\">";
			imgLegend.src = legendUrl;
			
			// must update the PRINT url on the screen
			document.getElementById("printminX").value = map.getMinX();
			document.getElementById("printminY").value = map.getMinY();
			document.getElementById("printmaxX").value = map.getMaxX();
			document.getElementById("printmaxY").value = map.getMaxY();
			document.getElementById("printvisibleLayers").value = getVisibleLayerString();
			document.getElementById("printacetatePoints").value = map.getAcetatePoints();
			//print.href = "print.aspx?minX=" + map.getMinX() + "&minY=" + map.getMinY() + "&maxX=" + map.getMaxX() + "&maxY=" + map.getMaxY() + "&layers=" + getVisibleLayerString() + "&acetatePoints=" + map.getAcetatePoints();
			
			
			// must update the EXPORT url on the screen
			//var exportLink = document.getElementById("exportUrl");
			//exportLink.href = "export.aspx?minX=" + map.getMinX() + "&minY=" + map.getMinY() + "&maxX=" + map.getMaxX() + "&maxY=" + map.getMaxY() + "&layers=" + getVisibleLayerString() + "&acetatePoints=" + map.getAcetatePoints();
			document.getElementById("exportminX").value = map.getMinX();
			document.getElementById("exportminY").value = map.getMinY();
			document.getElementById("exportmaxX").value = map.getMaxX();
			document.getElementById("exportmaxY").value = map.getMaxY();
			document.getElementById("exportvisibleLayers").value = getVisibleLayerString();
			document.getElementById("exportacetatePoints").value = map.getAcetatePoints();
			
			self.mapLoaded = true;
		}
		catch(e)
		{
		    //alert(e);
			alert("System temporarily unavailable.  Please try your request again shortly.");
		}
		
		// disable loading div
		if( doTurnOffLoading )
			loading.style.visibility = "hidden";
	}

	/*function refreshMap(response, doTurnOffLoading)
	{
		try
		{
			var mapUrl = response.getElementsByTagName('mapUrl')[0].firstChild.data;
			var oldMapUrl = mapImage.src;
			var legendUrl = response.getElementsByTagName('legendUrl')[0].firstChild.data;
			
			updateCoords(response.getElementsByTagName('minX')[0].firstChild.data, response.getElementsByTagName('minY')[0].firstChild.data, response.getElementsByTagName('maxX')[0].firstChild.data, response.getElementsByTagName('maxY')[0].firstChild.data, self.FromUserAction);
			
			calcScale();
			
			checkVisScale();
			
			/*try{
				var intMapScale = map.Scale;
				intMapScale = parseInt(map.Scale);
				if(map.Scale != intMapScale){
					intMapScale++;
				}
				if(s.getMaximum() < intMapScale){
					s.setMaximum(intMapScale);
				}
				document.getElementById("sliderMax_TextCell").innerHTML = "" + s.getMaximum();
			}
			catch(e){
				;
			}
			s.setValue(map.Scale);
			//zs.setCurrent();
			
			
			// get legend html element
			var imgLegend = document.getElementById('legendImage');
			
			// set map image to the url
			if(browser.isInternetExplorer())
			{	
			   
				var image = new Image();
				
				image.src = mapUrl;
				
				while(!image.complete)
				{
				  ;
				}
				
				doTrans(oldMapUrl,mapUrl);
				
			}
			else
				divMapImage.innerHTML = "<img id=\"mapImage\" src=\"" + mapUrl + "\" style=\"position:absolute;top:0px;left:0px;width:" + self.MapWidth + ";height:" + self.MapHeight + ";\" onmousemove=\"return false;\">";
			
			imgLegend.src = legendUrl;
			
			// must update the PRINT url on the screen
			document.getElementById("printminX").value = map.getMinX();
			document.getElementById("printminY").value = map.getMinY();
			document.getElementById("printmaxX").value = map.getMaxX();
			document.getElementById("printmaxY").value = map.getMaxY();
			document.getElementById("printvisibleLayers").value = getVisibleLayerString();
			document.getElementById("printacetatePoints").value = map.getAcetatePoints();
			//print.href = "print.aspx?minX=" + map.getMinX() + "&minY=" + map.getMinY() + "&maxX=" + map.getMaxX() + "&maxY=" + map.getMaxY() + "&layers=" + getVisibleLayerString() + "&acetatePoints=" + map.getAcetatePoints();
			/*var overbox = document.getElementById("box");
		    var overleft = 18;
		    var overtop = 15;
    		
		    var overminx = 11175868.5759763;
		    var overminy = 3709653.6932789;
		    var overmaxx = 11550536.4988771;
		    var overmaxy = 3909476.58549269;
		    var overdx = overmaxx - overminx;
		    var overdy = overmaxy - overminy;
		    
		    var unitsperpixel = overdx/105;
		    var minx = 0;
		    var miny = 0;
		    var maxx = 0;
		    var maxy = 0;
		    
		    if(response.getElementsByTagName('minX')[0].firstChild.data < overminx)
		        minx = overminx;
		    else
		        minx = response.getElementsByTagName('minX')[0].firstChild.data;
 
		    if(response.getElementsByTagName('minY')[0].firstChild.data < overminy)
		        miny = overminy;
		    else
		        miny = response.getElementsByTagName('minY')[0].firstChild.data;
		        		    
		    if(response.getElementsByTagName('maxX')[0].firstChild.data > overmaxx)
		        maxx = overmaxx;
		    else
		        maxx = response.getElementsByTagName('maxX')[0].firstChild.data;

            if(response.getElementsByTagName('maxY')[0].firstChild.data > overmaxy)
		        maxy = overmaxy;
		    else
		        maxy = response.getElementsByTagName('maxY')[0].firstChild.data;	
		        
		    if(response.getElementsByTagName('maxY')[0].firstChild.data < overminy)
		        maxy = overminy;
		    if(response.getElementsByTagName('maxX')[0].firstChild.data < overminx)
		        maxx = overminx;
		    if(response.getElementsByTagName('minY')[0].firstChild.data > overmaxy)
		        miny = overmaxy;
		    if(response.getElementsByTagName('minX')[0].firstChild.data > overmaxx)
		        minx = overmaxx;	    
		    
		    var offsety = miny - overminy;
		    var offsetx = minx - overminx;
		    var offsetx2 = maxx - overminx;
		    var offsety2 = maxy - overminy;
		    
		   
		    
		    overbox.style.display = "block";
		    overbox.style.lineHeight = 2;
		    overbox.style.fontSize = 1;
		    //alert(offsety + " "  + offsetx + " " + offsety2 + " " + offsetx2);
		    overbox.style.bottom = parseInt(offsety/unitsperpixel + overtop);
		    overbox.style.left = parseInt(offsetx/unitsperpixel + overleft);
		    overbox.style.height = parseInt((offsety2 - offsety)/unitsperpixel);
		    overbox.style.width = parseInt((offsetx2-offsetx)/unitsperpixel);
		    //alert(overbox.style.height + " " + overbox.style.width);
		    
		    if(parseInt(overbox.style.width) >15 || parseInt(overbox.style.height) >15)
		    {
		        overbox.style.backgroundColor = "";
		        overbox.style.borderWidth = 2;
		        //overbox.style.width = parseInt(overbox.style.width) - 4;
		        //overbox.style.height = parseInt(overbox.style.height) - 4;
		        //overbox.style.left = parseInt(overbox.style.left) + 2;
		        //overbox.style.bottom = parseInt(overbox.style.bottom) + 2;
		        //alert("hi");
		    }
		    else
		    {
		        overbox.style.borderWidth = 0;
		        overbox.style.backgroundColor = "#E98003";
		        //alert(overbox.style.backgroundColor);
		    }
		    if(parseInt(overbox.style.width) < 4 || parseInt(overbox.style.height) < 4)
		    {
		        overbox.style.height = 2;
		        //overbox.style.display = "none";
		        overbox.style.width = 2;
		        //alert("height: " + overbox.style.height + " width: " + overbox.style.width);
		    }
		    
		    //alert(overdx/105 + " " + overdy/56);
		    
    		//response.getElementsByTagName('minX')[0].firstChild.data, response.getElementsByTagName('minY')[0].firstChild.data, response.getElementsByTagName('maxX')[0].firstChild.data, response.getElementsByTagName('maxY')[0].firstChild.data
    		/*alert(response.getElementsByTagName('minY')[0].firstChild.data);
    		alert(response.getElementsByTagName('maxY')[0].firstChild.data);
		    var pixelminx = (Math.abs(overminx - response.getElementsByTagName('minX')[0].firstChild.data) / overdx) * 105;
		    var pixelminy = (Math.abs(overminy - response.getElementsByTagName('minY')[0].firstChild.data) / overdy) * 56;
		    var pixelmaxx = (Math.abs(overminx - response.getElementsByTagName('maxX')[0].firstChild.data) / overdx) * 105;
		    var pixelmaxy = (Math.abs(overminy - response.getElementsByTagName('maxY')[0].firstChild.data) / overdy) * 56;
		    
		    var xunitspixel = (overmaxx - overminx) / 105;
		    var yunitspixel = (overmaxy - overminy) / 56;
		    //alert(yunitspixel);
		    //alert(xunitspixel);
		    var yloc = parseInt((map.getMinY() - overminy) / yunitspixel);
		    var xloc = parseInt((map.getMinX() - overminx) / xunitspixel);
		    var y2loc = parseInt((overmaxy - map.getMaxY()) / yunitspixel);
		    var x2loc = parseInt((overmaxx - map.getMaxX()) / xunitspixel);
		    alert(y2loc + " " + yloc);
		    alert(x2loc + " " + xloc);
		    alert(pixelminx + " " + pixelmaxx);
		    alert(pixelminy + " " + pixelmaxy);
    		//alert(Math.abs(y2loc - yloc));
    		//alert(Math.abs(x2loc - xloc));
		    //alert(pixelminx + " " + pixelminy + " " + pixelmaxx + " " + pixelmaxy);
    		
		    
	        //overbox.style.height = 0;
	        //overbox.style.width = 0;
	        overbox.style.display = "block";
	        //overbox.style.zIndex = 99;
	        //overbox.style.left = overtop + xloc;
	        //overbox.style.bottom = overleft + yloc;
	        overbox.style.bottom = parseInt(56 + overtop - pixelminx - pixelmaxy);
	        overbox.style.left = parseInt(Math.abs(pixelminx + overleft));
	        alert(overbox.style.left);
	        //alert(pixelminx - pixelmaxx);
	        //alert(pixelminy - pixelmaxy);
	        /*if(y2loc >= yloc)
	            overbox.style.height = Math.abs(y2loc - yloc);
	         else
	            overbox.style.height = Math.abs(yloc + y2loc)
	         if(x2loc >= xloc)
	            overbox.style.width = Math.abs(x2loc - xloc);
	         else
	            overbox.style.width = Math.abs(xloc - x2loc);
	        //alert("!2");
	        alert(overbox.style.height);
	        overbox.style.width = parseInt(pixelmaxx - pixelminx);
    		overbox.style.height = parseInt(pixelmaxy - pixelminy);  
		    
		    //alert(this.Scale);
			
			// must update the EXPORT url on the screen
			//var exportLink = document.getElementById("exportUrl");
			//exportLink.href = "export.aspx?minX=" + map.getMinX() + "&minY=" + map.getMinY() + "&maxX=" + map.getMaxX() + "&maxY=" + map.getMaxY() + "&layers=" + getVisibleLayerString() + "&acetatePoints=" + map.getAcetatePoints();
			
			document.getElementById("exportminX").value = map.getMinX();
			document.getElementById("exportminY").value = map.getMinY();
			document.getElementById("exportmaxX").value = map.getMaxX();
			document.getElementById("exportmaxY").value = map.getMaxY();
			document.getElementById("exportvisibleLayers").value = getVisibleLayerString();
			document.getElementById("exportacetatePoints").value = map.getAcetatePoints();
			
			mapLoaded = true;
		}
		catch(e)
		{
			alert("System temporarily unavailable.  Please try your request again shortly.");
		}
		
		// disable loading div
		if( doTurnOffLoading )
			loading.style.visibility = "hidden";
	}*/
	
	function doTrans()
	{        
        divMapImage.filters[0].apply();  
        //mapImage.src = endImage;
        mapImage.style["position"] = "absolute";
        mapImage.style["top"] = "0px";
        mapImage.style["left"] = "0px";
        mapImage.style.width = self.MapWidth;
        mapImage.style.height = self.MapHeight;
        mapImage2.onmousemove = function(){return false;};
        divMapImage.filters[0].play();
        
        
	}
	
	/*function doTrans(startImage, endImage)
	{        
        divMapImage.filters[0].apply();
        if (mapImage.src.indexOf(startImage)!=-1) {
            mapImage.src = endImage;
            mapImage.style["position"] = "absolute"
            mapImage.style["top"] = "0px";
            mapImage.style["left"] = "0px";
            mapImage.style.width = self.MapWidth;
            mapImage.style.height = self.MapHeight;
            mapImage.onmousemove = function(){return false;};
        }
        divMapImage.filters[0].play();
	}*/

	function updateCoords(mapx1, mapy1, mapx2, mapy2, fromUserAction)
	{
		var ext = new Extent();
		ext.MinX = mapx1;
		ext.MinY = mapy1;
		ext.MaxX = mapx2;
		ext.MaxY = mapy2;
		
		// false if trying to view next or last map in memory
		if( fromUserAction )
		{
			// use current index as starting point
			// delete all other elements in array after this point
			
			self.ExtentIndex++;
			self.ExtentArray[self.ExtentIndex] = ext;
			
			self.ExtentArray.splice(self.ExtentIndex + 1, self.ExtentArray.length - 1);
		}
		else
		{
		    
			self.ExtentArray[self.ExtentIndex] = ext;
		}
		//zs.setCurrent();
	}
	
	function getMinX() { return self.ExtentArray[self.ExtentIndex].MinX; }	
	function getMinY() { return self.ExtentArray[self.ExtentIndex].MinY; }	
	function getMaxX() { return self.ExtentArray[self.ExtentIndex].MaxX; }	
	function getMaxY() { return self.ExtentArray[self.ExtentIndex].MaxY; }
	function setMinX(pt) { self.ExtentArray[self.ExtentIndex].MinX = pt; }	
	function setMinY(pt) { self.ExtentArray[self.ExtentIndex].MinY = pt; }	
	function setMaxX(pt) { self.ExtentArray[self.ExtentIndex].MaxX = pt; }
	function setMaxY(pt) { self.ExtentArray[self.ExtentIndex].MaxY = pt; }
	
	function getNextMap()
	{
		var ext = self.ExtentArray[self.ExtentIndex + 1];
		
		if( ext != null )
		{
			self.ExtentIndex++;
			getMap("MAP_FORWARD", ext.MinX, ext.MinY, ext.MaxX, ext.MaxY, false);
		}
	}
	
	function getLastMap()
	{	
		var ext = self.ExtentArray[self.ExtentIndex - 1];
		
		if( ext != null )
		{
			self.ExtentIndex--;
			getMap("MAP_BACK", ext.MinX, ext.MinY, ext.MaxX, ext.MaxY, false);
		}
	}
	
	function zoomToFullExtent()
	{
		var ext = self.ExtentArray[0];
		
		if( ext != null )
			getMap("REFRESH", ext.MinX, ext.MinY, ext.MaxX, ext.MaxY, true);
	}
	
	function getAcetatePoints()
	{
		// take self.AcetatePoints Array and convert to string
		// output: label,x,y|label,x,y|...
		var finalString = "";
		
		for( var i = 0; i < self.AcetatePoints.length; i++ )
		{
			var point = self.AcetatePoints[i];
			finalString += point.getLabel() + "," + point.getX() + "," + point.getY() + "|";
		}
		
		// remove last | from string
		finalString = finalString.substr(0, finalString.lastIndexOf('|'));
		
		return finalString;
	}
	
	function toMapPoint(pixelX, pixelY)
	{

		xPx = (map.getMaxX() - map.getMinX()) / map.MapWidth;//units/pixel
		yPx = (map.getMaxY() - map.getMinY()) / map.MapHeight;//units/pixel
		
		mapX = (pixelX * xPx) + parseFloat(map.getMinX());
		mapY = (map.MapHeight - pixelY) * yPx + parseFloat(map.getMinY());
		
		var arrPt = new Array();
		arrPt[0] = mapX;
		arrPt[1] = mapY;
		
		//alert("OUTPUT\nmapX: " + mapX + "\nmapY: " + mapY);
		return arrPt;
	}
	function panNorth()
	{
		var shift = (map.getMaxY() - map.getMinY()) * 0.3;
		
		var minY = parseFloat(map.getMinY()) + shift;
		var maxY = parseFloat(map.getMaxY()) + shift;
		var minX = map.getMinX();
		var maxX = map.getMaxX();
		
		map.getMap("ZOOMIN", minX, minY, maxX ,maxY, true);		
		
	}
	
	function panSouth()
	{
		var shift = (map.getMaxY() - map.getMinY()) * 0.3;
		
		var minY = parseFloat(map.getMinY()) - shift;
		var maxY = parseFloat(map.getMaxY()) - shift;
		var minX = map.getMinX();
		var maxX = map.getMaxX();
		
		map.getMap("ZOOMIN", minX, minY, maxX ,maxY, true);
	}
	
	function panEast()
	{
		var shift = (map.getMaxX() - map.getMinX()) * 0.3;
			
		var minY = map.getMinY();
		var maxY = map.getMaxY();
		var minX = parseFloat(map.getMinX()) + shift;
		var maxX = parseFloat(map.getMaxX()) + shift;	
		
		map.getMap("ZOOMIN", minX, minY, maxX ,maxY, true);	
	}
	
	function panWest()
	{
		var shift = (map.getMaxX() - map.getMinX()) * 0.3;
			
		var minY = map.getMinY();
		var maxY = map.getMaxY();
		var minX = parseFloat(map.getMinX()) - shift;
		var maxX = parseFloat(map.getMaxX()) - shift;	
		
		map.getMap("ZOOMIN", minX, minY, maxX ,maxY, true);	
	
	}

	
}