//<script>
var zoomBoxColor = "#FF0000";	// color of zoombox
		var hspc = 0; 		// horizontal image offset
		var vspc = 0; 		// vertical image offset
		var ovBoxSize = 2; 	// Zoombox line width;
		
		var zooming = false;
		
		// Global vars to save mouse position
		var mouseX=0;
		var mouseY=0;
		var x1=0;
		var y1=0;
		var x2=0;
		var y2=0;
		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;
		//alert(navigator.appVersion);
		if (isNav) {
			
			if (parseFloat(navigator.appVersion)<5) {
				isNav4=true;
				//alert("Netscape 4.x or older");
			} else {
				is5up = true;
			}
		} else {
			isIE4=true;
			if (navigator.appVersion.indexOf("MSIE 5")>0) {
				isIE4 = false;
				is5up = true;
			}
		}		
		// 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:201; 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 (1<2) {
				var theObj = document.getElementById(name);
				return theObj.style
			  }
			  else
			  return(null);
		}	
		
		// move layer to x,y
		function moveLayer(name, x, y) {		
		  	var layer = getLayer(name);		
		  	if (isNav4)
		    	layer.moveTo(x, y);
		  	//if (document.all) {
			 else {
		    	layer.left = x + "px";
		   		layer.top  = y + "px";
		  	}
		}
		
		// 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";
		  	//if (document.all)
			else
		   		 layer.visibility = "hidden";
				 //layer.display="none";
		}
		
		// toggle layer to visible
		function showLayer(name) {		
		  	var layer = getLayer(name);		
		  	if (isNav4)
		    	layer.visibility = "show";
		  	//if (document.all)
			else
		   	 layer.visibility = "visible";
			 //layer.display="block";
		}
		
		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) {
				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");
		}

		// get cursor location
		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) {
			//moveLayer("theMap",hspc,vspc);
			getImageXY(e);			
			// keep it within the MapImage
			if ((mouseX<mWidth) && (mouseY<mHeight)) {
					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;
			
			hideLayer("zoomBoxTop");
			hideLayer("zoomBoxLeft");
			hideLayer("zoomBoxRight");
			hideLayer("zoomBoxBottom");
			window.scrollTo(0,0);
			
			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)) {
				boxIt(zleft,ztop,zright,zbottom);
			}
			return false;
		}

function isRightClick(e) {
    if (isNav) {
	   return (e.button > 1);
	}else{
	   return (event.button > 1);
	}
}		