var legendImage="";
var coordsDelimiter = " ";


var chkUnits=false;
var legendTemp = false;

var theImagePath = "";
var theImageURLPath = "";
var theServiceName = "";

var theVersion = navigator.appVersion;
var theVersNum = parseFloat(theVersion);
var theBrowser = navigator.appName;

function startUp() { //startUp

	fullLeft = limitLeft;
	fullRight = limitRight;
	fullTop = limitTop;
	fullBottom = limitBottom;
				
	fullWidth = Math.abs(fullRight - fullLeft);
	fullHeight = Math.abs(fullTop - fullBottom);

	left=startLeft;
    right=startRight;
    top=startTop;
    bottom=startBottom;

	xDistance = Math.abs(right-left);
	var sFactor = xDistance / iWidth;
	mapScaleFactor = sFactor;
	xDistance = Math.abs(right-left);
	yDistance = Math.abs(top-bottom);
	xHalf = xDistance/2;
	yHalf = yDistance/2;
	panX = xDistance * panFactor;
	panY = yDistance * panFactor;
	if (chkUnits) {
		 if (MapUnits=="DEGREES") {
		 	if ((right > 250) || (top > 150)) MapUnits="FEET";
		 } 
		 chkUnits=false;
	}
	mouseX = 0;
	mouseY = 0;
	pixelX = xDistance/iWidth;
	pixelY = yDistance/iHeight;
	mapX = left;
	mayY = top;
	lastLeft = left;
	lastRight = right;
	lastTop = top;
	lastBottom = bottom;

	fullLeft = limitLeft;
	fullRight = limitRight;
	fullTop = limitTop;
	fullBottom = limitBottom;
	fullWidth = Math.abs(fullRight - fullLeft);
	fullHeight = Math.abs(fullTop - fullBottom);

	sendToServerASP(4);


}

function startMap() { //startMap
	shwRetrData(); //showRetrieveData
	startUp(); //startUp
}


function getMapWd () { //getMapWidth
	var mapFrameWidth = window.innerWidth;
	if (mapFrameWidth == null) {
		mapFrameWidth = document.body.clientWidth;
	}
	return mapFrameWidth;
}

function getMapHt () { //getMapHeight
	var mapFrameHeight = window.innerHeight;
	if (mapFrameHeight == null) {
		mapFrameHeight = document.body.clientHeight;
	}
	return mapFrameHeight;
}


function f20(oldString,oldStuff,newStuff) { //swapStuff
	var pos = 0;
	var rpos = 0;
	var epos = 0;
	var leftString = "";
	var rightString = "";
	pos = oldString.indexOf(oldStuff);			
	while (pos!=-1) {
		epos = oldString.length;
		rpos = pos + oldStuff.length;
		leftString = oldString.substring(0,pos);
		rightString = oldString.substring(rpos,epos);
		oldString = leftString + newStuff + rightString;
		pos = oldString.indexOf(oldStuff);
	}
	leftString=null;
	rightString=null;
	return oldString;
}


function f29(oldString) {  //makeXMLsafe

	//oldString = f20(oldString,"'","&apos;");
	//oldString = f20(oldString,">","&gt;");
	//oldString = f20(oldString,"<","&lt;");
	//oldString = f20(oldString,'"',"&quot;");

	return oldString;
}
//march 06 gsmith via ppunter
function fixlab(oldString) {  //makeXMLsafe

	oldString = f20(oldString,"'","&apos;");
	oldString = f20(oldString,">","&gt;");
	oldString = f20(oldString,"<","&lt;");
	oldString = f20(oldString,'"',"&quot;");
	oldString = f20(oldString,',',"$$_MCC_COMMA_$$");

	return oldString;
}

// reloadTimer constantly gets reset ontil the resizing is finished
var reloadTimer=0;
// avoid sending requests until browser has been resized
function reloadApp() {
    window.clearTimeout(reloadTimer);
	reloadTimer = window.setTimeout("sendMapXML();",1000);
}