// aimsImage.js
/*
*  JavaScript template file for ArcIMS HTML Viewer
*
*/


/*
************************************************************************

Functions for responsing image tool bar

************************************************************************
*/

///for aerial image polygon layervar useImage=true;var imageActive=false;var pre_active_indx=ActiveLayerIndex;

function Start_Image_Tool()
{
		panning=false;
		zooming=false;
		selectBox=false;
		shapeSelectBuffer = false;
		
		//setup the toolmode 
		if (canQuery) 
		{
			toolMode = 44;	
			if (isIE)	
			{
				document.all.theTop.style.cursor = "crosshair";
				theCursor = document.all.theTop.style.cursor;
			}
			modeBlurb = modeList[3];
		} 
		else 
		{
			alert("Show Images disabled");
		}
		showGeocode=false;
		//if (useTextFrame) parent.TextFrame.document.location= appDir + "text.htm";	
		hideLayer("measureBox");
}

//for identify images
function identifyImage(e)
{
		//alert("activelayerindex="+ActiveLayerIndex);
		//set the active layer
		for (var j=0; j<parent.MapFrame.LayerID.length; j++)
		{
			//alert("identifyImage-- layerID = "+parent.MapFrame.LayerID[j]);
			if (parent.MapFrame.LayerID[j]=="Aerial Image")
			{
				//alert("identifyImage-- layerID = "+parent.MapFrame.LayerID[j]);
				//alert("identifyImage-- j = "+ j );
				parent.MapFrame.setActiveLayer(j);
				//alert("identifyImage-- setActiveLayer = "+parent.MapFrame.setActiveLayer(j));
				imageActive=true;
			}
		}
		
		//alert("activelayerindex="+ActiveLayerIndex);
		
		highlightedOne="";
		var theX = mouseX;
		var theY = mouseY;
		getMapXY(theX,theY);
			
		searchTolerance = (xDistance/iWidth) * pixelTolerance;
		//alert("searchTolerance="+searchTolerance);
		var tempWest = mapX - searchTolerance;
		var tempNorth = mapY + searchTolerance;
		var tempEast = mapX + searchTolerance;
		var tempSouth = mapY - searchTolerance;
		
		
		queryStartRecord=1;
		selectEnvelope='maxy="' + forceComma(tempNorth) + '" maxx="' + forceComma(tempEast) + '" miny="' + forceComma(tempSouth) + '" minx="' + forceComma(tempWest) + '"';
		selectionMode=2;
		var theString = writeGetFeatures(tempWest,tempSouth,tempEast,tempNorth);
		//alert ("theString="+theString);
		
		showRetrieveData();
		// sent to image server as mode 7 		
		sendToServer(imsQueryURL,theString,7);

}

function displayAerialImageData(theReply)
{
	setLayerFields(ActiveLayerIndex);
	parent.TOCActive.location = "ShowActiveLayer.asp";
	var url = appDir + "displayAerialImageData.htm";
	if (useTextFrame) 
	{
		parent.TextFrame.document.location = url;
	} 
	else 
	{
		var Win1 = open(url,"DataWindow","width=575,height=250,scrollbars=yes,resizable=yes");
		extWin = Win1;
		focusOnData = true;
	}

}

function sendImageMapXML() {
	
	beforeMapRefresh();
	
	showRetrieveMap();
	
	
	xDistance = Math.abs(eRight-eLeft);
	yDistance = Math.abs(eTop-eBottom);
	var sFactor = xDistance / iWidth
	var theText = writeImageXML();
	if (debugOn==2) alert(msgList[12] + theText);
		sendToServer(imsURL,theText,1);
}

