		// For IE and FireFox
		
		// *********************************************************************************************************
		// ** HTML RECTANGLE BOX FOR ZOOMING
		// *********************************************************************************************************
		
		// Set the image height and width for the zoom box
		var iWidth = MapWidth; 	// image width
		var iHeight = MapHeight;	// image height
		
		// Main Map
		var hspc = findPosX(map);
		var vspc = findPosY(map);
	
		var zoomBoxColor = "#000000";	// color of zoombox
		var ovBoxSize = 1; 	// Zoombox line width;
		var zooming = false;
			
		// Global vars to save mouse position offset to image
		//***********************************************************************************		
		var mouseX=0;
		var mouseY=0;

		//Current dimensions of box frame in screen coordinates ofset to image
		var x1=0;
		var y1=0;
		var x2=0;
		var y2=0;

		//Current dimensions of box frame in screen coordinates taking account of
		//whether X1,Y1 is above X2,Y2 or not (ie 1 and 2 are swapped if need be)
		var zleft=0;
		var zright=0;
		var ztop=0;
		var zbottom=0;
	
		// Global vars for browser type and version
		//***********************************************************************************		
		var isNav = (navigator.appName.indexOf("Netscape")>=0);
		var isNav4 = false;
		var isIE4 = false;
		var is5up = false;
		
		if (isNav) {
			if (parseFloat(navigator.appVersion)<5) {
				isNav4 = true;
			} else {
				is5up = true;
			}
		} else {
			isIE4=true;
			if (navigator.appVersion.indexOf("MSIE 5")>0) {
				isIE4 = false;
				is5up = true;
			}
		}

		/*
		##################################################################################################
		DHTML layer functions - used to create and manipulate style sheets
		##################################################################################################
		*/

		//***********************************************************************************		
		// Create a DHTML layer
		function createLayer(name, inleft, intop, width, height, visible, content) {
		//***********************************************************************************		

			  var layer;
			  if (isNav4) {
			    document.writeln('<layer name="' + name + '" left=' + inleft + ' top=' + intop + ' width=' + width + ' height=' + height +  ' visibility=' + (visible ? '"show"' : '"hide"') +  '>');
			    document.writeln(content);
			    document.writeln('</layer>');
			  } else {
			    document.writeln('<div id="' + name + '" style="position:absolute; overflow:hidden; left:' + inleft + 'px; top:' + intop + 'px; width:' + width + 'px; height:' + height + 'px;' + '; z-index:1; visibility:' + (visible ? 'visible;' : 'hidden;') +  '">');
			    document.writeln(content);
			    document.writeln('</div>');
			  }
		}
		
		//***********************************************************************************		
		// get the layer object called "name"
		function getLayer(name) {
		//***********************************************************************************		
			  if (isNav4)
			    return(document.layers[name]);
			  else if (isIE4) {
			    layer = eval('document.all.' + name + '.style');
			    return(layer);
			  } else if (is5up) {
				var theObj = document.getElementById(name);
				return theObj.style
			  }
			  else
			    return(null);
		}

		//***********************************************************************************		
		function isVisible(name) {
		//***********************************************************************************		
			  var layer = getLayer(name);
			  if (isNav && layer.visibility == "show")
			    return(true);
			  if (isIE && layer.visibility == "visible")
			    return(true);
			  return(false);
		}

		//***********************************************************************************		
		// set layer background color
		function setLayerBackgroundColor(name, color) {		
		//***********************************************************************************		
		  	var layer = getLayer(name);		
		 	 if (isNav4)
		    	layer.bgColor = color;
		  	//else if (document.all)
			else
		    	layer.backgroundColor = color;
		}

		//***********************************************************************************		
		// toggle layer to invisible
		function hideLayer(name) {		
		//***********************************************************************************		
		  	var layer = getLayer(name);		
		  	if (isNav4)
		    	layer.visibility = "hide";
			else
		   		 layer.visibility = "hidden";
		}

		//***********************************************************************************		
		// toggle layer to visible
		function showLayer(name) {		
		//***********************************************************************************		
		  	
		  	//alert( "show" );
		  	var layer = getLayer(name);		
		  	if (isNav4)
		    	layer.visibility = "show";
			else
		   	 layer.visibility = "visible";
		   	 
		   	// alert( "finish" );
		}
		
		//***********************************************************************************		
		function clipLayer(name, clipleft, cliptop, clipright, clipbottom) {		
		//***********************************************************************************	
			
			  var layer = getLayer(name);		
			  if (isNav4) {
				    layer.clip.left   = clipleft;
				    layer.clip.top    = cliptop;
				    layer.clip.right  = clipright;
				    layer.clip.bottom = clipbottom;
			  }	  else {
	
					var newWidth = clipright - clipleft;
					var newHeight = clipbottom - cliptop;
					layer.height = newHeight;
					layer.width	= newWidth;
					layer.top	= cliptop + "px";
					layer.left	= clipleft + "px";
				}
		}

		//***********************************************************************************		
		function boxIt(theLeft,theTop,theRight,theBottom) {
		//***********************************************************************************		
				
				theLeft=theLeft+hspc
				theRight=theRight+hspc
				theTop=theTop+vspc
				theBottom=theBottom+vspc
				
				if ((theLeft>=hspc) && (theRight<=iWidth+hspc) && (theTop>=vspc) && (theBottom<=vspc+iHeight)) {
	
					clipLayer("zoomBoxTop",theLeft,theTop,theRight,theTop+ovBoxSize);
					clipLayer("zoomBoxLeft",theLeft,theTop,theLeft+ovBoxSize,theBottom);
					clipLayer("zoomBoxRight",theRight-ovBoxSize,theTop,theRight,theBottom);
					clipLayer("zoomBoxBottom",theLeft,theBottom-ovBoxSize,theRight,theBottom);	
					showLayer("zoomBoxTop");
					showLayer("zoomBoxLeft");
					showLayer("zoomBoxRight");
					showLayer("zoomBoxBottom");
				}
				else {	
					hideLayer("zoomBoxTop");
					hideLayer("zoomBoxLeft");
					hideLayer("zoomBoxRight");
					hideLayer("zoomBoxBottom");
				}
		}
		
		/*
		##################################################################################################	
		Navigation functions - used to resize zoom box
		##################################################################################################
		*/

		//***********************************************************************************		
		// get cursor location - called from mouse move
		function getImageXY(e) {
		//***********************************************************************************		
			if (isNav) {
				mouseX = e.pageX;
				mouseY = e.pageY;
			} else {
				mouseX = event.clientX + document.body.scrollLeft;
				mouseY = event.clientY + document.body.scrollTop;
			}
			
			// subtract offsets from page left and top
			mouseX = mouseX - hspc;
			mouseY = mouseY - vspc;		
			
		}	

		//***********************************************************************************		
		// start zoom in.... box displayed
		function startZoomBox(e) {
		//***********************************************************************************		
			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;
			return false;
		}

		//***********************************************************************************		
		// stop zoom box display... 
		function stopZoomBox(e) {
		//***********************************************************************************		
			zooming=false;
			window.scrollTo(0,0);
			return true;
		}

		//***********************************************************************************
		// ############MOUSE MOVE##############
		function mouseMove(e) {
		//***********************************************************************************
			
			getImageXY(e);
			
			//Are we inside the overview map
			if ((mouseX<iWidth) && (mouseY<iHeight) && (mouseX>=0) && (mouseY>=0)) {

				if (zooming) {
					x2=mouseX;
					y2=mouseY;
					setClip();
				}	
						
			}
				
			// next line needed for Mac
			return false;
			
		}

		//***********************************************************************************		
		// 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)) {
				boxIt(zleft,ztop,zright,zbottom);
			}
		}
		
		/*
		##################################################################################################
		Click/Mouse functions - used to catch mouse button events
		##################################################################################################
		*/

		//***********************************************************************************
		// #############MOUSE UP#################
		function mouseUp(e) { 
		//***********************************************************************************
			
			if (zooming) {
				stopZoomBox(e);
				sendZBtoServer();
			}			
				
			return false;
		}

		//***********************************************************************************		
		function sendZBtoServer() {
		//***********************************************************************************
			
			if ( toolmode == 1 || toolmode == 2 ) {
			
				if ( zleft==zright && ztop==zbottom ) {
					
					// Point
					ZoomPoint( zleft, ztop);
				}
				else {
					
					// Send pixel coords to the server
					ZoomBox( "", zleft, ztop, zright, zbottom );
				}	
				
			}
			
			hideLayer("zoomBoxTop");
			hideLayer("zoomBoxLeft");
			hideLayer("zoomBoxRight");
			hideLayer("zoomBoxBottom");
			
		}
		
		//***********************************************************************************		
		// #############MOUSE DOWN#################
		function mouseDown (e) {
		//***********************************************************************************
			
			if ((mouseX<iWidth) && (mouseY<iHeight) && (mouseX>0) && (mouseY>0)) {
				startZoomBox(e);
				return false;
			}
		}
		
		function findPosX(obj)
		{
			var curleft = 0;
			if (obj.offsetParent)
			{
				while (obj.offsetParent)
				{
					curleft += obj.offsetLeft
					obj = obj.offsetParent;
				}
			}
			else if (obj.x)
				curleft += obj.x;
			return curleft;
		}

		function findPosY(obj)
		{
			var curtop = 0;
			if (obj.offsetParent)
			{
				while (obj.offsetParent)
				{
					curtop += obj.offsetTop
					obj = obj.offsetParent;
				}
			}
			else if (obj.y)
				curtop += obj.y;
			return curtop;
		}

	// zoom/selection box

	content = '<img name="zoomImageTop" src="images/pixel.gif" width=1 height=1>';
	createLayer("zoomBoxTop",0,0,iWidth,iHeight,false,content);
	content = '<img name="zoomImageLeft" src="images/pixel.gif" width=1 height=1>';
	createLayer("zoomBoxLeft",0,0,iWidth,iHeight,false,content);
	content = '<img name="zoomImageRight" src="images/pixel.gif" width=1 height=1>';
	createLayer("zoomBoxRight",0,0,iWidth,iHeight,false,content);
	content = '<img name="zoomImageBottom" src="images/pixel.gif" width=1 height=1>';
	createLayer("zoomBoxBottom",0,0,iWidth,iHeight,false,content);

	// set zoom box color
	setLayerBackgroundColor("zoomBoxTop", zoomBoxColor);
	setLayerBackgroundColor("zoomBoxLeft", zoomBoxColor);
	setLayerBackgroundColor("zoomBoxRight", zoomBoxColor);
	setLayerBackgroundColor("zoomBoxBottom", zoomBoxColor);

