var ns = (document.layers ? true : false);var ie = (document.all ? true : false);var navig = navigator.userAgent;var moz = (navig.indexOf("Gecko")>=0?true : false);var nn6 = ((!document.all && document.getElementById) ? true : false);var opera = (navig.indexOf("Opera")>=0?true : false);var isClick = false;var mouseStartX = -1;var mouseStartY = -1;var minX = 0;var maxX = 0;var minY = 0;var maxY = 0;var globaldrag = 0;var imgLayer = "maphome";var selLayer = "selection";var dragactief=0;var criteriapresent=false; var uri;  function preload() { 	if (ie) {	 	document.all[imgLayer].style.visibility="visible";  	}	if (ns) {		document.layers[imgLayer].visibility = "visible";	}	if (nn6) {		document.getElementById(imgLayer).style.visibility = "visible";	} }function initDragZoom(u) {	uri = u;	preload();	xwidth=375;	if (ie || moz) {		var theDiv = document.getElementById(imgLayer);        minX = findPosX(theDiv); //       maxX = minX + parseInt(theDiv.offsetWidth); 		maxX=minX+375;        minY = findPosY(theDiv);        maxY = minY + parseInt(theDiv.offsetHeight);	}	if (ns) {		var theDiv = document.layers[imgLayer]		minX = theLayer.pageX + x;	//	maxX = minX + theLayer.clip.width;	maxX=minX+375;		minY = theLayer.pageY + y;		maxY = minY + theLayer.clip.height;	}	if(nn6){		if(opera){			var theDiv = document.getElementById(imgLayer);			minX = findPosX(theDiv);		//	maxX = minX + parseInt(theDiv.style.width);		maxX=minX+375;			minY = findPosY(theDiv);			maxY = minY + parseInt(theDiv.style.height);		}	}		if(ie){		//document.all['mapper'].onmousedown = mouseDown;		theDiv.document.onmousedown = mouseDown;		theDiv.document.onmousemove = mouseMove;		theDiv.document.onmouseup = mouseUp;	}	if (ns) {		document.onmousedown = mouseDown;		document.onmousemove = mouseMove;		document.onmouseup = mouseUp;		document.captureEvents( Event.MOUSEDOWN |Event.MOUSEMOVE | Event.MOUSEUP);	}	if(nn6){		//if(opera){		//}else{			document.onmousedown = mouseDown;			document.onmousemove = mouseMove;			document.onmouseup = mouseUp;			document.captureEvents(Event.MOUSEDOWN |Event.MOUSEMOVE | Event.MOUSEUP);		//}	}	if (ie) { 		document.all["dragdrop"].src="../../images/<%=clientID%>/dragzoomAct.gif";	}	if (ns) {		document.images['dragimage'].src="../images/<%=clientID%>/dragzoomAct.gif";	}	if(nn6){		//document.images["dragdrop"].src="../images/<%=clientID%>/dragzoomAct.gif";	}}function mouseDown(e) {   if(globaldrag!=0){	   // 	window.status="mousedown globaldrag enabled";	if ((ns && e.which != 1) || (ie && event.button != 1) ||(moz && e.which != 1) || (nn6 && e.which != 1)) {		return true; // avoid right-click capture	}		var mouseX = (ns||moz||nn6 ? e.pageX : event.clientX + document.body.scrollLeft);	var mouseY = (ns||moz||nn6 ? e.pageY : event.clientY + document.body.scrollTop);	mouseStartX = mouseX;	mouseStartY = mouseY;		isClick = ((mouseStartX >= minX) && (mouseStartX <= maxX)) && ((mouseStartY >= minY) && (mouseStartY <= maxY));	if(isClick) {				dragactief=1;		showSelection(mouseStartX, mouseStartY);		if (ie) {			document.all[selLayer].style.visibility = "visible";		}		if (ns) {			document.layers[selLayer].visibility = "show";		}		if(nn6){			document.getElementById(selLayer).style.visibility = "visible";		}		return false;	} else { return true;}   }   //return true;}function mouseMove(e) { if(globaldrag !=0){		var mouseX = (ns||moz||nn6 ? e.pageX : event.clientX + document.body.scrollLeft);	var mouseY = (ns||moz||nn6 ? e.pageY : event.clientY + document.body.scrollTop);		isClick = ((mouseX >= minX) && (mouseX <= maxX)) && ((mouseY >= minY) && (mouseY <= maxY));				if(ns){		if (isClick) {			document.layers["dragdrop"].visibility="show";			document.layers["dragdrop"].pageX = (mouseX+5)+"px";			document.layers["dragdrop"].pageY = (mouseY+15)+"px";			} else {			document.layers["dragdrop"].visibility="hidden";			}	}	if(nn6 || ie){		if (isClick) {			document.getElementById("dragdrop").style.visibility="visible";			document.getElementById("dragdrop").style.left = (mouseX+5)+"px";			document.getElementById("dragdrop").style.top = (mouseY+15)+"px";			} else {			document.getElementById("dragdrop").style.visibility="hidden";			}	}//	if(ie){//		document.all["dragdrop"].style.visibility="visible";//		document.all["dragdrop"].style.pixelLeft = mouseX+5;//		document.all["dragdrop"].style.pixelTop = mouseY+15;//	}	//window.status=mouseX+" "+mouseY+ " " + dragactief;	//isClick = ((mouseStartX >= minX) && (mouseStartX <= maxX)) && ((mouseStartY >= minY) && (mouseStartY <= maxY));	if ((dragactief==1)&&(isClick)) {		showSelection(mouseX, mouseY);		dragactief=1;		return false;	}   }   return true;}function mouseUp(e) { 	if(globaldrag!=0){						if ((ns && e.which != 1) || (ie && event.button != 1) ||(moz && e.which != 1)||(nn6 && e.which != 1)) {			return true; // avoid right-click capture		}				var mouseX = (ns||moz||nn6 ? e.pageX : event.clientX + document.body.scrollLeft);		var mouseY = (ns||moz||nn6 ? e.pageY : event.clientY + document.body.scrollTop);		var criteriapart="";			if (isClick) {						var x1 = mouseStartX;			var x2 = mouseX;					x0 = mouseStartX - minX;			y0 = mouseStartY - minY;			x1 = mouseX - minX;			y1 = mouseY - minY;					var mouseMoved = (x1 != x0) || (y1 != y0);			if (ie) {				if (mouseMoved) {				}				document.all[selLayer].style.visibility = "hidden";					}			if (ns) {				if (mouseMoved) {				}				document.layers[selLayer].visibility = "hide";			}			if(nn6){				if(mouseMoved){}				document.getElementById(selLayer).style.visibility = "hidden";			}			if (x1 < 0) x1 = 0;			if ((x1+minX) > maxX) x1 = maxX-minX;			if (y1 < 0) y1 = 0;			if ((y1+minY) > maxY) y1 = maxY-minY;						if(criteriapresent){				criteriapart=generateCriteriaPart()     			}			//document.location.href = uri+"boxminx=" + x0 + "&boxminy=" + y0 + "&boxmaxx=" + x1 + "&boxmaxy=" + y1+"&action=box";			var frm=window.document.forms[0];			if ((x0!=x1)&&(y0!=y1)){			frm.mapaction.value="box";			if(x0<x1){				frm.mapxmin.value=x0;				frm.mapxmax.value=x1;				}else{				frm.mapxmin.value=x1;				frm.mapxmax.value=x0;								}			if (y0<y1){				frm.mapymin.value=y0;				frm.mapymax.value=y1;				}else{				frm.mapymin.value=y1;				frm.mapymax.value=y0;							}				updateSearch();			}			mouseStartX = -1;			mouseStartY = -1;			//dragactief = 0;		}		isClick = false; 	}	return true;}function showSelection(mouseX, mouseY) {	var x1 = mouseStartX;	var x2 = mouseX;	if (x1 > x2) {		var a = x2;		x2 = x1;		x1 = a;	}	if (x1 < minX) x1 = minX;	if (x2 > maxX) x2 = maxX;	var y1 = mouseStartY;	var y2 = mouseY;	if (y1 > y2) {		a = y2;		y2 = y1;		y1 = a;	}	if (y1 < minY) y1 = minY;	if (y2 > maxY) y2 = maxY;	//	if (ie) {//		document.all[selLayer].style.pixelLeft = x1+"px";//		document.all[selLayer].style.pixelTop = y1+"px";//		document.all[selLayer].style.pixelWidth = (x2 - x1)+"px";//		document.all[selLayer].style.pixelHeight = (y2 - y1)+"px";//	}	if (ns) {		document.layers[selLayer].pageX = x1;		document.layers[selLayer].pageY = y1;		document.layers[selLayer].resizeTo(x2-x1,y2-y1);		document.layers[selLayer].clip.width = x2 - x1;		document.layers[selLayer].clip.height = y2 - y1;	}	if(nn6||moz||ie){        document.getElementById(selLayer).style.left = x1+"px";		document.getElementById(selLayer).style.width =(x2 - x1)+"px";		document.getElementById(selLayer).style.top = y1+"px";		document.getElementById(selLayer).style.height = (y2 - y1)+"px";	}		//window.alert(x1 + " " + y1 + " / " +x2  + " " + y2);}//used by imagemapfunction disabledragfunction(){//	globaldrag = 0;}//used by imagemapfunction enabledragfunction(){//	window.alert("enable drag function" + dragactief );//	if (dragactief == 1 ) {//		globaldrag=1;//	}//	else {//		globaldrag = 0;//	}}function disabledrag(){	globaldrag = 0;}function enabledrag(){	globaldrag=1;}/*************************************************** finding x and y **************************************************/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;}// This function finds the vertical position of an element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;}