/*
// send the created xml request to map server
function sendImageMapXML() {
	
	beforeMapRefresh();
	//window.onerror=resetError;
	showRetrieveMap();
	var theText = writeImageXML();
	//alert("theText in sendImageXML.js: "+ theText.substr(theText.length/2, theText.length-1));
	if (debugOn==2) alert(msgList[12] + theText);
	
	parent.MapFrame.clearSelection();
	sendToServer(imsURL,theText,1);
	
}
*/
// prepare the request in xml format for Main Map
function writeImageXML() 
{
	var iMinx= forceComma(eLeft);
	var iMaxX = forceComma(eRight);
	var difXYDef = (startRight - startLeft);
	var difXYNew = (iMaxX - iMinx);
	if (webParams=="") {
		if  ((difXYNew>difXYDef)&&(parent.MapFrame.MultSelect)){
			eLeft = maxLimitLeft;
			eBottom =maxLimitBottom;
			eRight  =maxLimitRight;
			eTop = maxLimitTop;
		}
	}
	var theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_IMAGE>\n<PROPERTIES>\n<ENVELOPE minx="' + forceComma(eLeft) + '" miny="' + forceComma(eBottom) + '" maxx="' + forceComma(eRight) + '" maxy="' + forceComma(eTop) + '" />\n';
	theString += '<IMAGESIZE height="' + iHeight + '" width="' + iWidth + '" />\n';
	var visString = "";
	if (aimsLayersPresent) {
		// tell the server which layers are to be visible
		if (toggleVisible) {
			theString += '<LAYERLIST >\n';
			for (var i=0;i<layerCount;i++) {
				if (LayerVisible[i]==1) {
					theString += '<LAYERDEF id="' + LayerID[i] + '" visible="true" ';
					/*if (parent.MapFrame.bENT){
						if (aimsClassRenderPresent) {
							theString += addSpecialRenderToMap(i);
						} else {
							theString += '/>\n';
						}
					}else{
						theString += '/>\n';
					}*/
					
					if (LayerID[i]=='Parcels'){
						
							if (aimsClassRenderPresent) {
								//alert('bENT:  ' + parent.MapFrame.bENT);
								//alert('bENT:  ' + parent.MapFrame.bBRF);
								if ((parent.MapFrame.bENT)||(parent.MapFrame.bBRF)){
									theString += addSpecialRenderToMap(i);
								}else{
									theString += '/>\n';
								}
								
							} else {
								theString += '/>\n';
							}
					
					
					}else{
						theString += '/>\n';
					}		
				}
				else {
					theString += '<LAYERDEF id="' + LayerID[i] + '" visible="false" />\n';
				}
				
			}
			theString += '</LAYERLIST>\n';
		}
	}
	
	// map background color
	if (mapTransparent) {
		theString += '<BACKGROUND color="255,255,254" transcolor="255,255,254" />\n';
	} else {
		if (mapBackColor!="") {
			theString += '<BACKGROUND color="' + mapBackColor + '" />\n\n';
		}
	}
	if (aimsLegendPresent) {
		// create a legend image
		
		//if (legendVisible) theString += addLegendToMap();
		theString += addLegendToMap();
		//alert('theString:  ' + theString);
	}
	
	theString += '</PROPERTIES>\n';
	
	// buffer
	if (aimsBufferPresent) {
		if (showBuffer) theString += addBufferToMap();
	}
	
	// any custom stuff to fit here
	if (aimsCustomPresent) theString += addCustomToMap1();
	
	
	if (aimsClickPresent){
		// clickpoints 
		if (clickCount>0) {
			// draw click points and lines between them on map
			var clickColor = selectColor;
			if (clickType==1) clickColor = clickMarkerColor;
			theString += '<LAYER type="acetate" name="allTheClicks">\n';
			if (clickCount>1) {
				theString += '<OBJECT units="database">\n<LINE coords="' + forceComma(clickPointX[0]) + coordsDelimiter + forceComma(clickPointY[0]);
				for (var i=1;i<clickCount;i++) {
					theString += pairsDelimiter  + forceComma(clickPointX[i]) + coordsDelimiter + forceComma(clickPointY[i]); 
				}
				theString += '" >\n';
				theString += '<SIMPLELINESYMBOL type="solid" color="' + clickMarkerColor;
				theString += '" width="3" />\n</LINE>\n</OBJECT>\n'; 
				theString += '<OBJECT units="database">\n<LINE coords="' + forceComma(clickPointX[0]) + coordsDelimiter + forceComma(clickPointY[0]);
				for (var i=1;i<clickCount;i++) {
					theString += pairsDelimiter  + forceComma(clickPointX[i]) + coordsDelimiter + forceComma(clickPointY[i]); 
				}
				theString += '" >\n';
				theString += '<SIMPLELINESYMBOL type="solid" color="255,255,255" width="1" />\n</LINE>\n</OBJECT>\n'; 
	 		}
			for (var i=0;i<clickCount;i++) {
				theString += '<OBJECT units="database">\n<POINT coords="' + forceComma(clickPointX[i]) + coordsDelimiter + forceComma(clickPointY[i]) + '">\n';
				theString += '<SIMPLEMARKERSYMBOL  type="' + clickMarkerType + '"';
				theString += ' color="' + clickMarkerColor + '" width="' + clickMarkerSize + '" />\n</POINT>\n</OBJECT>\n';
			}
			theString += '</LAYER>\n';
		}
	}
	
	// route display - requires RouteServer extension
	if (aimsRoutePresent) {
		if (geocodeAppMode=="route") theString += addRouteToMapXML("");
	}
	
	// geocoding or point with label
	if (showGeocode) {
		// draw the point . . . also used to display any point with a label on map
		theString += '<LAYER type="acetate" name="GeoCode1">\n';
		theString += '<OBJECT units="database">\n<POINT coords="' + forceComma(geocodeX) + coordsDelimiter + forceComma(geocodeY) + '">\n';
		theString += '<SIMPLEMARKERSYMBOL  type="circle"  color="' + geocodePointColor + '" width="' + geocodePointSize +'" overlap="false" />\n</POINT></OBJECT>\n';
		if (geocodeLabel!="") {
			theString += '<OBJECT units="database">\n<TEXT coords="' + forceComma(geocodeX) + coordsDelimiter + forceComma(geocodeY) + '" label="' + geocodeLabel + '">\n';
			theString += '<TEXTMARKERSYMBOL fontcolor="' + geocodePointColor + '" fontsize="12" shadow="64,64,64" glowing="255,255,0" halignment="right" valignment="top" overlap="false" /></TEXT></OBJECT>\n';
		}
		theString += '</LAYER>\n';
		
	}
		
	// any custom stuff to fit here
	if (aimsCustomPresent) theString += addCustomToMap2();
	
	//add point location
	//********************************************
	//add point acetate layer
	theString +='<LAYER type="acetate" name="allTheClicks">\n';
	theString +='<OBJECT units="database">\n';
	theString +='<POINT coords="' + mapX +' '+mapY+'">\n';
	theString +='<SIMPLEMARKERSYMBOL type="cross" color="255,0,0" width="45" />\n';
	theString +='</POINT>\n';
	theString +='</OBJECT>\n';
	theString +='</LAYER>\n';
	//*********************************************

	if (drawBottomBar) {
		//alert('iWidth-1: ' + iWidth-1);
		theString += '<LAYER type="acetate" name="theBottomBar">\n';		
		theString += '<OBJECT units="pixel">\n<POLYGON ';
		theString += 'coords="0' + coordsDelimiter + '1' + pairsDelimiter;
		theString += '1' + coordsDelimiter + bottomBarHeight + pairsDelimiter;
		theString += (iWidth-1) + coordsDelimiter + bottomBarHeight + pairsDelimiter;
		theString += (iWidth-1) + coordsDelimiter + '1' + pairsDelimiter;
		theString += '0' + coordsDelimiter + '1">\n';
		theString += '<SIMPLEPOLYGONSYMBOL fillcolor="' + bottomBarColor + '" boundary="true" boundarycolor="' + bottomBarOutline + '" overlap="false" />\n';
		theString += '</POLYGON>\n</OBJECT>\n';
		theString += '</LAYER>\n';
	}

	if (drawCopyright) {
		// draw text on the map
		theString += '<LAYER type="acetate" name="theCopyright">\n';		
		theString += '<OBJECT units="pixel">\n<TEXT coords="' + CopyrightCoords + '" label="' + CopyrightText + '">\n';
		theString += '<TEXTMARKERSYMBOL fontstyle="' + CopyrightStyle + '" fontsize="' + CopyrightSize + '" ';
		if (CopyrightFont!="") theString += 'font="' + CopyrightFont + '" ';
		theString += 'fontcolor="' + CopyrightColor + '" antialiasing="True" ';
		//if (CopyrightBackground.toUpperCase()=="TRUE") theString += 'background="' + CopyrightBackground + '" backcolor="' + CopyrightBGColor + '" ';
		if (CopyrightBackground.toUpperCase()=="TRUE") theString += 'blockout="' + CopyrightBGColor + '" ';
		if (CopyrightShadow.toUpperCase()=="TRUE") theString += 'shadow="' + CopyrightShadowColor + '" ';
		theString += 'overlap="false" ';
		if (CopyrightGlow.toUpperCase()=="TRUE") theString += ' glowing="' + CopyrightGlowColor + '" ';
		theString += '/>\n</TEXT>\n</OBJECT>\n';
		theString += '</LAYER>\n';
	}
	if (drawNorthArrow) {
		// draw a north arrow
		theString += '<LAYER type="acetate" name="theNorthArrow">\n';
		theString += '<OBJECT units="pixel">\n<NORTHARROW type="' + NorthArrowType + '" size="' + NorthArrowSize + '" coords="' + NorthArrowCoords + '" shadow="32,32,32" ';
		theString += 'angle="' + NorthArrowAngle + '" antialiasing="True" overlap="False" />\n</OBJECT>\n';
		theString += '</LAYER>\n';
	}
	if (drawScaleBar) {
		// draw a scale bar
		//ScaleBarPrecision = numDecimals;
		theString += '<LAYER type="acetate" name="theScaleBar">\n';
		xDistance = eRight - eLeft;
		theString += '<OBJECT units="pixel">\n';
		theString += '<SCALEBAR ';
		
		if (drawScaleBar2) {
			theString += 'screenlength="' + parseInt(iWidth * (1/10)) + '" coords="' + (iWidth-((parseInt(iWidth * (4/10)))+20)) + coordsDelimiter + '3" ';
		} else {
			theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" coords="' + parseInt(iWidth * (6/10)) + coordsDelimiter + '3" ';
		}
		if (MapUnits=="DEGREES") theString += 'mode="geodesic" ';
		if (ScaleBarFont!="") theString += 'font="' + ScaleBarFont + '" ';
		theString += 'fontcolor="' + ScaleBarFontColor + '" fontstyle="' + ScaleBarStyle + '" barcolor="' + ScaleBarColor + '" ';
		if (MapUnits!="DEGREES") {
			theString += 'mapunits="' + MapUnits.toLowerCase() + '" ';
		}
		theString += 'scaleunits="' + ScaleBarUnits.toLowerCase() + '" antialiasing="True" ';
		var sDistance = getScaleBarDistance();
		if (MapUnits=="DEGREES") {
			if (xDistance<1/10){
				theString += 'precision="' + ScaleBarPrecision + '" ';
			}
		} else if (sDistance<5) {
			theString += 'precision="' + ScaleBarPrecision + '" ';
		}
		//theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" ';
		theString += 'fontsize="' + ScaleBarSize + '" barwidth="' + ScaleBarWidth + '" overlap="False"  ';
		//*/
		theString += '/>\n</OBJECT>\n';
		theString += '</LAYER>\n';	
		
	}
	if (drawScaleBar2) {
		// draw a scale bar
		//ScaleBarPrecision = numDecimals;
		theString += '<LAYER type="acetate" name="theScaleBar2">\n';
		xDistance = eRight - eLeft;
		theString += '<OBJECT units="pixel">\n';
		theString += '<SCALEBAR ';
		
		if (drawScaleBar) {
			theString += 'screenlength="' + parseInt(iWidth * (1/10)) + '" coords="' + (iWidth-((parseInt(iWidth * (2/10)))+10)) + coordsDelimiter + '3" ';
		} else {
			theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" coords="' + parseInt(iWidth * (6/10)) + coordsDelimiter + '3" ';
		}
		if (MapUnits=="DEGREES") theString += 'mode="geodesic" ';
		if (ScaleBar2Font!="") theString += 'font="' + ScaleBar2Font + '" ';
		theString += 'fontcolor="' + ScaleBar2FontColor + '" fontstyle="' + ScaleBar2Style + '" barcolor="' + ScaleBar2Color + '" ';
		if (MapUnits!="DEGREES") {
			theString += 'mapunits="' + MapUnits.toLowerCase() + '" ';
		}
		theString += 'scaleunits="' + ScaleBar2Units.toLowerCase() + '" antialiasing="True" ';
		var sDistance = getScaleBarDistance();
		if (MapUnits=="DEGREES") {
			if (xDistance<1/10){
				theString += 'precision="' + ScaleBar2Precision + '" ';
			}
		} else if (sDistance<5) {
			theString += 'precision="' + ScaleBar2Precision + '" ';
		}
		//theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" ';
		theString += 'fontsize="' + ScaleBar2Size + '" barwidth="' + ScaleBar2Width + '" overlap="False"  ';
		//*/
		theString += '/>\n</OBJECT>\n';
		theString += '</LAYER>\n';	
		
	}
	
	// any custom stuff to fit here
	if (aimsCustomPresent) theString += addCustomToMap3();

	if (drawModeOnMap) {
		// draw the current mode on the map
		theString += '<LAYER type="acetate" name="theMode">\n';
		theString += '<OBJECT units="pixel">\n<TEXT coords="5' + coordsDelimiter + (iHeight-10) + '" label="' + modeBlurb + '">\n';
		theString += '<TEXTMARKERSYMBOL fontstyle="BOLD" fontsize="12" font="ARIAL" fontcolor="' + modeMapColor + '" ';
		theString += 'threed="TRUE" glowing="' + modeMapGlow + '" overlap="false" />\n</TEXT>\n</OBJECT>';
		theString += '</LAYER>\n';	
	
	}
	
	// any custom stuff to be drawn on top of everything
	if (aimsCustomPresent) theString += addCustomToMap4();

	theString += '</GET_IMAGE>\n</REQUEST>\n</ARCXML>';
	//alert(theString);
	return theString;
}

