
var ZoomBoxMagLayer;
var ZoomMagLayerOffset=20;
var LogOfTwo=Math.log(2);

function showZoomBoxInfo(evt){

	if (ZoomBoxVisible==true) {
		ZoomText="Zoom in to level " + getNewMag();
		}
	else if (StairsVisible==true) {
		ZoomText="Zoom out to level " + getNewMag();
		}

	switch (browser){
		case "NAV6":
		case "NAV7":
			if (isVisible(ZoomBoxMagLayer)==false){
				showLayer(ZoomBoxMagLayer);
				setzIndex(ZoomBoxMagLayer,5);
			}
			moveLayer(ZoomBoxMagLayer,evt.clientX+ZoomMagLayerOffset,evt.clientY+ZoomMagLayerOffset);
			ZoomBoxMagLayer.innerHTML=ZoomText;
			break
		case "IE4":
		case "IE5":
		case "IE6":
		case "IE7":
			if (isVisible(ZoomBoxMagLayer)==false){
				showLayer(ZoomBoxMagLayer);
				setzIndex(ZoomBoxMagLayer,5);
			}
			moveLayer(ZoomBoxMagLayer,event.clientX+ZoomMagLayerOffset,event.clientY+ZoomMagLayerOffset);
			ZoomBoxMagLayer.innerHTML=ZoomText;
	}

}

function hideZoomBoxInfo(){

	switch (browser){
		case "NAV6":
		case "NAV7":
		case "IE4":
		case "IE5":
		case "IE6":
		case "IE7":
			hideLayer(ZoomBoxMagLayer);
	}

}

function getNewMag() {

	var NewMag;
	
	if ((x2<x1) && (y2<y1)) {
		NewMag=CurrentMag-getStairIncrement();
		}
	else {
		NewMag=CurrentMag+Math.floor(Math.log(MapWidth/(MaxX-MinX))/LogOfTwo);
		}
	
	if (NewMag > MaximumMag) NewMag = MaximumMag;
	if (NewMag < MinimumMag) NewMag = MinimumMag;
	
	return NewMag;

}