<!--
//========================================================
// Navigation functions from ArcIMS
//========================================================

// get image cursor location
function getImageXY(e) {
    mouseX = parseInt(e.offsetX);
    mouseY = parseInt(e.offsetY);
}

// get image dimension: width & height
function getImageSize() {
    var imgSize = findObject("ImgSize").value;
    var img
    switch(imgSize) {
      case "Small":
          img = findObject(id_prefix + "ImageMapSmall");
          break;
      case "Medium":
          img = findObject(id_prefix + "ImageMapMedium");
          break;
      case "Large":
          img = findObject(id_prefix + "ImageMapLarge");
          break;
    }
    if(img) {
        imgWidth  = parseInt(img.width);
        imgHeight = parseInt(img.height);
    }
}

// start zoom in.... box displayed
function startZoomBox(e) {
	//moveLayer("theMap",hspc,vspc);
	getImageXY(e);	

	// update image size
	getImageSize();
	// keep it within the MapImage
	if ((mouseX<imgWidth) && (mouseY<imgHeight)) {
		if (zooming) {
			stopZoomBox(e);
		} else {
			x1=mouseX;
			y1=mouseY
			x2=x1+1;
			y2=y1+1;
			zleft=x1;
			ztop=y1;
			zbottom=y1;
			zright=x1

// alert('x1= ' + x1 + '; y1 = ' + y1 + '; x2 = ' + x2 + '; y2 = ' + y2);

			boxIt(x1,y1,x2,y2);
			zooming=true;
		}
	}
	return false;
}

// stop zoom box display... zoom in
function stopZoomBox(e) {
	zooming=false;
	hideLayer("zoomBoxTop");
	hideLayer("zoomBoxLeft");
	hideLayer("zoomBoxRight");
	hideLayer("zoomBoxBottom");
	return true;
}

/*
// zoom in around mouse click
function zoomin(e) {
	getMapXY(mouseX,mouseY);
	var tempLeft=lastLeft;
	var tempRight=lastRight;
	var tempTop=lastTop;
	var tempBottom=lastBottom;
	saveLastExtent();

	eLeft = mapX - (xHalf/zoomFactor);
	eRight = mapX + (xHalf/zoomFactor);
	eTop = mapY + (yHalf/zoomFactor);
	eBottom = mapY - (yHalf/zoomFactor);
	
	sendMapXML();
}
*/

// start zoom out... box displayed
function startZoomOutBox(e) {
	moveLayer("theMap",hspc,vspc);
	getImageXY(e);
	// keep it within the MapImage
	if ((mouseX<iWidth) && (mouseY<iHeight)) {
		
		if (zooming) {
			stopZoomOutBox(e);
		} else {
			x1=mouseX;
			y1=mouseY
			x2=x1+1;
			y2=y1+1;
			zleft=x1;
			ztop=y1;
			zbottom=y1;
			zright=x1
			boxIt(x1,y1,x2,y2);
			zooming=true;
			/*
			if (is_NS4) {
				showLayer("zoomBoxTop");
				showLayer("zoomBoxLeft");
				showLayer("zoomBoxRight");
				showLayer("zoomBoxBottom");
			} else {
				showLayer("zoomBox");
			}
			*/
		}
	//} else {
	//	if (zooming) stopZoomOutBox(e);
	}
	return false;
	
}

// stop zoom out box. . . zoom out
function stopZoomOutBox(e) {
	zooming=false;
	hideLayer("zoomBoxTop");
	hideLayer("zoomBoxLeft");
	hideLayer("zoomBoxRight");
	hideLayer("zoomBoxBottom");

	if ((zright <zleft+2) && (zbottom < ztop+2)) {
		zoomout(e);
	} else {
		var tempLeft=eLeft;
		var tempRight=eRight;
		var tempTop=eTop;
		var tempBottom=eBottom;
		saveLastExtent();
		var zWidth = Math.abs(zright-zleft);
		var zHeight = Math.abs(ztop-zbottom);
		var xRatio = iWidth / zWidth;
		var yRatio = iHeight / zHeight;
		var xAdd = xRatio * xDistance / 2;
		var yAdd = yRatio * yDistance / 2;
		eLeft = eLeft - xAdd;
		eRight = eRight + xAdd;
		eTop = eTop + yAdd;
		eBottom = eBottom - yAdd;
		window.scrollTo(0,0);
		if (enforceFullExtent) {
			if ((eRight-eLeft)>fullWidth) {
				eLeft = fullLeft;
				eRight = fullRight;
				eTop = fullTop;
				eBottom = fullBottom;
				lastLeft=tempLeft;
				lastRight=tempRight;
				lastTop=tempTop;
				lastBottom=tempBottom;
			}
		}
		//var theString = writeXML();
//		sendMapXML();
	}
	return true;
}

// clip zoom box layer to mouse coords
function setClip() {	
	var tempX=x1;
	var tempY=y1;
	if (x1>x2) {
		zright=x1;
		zleft=x2;
	} else {
		zleft=x1;
		zright=x2;
	}
	if (y1>y2) {
		zbottom=y1;
		ztop=y2;
	} else {
		ztop=y1;
		zbottom=y2;
	}
	
	if ((x1 != x2) && (y1 != y2)) {
	    xDistance = x2-x1;
	    yDistance = y2-y1;
		boxIt(zleft,ztop,zright,zbottom);
	}
}


function boxIt(theLeft,theTop,theRight,theBottom) {
    if (!is_NS4) {
	    theTop    = theTop + vspc;
	    theBottom = theBottom + vspc;
	    theLeft   = theLeft + hspc;
	    theRight  = theRight + hspc;
    }
    clipLayer("zoomBoxTop",theLeft,theTop,theRight,theTop+boxSize);
    clipLayer("zoomBoxLeft",theLeft,theTop,theLeft+boxSize,theBottom);
    clipLayer("zoomBoxRight",theRight-boxSize,theTop,theRight,theBottom);
    clipLayer("zoomBoxBottom",theLeft,theBottom-boxSize,theRight,theBottom);	
    showLayer("zoomBoxTop");
    showLayer("zoomBoxLeft");
    showLayer("zoomBoxRight");
    showLayer("zoomBoxBottom");
}

//-->