/*
// prepare the request in xml format for Main Map
function writeImageXML() {
	
	var theString = '<ARCXML version="1.1">\n<REQUEST>\n<GET_IMAGE>\n<PROPERTIES>\n<ENVELOPE minx="' + forceComma(eLeft) + '" miny="' + forceComma(eBottom) + '" maxx="' + forceComma(eRight) + '" maxy="' + forceComma(eTop) + '" />\n';
	theString += '<IMAGESIZE height="' + iHeight + '" width="' + iWidth + '" />\n';
	var visString = "";
	if (aimsLayersPresent) {
		// tell the server which layers are to be visible
		if (toggleVisible) {
			theString += '<LAYERLIST >\n';
			for (var i=0;i<layerCount;i++) {
				if (LayerVisible[i]==1) {
					theString += '<LAYERDEF id="' + LayerID[i] + '" visible="true" ';
					if (aimsClassRenderPresent) {
						theString += addSpecialRenderToMap(i);
					} else {
						theString += '/>\n';
					}
					
				}
				else {
					theString += '<LAYERDEF id="' + LayerID[i] + '" visible="false" />\n';
				}
				
			}
			theString += '</LAYERLIST>\n';
		}
	}
	
	// map background color
	if (mapTransparent) {
		theString += '<BACKGROUND color="255,255,254" transcolor="255,255,254" />\n';
	} else {
		if (mapBackColor!="") {
			theString += '<BACKGROUND color="' + mapBackColor + '" />\n\n';
		}
	}
	if (aimsLegendPresent) {
		// create a legend image
		if (legendVisible) theString += addLegendToMap();
	}
	
	theString += '</PROPERTIES>\n';
	
	// buffer
	if (aimsBufferPresent) {
		if (showBuffer) theString += addBufferToMap();
	}
	
	// any custom stuff to fit here
	if (aimsCustomPresent) theString += addCustomToMap1();
	
	// route display - requires RouteServer extension
	if (aimsRoutePresent) {
		if (geocodeAppMode=="route") theString += addRouteToMapXML("");
	}
	
	// geocoding or point with label
	if (showGeocode) {
		// draw the point . . . also used to display any point with a label on map
		theString += '<LAYER type="acetate" name="GeoCode1">\n';
		theString += '<OBJECT units="database">\n<POINT coords="' + forceComma(geocodeX) + coordsDelimiter + forceComma(geocodeY) + '">\n';
		theString += '<SIMPLEMARKERSYMBOL  type="circle"  color="' + geocodePointColor + '" width="' + geocodePointSize +'" overlap="false" />\n</POINT></OBJECT>\n';
		if (geocodeLabel!="") {
			theString += '<OBJECT units="database">\n<TEXT coords="' + forceComma(geocodeX) + coordsDelimiter + forceComma(geocodeY) + '" label="' + geocodeLabel + '">\n';
			theString += '<TEXTMARKERSYMBOL fontcolor="' + geocodePointColor + '" fontsize="12" shadow="64,64,64" glowing="255,255,0" halignment="right" valignment="top" overlap="false" /></TEXT></OBJECT>\n';
		}
		theString += '</LAYER>\n';
		
	}
	
	// any custom stuff to fit here
	if (aimsCustomPresent) theString += addCustomToMap2();
	
	//add point location
	//********************************************
	//add point acetate layer
	 theString +='<LAYER type="acetate" name="allTheClicks">\n';
	 theString +='<OBJECT units="database">\n';
	 theString +='<POINT coords="' + mapX +' '+mapY+'">\n';
	 theString +='<SIMPLEMARKERSYMBOL type="cross" color="255,0,0" width="45" />\n';
	 theString +='</POINT>\n';
	 theString +='</OBJECT>\n';
	 theString +='</LAYER>\n';
	//*********************************************
	
	if (drawBottomBar) {
		theString += '<LAYER type="acetate" name="theBottomBar">\n';		
		theString += '<OBJECT units="pixel">\n<POLYGON ';
		theString += 'coords="0' + coordsDelimiter + '1' + pairsDelimiter;
		theString += '1' + coordsDelimiter + bottomBarHeight + pairsDelimiter;
		theString += (iWidth-1) + coordsDelimiter + bottomBarHeight + pairsDelimiter;
		theString += (iWidth-1) + coordsDelimiter + '1' + pairsDelimiter;
		theString += '0' + coordsDelimiter + '1">\n';
		theString += '<SIMPLEPOLYGONSYMBOL fillcolor="' + bottomBarColor + '" boundary="true" boundarycolor="' + bottomBarOutline + '" overlap="false" />\n';
		theString += '</POLYGON>\n</OBJECT>\n';
		theString += '</LAYER>\n';
	}

	if (drawCopyright) {
		// draw text on the map
		theString += '<LAYER type="acetate" name="theCopyright">\n';		
		theString += '<OBJECT units="pixel">\n<TEXT coords="' + CopyrightCoords + '" label="' + CopyrightText + '">\n';
		theString += '<TEXTMARKERSYMBOL fontstyle="' + CopyrightStyle + '" fontsize="' + CopyrightSize + '" ';
		if (CopyrightFont!="") theString += 'font="' + CopyrightFont + '" ';
		theString += 'fontcolor="' + CopyrightColor + '" antialiasing="True" ';
		//if (CopyrightBackground.toUpperCase()=="TRUE") theString += 'background="' + CopyrightBackground + '" backcolor="' + CopyrightBGColor + '" ';
		if (CopyrightBackground.toUpperCase()=="TRUE") theString += 'blockout="' + CopyrightBGColor + '" ';
		if (CopyrightShadow.toUpperCase()=="TRUE") theString += 'shadow="' + CopyrightShadowColor + '" ';
		theString += 'overlap="false" ';
		if (CopyrightGlow.toUpperCase()=="TRUE") theString += ' glowing="' + CopyrightGlowColor + '" ';
		theString += '/>\n</TEXT>\n</OBJECT>\n';
		theString += '</LAYER>\n';
	}
	if (drawNorthArrow) {
		// draw a north arrow
		theString += '<LAYER type="acetate" name="theNorthArrow">\n';
		theString += '<OBJECT units="pixel">\n<NORTHARROW type="' + NorthArrowType + '" size="' + NorthArrowSize + '" coords="' + NorthArrowCoords + '" shadow="32,32,32" ';
		theString += 'angle="' + NorthArrowAngle + '" antialiasing="True" overlap="False" />\n</OBJECT>\n';
		theString += '</LAYER>\n';
	}
	if (drawScaleBar) {
		// draw a scale bar
		//ScaleBarPrecision = numDecimals;
		theString += '<LAYER type="acetate" name="theScaleBar">\n';
		xDistance = eRight - eLeft;
		theString += '<OBJECT units="pixel">\n';
		theString += '<SCALEBAR ';
		
		if (drawScaleBar2) {
			theString += 'screenlength="' + parseInt(iWidth * (1/10)) + '" coords="' + (iWidth-((parseInt(iWidth * (4/10)))+20)) + coordsDelimiter + '3" ';
		} else {
			theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" coords="' + parseInt(iWidth * (6/10)) + coordsDelimiter + '3" ';
		}
		if (MapUnits=="DEGREES") theString += 'mode="geodesic" ';
		if (ScaleBarFont!="") theString += 'font="' + ScaleBarFont + '" ';
		theString += 'fontcolor="' + ScaleBarFontColor + '" fontstyle="' + ScaleBarStyle + '" barcolor="' + ScaleBarColor + '" ';
		if (MapUnits!="DEGREES") {
			theString += 'mapunits="' + MapUnits.toLowerCase() + '" ';
		}
		theString += 'scaleunits="' + ScaleBarUnits.toLowerCase() + '" antialiasing="True" ';
		var sDistance = getScaleBarDistance();
		if (MapUnits=="DEGREES") {
			if (xDistance<1/10){
				theString += 'precision="' + ScaleBarPrecision + '" ';
			}
		} else if (sDistance<5) {
			theString += 'precision="' + ScaleBarPrecision + '" ';
		}
		//theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" ';
		theString += 'fontsize="' + ScaleBarSize + '" barwidth="' + ScaleBarWidth + '" overlap="False"  ';
		// end phrase comments here
		theString += '/>\n</OBJECT>\n';
		theString += '</LAYER>\n';	
		
	}
	if (drawScaleBar2) {
		// draw a scale bar
		//ScaleBarPrecision = numDecimals;
		theString += '<LAYER type="acetate" name="theScaleBar2">\n';
		xDistance = eRight - eLeft;
		theString += '<OBJECT units="pixel">\n';
		theString += '<SCALEBAR ';
		
		if (drawScaleBar) {
			theString += 'screenlength="' + parseInt(iWidth * (1/10)) + '" coords="' + (iWidth-((parseInt(iWidth * (2/10)))+10)) + coordsDelimiter + '3" ';
		} else {
			theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" coords="' + parseInt(iWidth * (6/10)) + coordsDelimiter + '3" ';
		}
		if (MapUnits=="DEGREES") theString += 'mode="geodesic" ';
		if (ScaleBar2Font!="") theString += 'font="' + ScaleBar2Font + '" ';
		theString += 'fontcolor="' + ScaleBar2FontColor + '" fontstyle="' + ScaleBar2Style + '" barcolor="' + ScaleBar2Color + '" ';
		if (MapUnits!="DEGREES") {
			theString += 'mapunits="' + MapUnits.toLowerCase() + '" ';
		}
		theString += 'scaleunits="' + ScaleBar2Units.toLowerCase() + '" antialiasing="True" ';
		var sDistance = getScaleBarDistance();
		if (MapUnits=="DEGREES") {
			if (xDistance<1/10){
				theString += 'precision="' + ScaleBar2Precision + '" ';
			}
		} else if (sDistance<5) {
			theString += 'precision="' + ScaleBar2Precision + '" ';
		}
		//theString += 'screenlength="' + parseInt(iWidth * (2/10)) + '" ';
		theString += 'fontsize="' + ScaleBar2Size + '" barwidth="' + ScaleBar2Width + '" overlap="False"  ';
		//     end phrase comments
		theString += '/>\n</OBJECT>\n';
		theString += '</LAYER>\n';	
		
	}
	
	// any custom stuff to fit here
	if (aimsCustomPresent) theString += addCustomToMap3();

	if (drawModeOnMap) {
		// draw the current mode on the map
		theString += '<LAYER type="acetate" name="theMode">\n';
		theString += '<OBJECT units="pixel">\n<TEXT coords="5' + coordsDelimiter + (iHeight-10) + '" label="' + modeBlurb + '">\n';
		theString += '<TEXTMARKERSYMBOL fontstyle="BOLD" fontsize="12" font="ARIAL" fontcolor="' + modeMapColor + '" ';
		theString += 'threed="TRUE" glowing="' + modeMapGlow + '" overlap="false" />\n</TEXT>\n</OBJECT>';
		theString += '</LAYER>\n';	
	
	}
	
	// any custom stuff to be drawn on top of everything
	if (aimsCustomPresent) theString += addCustomToMap4();

	theString += '</GET_IMAGE>\n</REQUEST>\n</ARCXML>';
	//alert(theString);
	
	return theString;
}

*/

function Clear_ShowImage()
{
	if (imageActive)
	{
		//alert("pre_active_indx is : "+parent.MapFrame.LayerID[pre_active_indx]);
		parent.MapFrame.setActiveLayer(pre_active_indx);
		//alert("activelayer is: "+parent.MapFrame.LayerID[ActiveLayerIndex]);
		
		imageActive=false;
	}
}








