//function for zoom box

 
//Browser checking
if (navigator.userAgent.indexOf("MSIE") != -1 ) {
	//MSIE oder Netscape 6
	isIE = true;
	isNav = false;
	isNav6 = false;
} else if (document.getElementById&&!document.all){
	isIE = false;
	isNav = false;
	isNav6 = true;
} else {
	// MSIE
	isIE = false;
	isNav = true;
	isNav6 = false;
}


 
var zooming = false;
var panning = false;

//Position for map layer
var layerheight = 425;
var layerwidth = 628;
if (isNav6) {
	var postop =  2;
	var posleft = 0;
} else {
	var postop =  2;
	var posleft = 0;
}
var z_index=100;

//Parameters for   Zoombox
var boxLineWidth=2; //zoom box line thickness
var zoomColor= "#0000FF"; // Zoombox color


function addZoombox() {
	content = '<img name="boxTop" SRC="pixel.gif" width=1 height=1>';
	createLayer("BoxTop", posleft, postop, layerwidth, layerheight, z_index, zoomColor, false, content);
	content = '<img name="boxLeft" SRC="pixel.gif" width=1 height=1>';
	createLayer("BoxLeft", posleft, postop, layerwidth, layerheight, z_index, zoomColor, false, content);
	content = '<img name="boxRight" SRC="pixel.gif" width=1 height=1>';
	createLayer("BoxRight", posleft, postop, layerwidth, layerheight, z_index, zoomColor, false, content);
	content = '<img name="boxBottom" SRC="pixel.gif" width=1 height=1>';
	createLayer("BoxBottom", posleft, postop, layerwidth, layerheight, z_index, zoomColor, false, content);
	//initialisierung des event-capturing
	setEvents();
	//done
}

// start zoom in.... box displayed
function startBox(e) {
	//moveLayer("theMap",posleft,postop);
	getImageXY(e);
	if (insideMap) {
	// keep it within the MapImage
	if ((mouseX<layerwidth) && (mouseY<layerheight)) {
		if (!zooming) {
			startX=mouseX;
			startY=mouseY;
			x2=startX+1;
			y2=startY+1;
			clipLayer("BoxTop",startX,startY,x2,y2);
			clipLayer("BoxRight",startX,startY,x2,y2);
			clipLayer("BoxBottom",startX,startY,x2,y2);
			clipLayer("BoxLeft",startX,startY,x2,y2);
			zooming=true;
			showLayer("BoxTop");
			showLayer("BoxRight");
			showLayer("BoxBottom");		
			showLayer("BoxLeft");
		}
	} else {
		if (zooming) {
			stopBox(e);
		}
	}
	}
	return false;	
}

// stop zoom box display... zoom in
function stopBox(e) {
	if (insideMap) {
		zooming=false;
		getImageXY(e);
		if (isNav6) {
			stopX=mouseX-posleft;
			stopY=mouseY-postop;
		} else {
			stopX=mouseX;
			stopY=mouseY;
		}
		if (isNav6) {
			startX = startX-posleft;
			startY = startY-postop;
		}	
		var tempX=startX;
		var tempY=startY;
		if (startX>stopX) {
			xmax=startX;
			xmin=stopX;
		} else {
			xmin=startX;
			xmax=stopX;
		}
		if (startY<stopY) {
			ymin=startY;
			ymax=stopY;
		} else {
			ymax=startY;
			ymin=stopY;
		}
		
		if (xmax-xmin > 10 && ymax-ymin > 10 && zoomdir==1) {
			refreshMap("box");
		}
		else {
			refreshMap("point");
		}
		
		return true;
	}
}