function startZoomBox() 
{		
	//if ((Xmd<MapWidth) && (Xmd>0) && (Ymd<MapHeight) && (Ymd>0)) 
	//{		
		if (zooming) 
		{
			stopZoomBox();
		} 
		else 
		{
			x1=Xmd + document.body.scrollLeft;			
			y1=Ymd + document.body.scrollTop;
			x2=x1+1;
			y2=y1+1;
			zleft=x1;
			ztop=y1;
			zbottom=y1;
			zright=x1			
			boxIt(x1,y1,x2,y2);
			zooming=true;
			/*
			if (isNav4) {
				showLayer("zoomBoxTop");
				showLayer("zoomBoxLeft");
				showLayer("zoomBoxRight");
				showLayer("zoomBoxBottom");
			} else {
				showLayer("zoomBox");
			}
			*/
		}
	//}
	return false;
}


//....................function called when mouse up to stop drawing the red rectangle..........
//....................when stop dragging over the map "mouse up"...............................
function stopZoomBox() {
	zooming=false;
	
		hideLayer("zoomBoxTop");
		hideLayer("zoomBoxLeft");
		hideLayer("zoomBoxRight");
		hideLayer("zoomBoxBottom");	
	return true;
}

function getMouse() 
{		
		mouseStuff();	  		
		return false;	
}

function chkMouseUp() 
{ 
	if (zooming) 
	{
			stopZoomBox();		
	}			
	return false;
}

function mouseStuff() 
{
	if (zooming) //if strAction = zoomin or zoomout
	{
		if((Xmm + document.body.scrollLeft) > x1 && (Ymm + document.body.scrollTop) > y1)
		{
			factor = 4;
			
		}
		else
		{ 
			factor = 0;					
		}
		x2=Xmm + document.body.scrollLeft - factor;
		y2=Ymm + document.body.scrollTop + factor;
		setClip();
	} 		
}

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)) {
		//clipLayer("zoomBox",zleft,ztop,zright,zbottom);
		boxIt(zleft,ztop,zright,zbottom);
	//clipLayer("zoomBoxTop",zleft,ztop,zright,ztop+3);
	//clipLayer("zoomBoxLeft",zleft,ztop,zleft+3,zbottom);
	//clipLayer("zoomBoxRight",zright-3,ztop,zright,zbottom);
	//clipLayer("zoomBoxBottom",zleft,zbottom-3,zright,zbottom);	
		showLayer("zoomBoxTop");
		showLayer("zoomBoxLeft");
		showLayer("zoomBoxRight");
		showLayer("zoomBoxBottom");
		
	}
	//return false;
}


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>');	    
	  //}
}

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 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 boxIt(theLeft,theTop,theRight,theBottom) 
{

		//if (!isNav4) 
		//{
		//	theTop = theTop + vspc;
		//	theBottom = theBottom + vspc;
		//	theLeft = theLeft + hspc;
		//	theRight = theRight + hspc;			
		//}
		clipLayer("zoomBoxTop",theLeft,theTop,theRight,theTop+3);
		clipLayer("zoomBoxLeft",theLeft,theTop,theLeft+3,theBottom);
		clipLayer("zoomBoxRight",theRight-3,theTop,theRight,theBottom);
		clipLayer("zoomBoxBottom",theLeft,theBottom-3,theRight,theBottom);	
		showLayer("zoomBoxTop");
		showLayer("zoomBoxLeft");
		showLayer("zoomBoxRight");
		showLayer("zoomBoxBottom");
		
}

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 setLayerBackgroundColor(name, color) 
{		
  	var layer = getLayer(name);		
 	//if (isNav4)
    //	layer.bgColor = color; 
	//else
    	layer.backgroundColor = color;    
}

