
var theX,theY;var x1,y1,x2,y2;var zleft,zright,ztop,zbottom;var mtop,mleft,mwidth,mheight,mbroder;var mapDivId1,mapDivId2;var activeTool;var dragging=false;var panning=false;var waitingForResponse=false;function calcSelectEnvelope(){if(selectCount>0){selMaxEnvelope[0]=selectLeft[0];selMaxEnvelope[1]=selectBottom[0];selMaxEnvelope[2]=selectRight[0];selMaxEnvelope[3]=selectTop[0];if(selectCount>1){for(var i=1;i<selectCount;i++){if(selectLeft[i]<selMaxEnvelope[0])selMaxEnvelope[0]=selectLeft[i];if(selectBottom[i]<selMaxEnvelope[1])selMaxEnvelope[1]=selectBottom[i];if(selectRight[i]>selMaxEnvelope[2])selMaxEnvelope[2]=selectRight[i];if(selectTop[i]>selMaxEnvelope[3])selMaxEnvelope[3]=selectTop[i];}}}}
function zoomToReturnedRecords(){calcSelectEnvelope();var fWidth=selMaxEnvelope[2]-selMaxEnvelope[0];var fHeight=selMaxEnvelope[3]-selMaxEnvelope[1];var mWMargin=0;var mHMargin=0;if((fWidth==0)&&(fHeight==0)){mWMargin=fullWidth*selectPointMargin;mHMargin=fullHeight*selectPointMargin;if(mWMargin>xDistance/2){mWMargin=xDistance/2;mHMargin=yDistance/2;}}else{mWMargin=fWidth*selectMargin;mHMargin=fHeight*selectMargin;}
saveLastExtent();eLeft=selMaxEnvelope[0]-mWMargin;eRight=selMaxEnvelope[2]+mWMargin;eTop=selMaxEnvelope[3]+mHMargin;eBottom=selMaxEnvelope[1]-mHMargin;sendMapXML();}
function setMapDivProperties1(top,left,width,height,border,mapId1){mtop=top+border;mleft=left+border;mwidth=width-(2*border);mheight=height-(2*border);mborder=border;mapDivId1=mapId1;}
function setMapDivProperties2(top,left,width,height,border,mapId2){mtop=top+border;mleft=left+border;mwidth=width-(2*border);mheight=height-(2*border);mborder=border;mapDivId1=mapId2;}
function createZoomBoxDivs(){createLayer("zoomboxTop",mleft,mtop,mwidth,mheight,false,"");createLayer("zoomboxBottom",mleft,mtop,mwidth,mheight,false,"");createLayer("zoomboxLeft",mleft,mtop,mwidth,mheight,false,"");createLayer("zoomboxRight",mleft,mtop,mwidth,mheight,false,"");setLayerBackgroundColor("zoomboxTop",zoomBoxColor);setLayerBackgroundColor("zoomboxBottom",zoomBoxColor);setLayerBackgroundColor("zoomboxLeft",zoomBoxColor);setLayerBackgroundColor("zoomboxRight",zoomBoxColor);}
function createOVBoxDivs(){var content='<img name="zoomOVImageTop" src="images/pixel.gif" width=1 height=1>';createLayer("zoomOVBoxTop",OVlayerLeft,OVlayerTop,ovBorderWidth,1,false,content);content='<img name="zoomOVImageLeft" src="images/pixel.gif" width=1 height=1>';createLayer("zoomOVBoxLeft",OVlayerLeft,OVlayerTop,ovBorderWidth,1,false,content);content='<img name="zoomOVImageRight" src="images/pixel.gif" width=1 height=1>';createLayer("zoomOVBoxRight",OVlayerLeft,OVlayerTop,ovBorderWidth,1,false,content);content='<img name="zoomOVImageBottom" src="images/pixel.gif" width=1 height=1>';createLayer("zoomOVBoxBottom",OVlayerLeft,OVlayerTop,ovBorderWidth,1,false,content);setLayerBackgroundColor("zoomOVBoxTop",zoomBoxColor);setLayerBackgroundColor("zoomOVBoxLeft",zoomBoxColor);setLayerBackgroundColor("zoomOVBoxRight",zoomBoxColor);setLayerBackgroundColor("zoomOVBoxBottom",zoomBoxColor);}
function createOVBoxDiv(){if(lang=="NL"){var content='<img name="OVImageBox" id="OVImageBox" src="images/pixel.gif" alt="Klik om je te positioneren" title="Klik om je te positioneren">';}
else{var content='<img name="OVImageBox" id="OVImageBox" src="images/pixel.gif" alt="Cliquez pour vous positioner" title="Cliquez pour vous positioner">';}
createOVBoxLayer("OVBox",OVlayerLeft,OVlayerTop,mwidth,mheight,false,content);}
function putOVBox(){var vright=i2BoxWidth+OVlayerLeft;var vbottom=i2BoxHeight+OVlayerTop;clipLayer("OVBox",OVlayerLeft,OVlayerTop,vright,vbottom);showLayer("OVBox");}
function putExtentOnOVMap(){var ovXincre=fullOVWidth/i2Width;var ovYincre=fullOVHeight/i2Height;var vleft=Math.ceil((minx-fullOVLeft)/(ovXincre+ovBorderWidth))+OVlayerLeft;var vright=Math.ceil((maxx-fullOVLeft)/(ovXincre+ovBorderWidth))+OVlayerLeft;var vtop=Math.ceil((fullOVTop-maxy)/(ovYincre+ovBorderWidth))+OVlayerTop;var vbottom=Math.ceil((fullOVTop-miny)/(ovYincre+ovBorderWidth))+OVlayerTop;clipOVLayer("zoomOVBoxTop",vleft,vtop-ovExtentBoxSize,vright,vtop);showOVLayer("zoomOVBoxTop");clipOVLayer("zoomOVBoxLeft",vleft-ovExtentBoxSize,vtop-ovExtentBoxSize,vleft,vbottom);showOVLayer("zoomOVBoxLeft");clipOVLayer("zoomOVBoxRight",vright,vtop-ovExtentBoxSize,vright+ovExtentBoxSize,vbottom);showOVLayer("zoomOVBoxRight");clipOVLayer("zoomOVBoxBottom",vleft,vbottom-ovExtentBoxSize,vright+1,vbottom);showOVLayer("zoomOVBoxBottom");}
function clipOVLayer(name,clipleft,cliptop,clipright,clipbottom){var layer=getLayer(name);if((clipright.isNaN)||(clipleft.isNaN)||(cliptop.isNaN)||(clipbottom.isNaN))
{layer.visibility="hidden";}
else
{var newWidth=clipright-clipleft;var newHeight=clipbottom-cliptop;if((newWidth<=0)||(newHeight<=0))
{layer.visibility="hidden";}
else
{layer.height=newHeight;layer.width=newWidth;layer.top=cliptop+"px";layer.left=clipleft+"px";layer.visibility="visible";}}}
function showOVLayer(name){var layer=document.getElementById(name);layer.visibility="visible";}
function ovMapClick(x,y){if(!hideMinButton){var ovWidth=i2Width;var ovHeight=i2Height;var ovXincre=fullOVWidth/ovWidth;var ovYincre=fullOVHeight/ovHeight;var ovX=x;var ovY=ovHeight-y;var ovmapX=ovX*ovXincre+fullOVLeft;var ovmapY=ovY*ovYincre+fullOVBottom;xDistance=Math.abs(maxx-minx);yDistance=Math.abs(maxy-miny);var xHalf=xDistance/2;var yHalf=yDistance/2;minx=ovmapX-xHalf;maxx=ovmapX+xHalf;miny=ovmapY-yHalf;maxy=ovmapY+yHalf;checkFullExtent();var env='<ENVELOPE minx="'+minx+'" miny="'+miny+'" maxx="'+maxx+'" maxy="'+maxy+'" />';get2mapsWithCurrentExtent();}}
function ovMap2Click(e){getOVImageXY(e);ovMapClick(mouseX,mouseY);}
function getOVImageXY(e){if(isNav){mouseX=e.pageX;mouseY=e.pageY;}else{mouseX=event.clientX+document.body.scrollLeft;mouseY=event.clientY+document.body.scrollTop;}
mouseX=mouseX-OVlayerLeft;mouseY=mouseY-OVlayerTop;}
function pointClick(e){getXY(e);var x1=theX-mleft;var y1=theY-mtop;identify(x1,y1);return false;}
function resetAfterPan(){moveLayer(mapDivId1,0,0);clipLayer2(mapDivId1,0,0,mwidth,mheight);document.getElementById('theImage1').onload=null;}
function createOVBoxLayer(name,inleft,intop,width,height,visible,content){var layer;if(lang=="NL"){document.writeln('<div id="'+name+'" class="OVBox" title="Klik om je te positioneren binnen de kaartgrenzen" onmousedown="ovMap2Click(event)"; style="position:absolute; overflow:hidden; left:'+inleft+'px; top:'+intop+'px; width:'+width+'px; height:'+height+'px;'+'; z-index:11; visibility:'+(visible?'visible;':'hidden;')+'">');}
else{document.writeln('<div id="'+name+'" class="OVBox" title="Cliquez pour vous positioner" onmousedown="ovMap2Click(event)"; style="position:absolute; overflow:hidden; left:'+inleft+'px; top:'+intop+'px; width:'+width+'px; height:'+height+'px;'+'; z-index:11; visibility:'+(visible?'visible;':'hidden;')+'">');}
document.writeln(content);document.writeln('</div>');}
function createLayer(name,inleft,intop,width,height,visible,content){var layer;document.writeln('<div id="'+name+'" style="position:absolute; overflow:hidden; left:'+inleft+'px; top:'+intop+'px; width:'+width+'px; height:'+height+'px;'+'; z-index:11; visibility:'+(visible?'visible;':'hidden;')+'">');document.writeln(content);document.writeln('</div>');}
function getLayer(name){var theObj=document.getElementById(name);if(theObj!=null){return theObj.style}else{return(null);}}
function isVisible(name){var layer=getLayer(name);if(isNav&&layer.visibility=="show")
return(true);if(isIE&&layer.visibility=="visible")
return(true);return(false);}
function getXY(e){if(isNav){theX=e.pageX;theY=e.pageY;}else{theX=event.clientX+document.body.scrollLeft;theY=event.clientY+document.body.scrollTop;}
return false;}
function getImageXY(e){if(isNav){mouseX=e.pageX;mouseY=e.pageY;}else{mouseX=event.clientX+document.body.scrollLeft;mouseY=event.clientY+document.body.scrollTop;}
mouseX-=hspc;mouseY-=vspc;}
function moveLayer(name,x,y){var layer=getLayer(name);layer.left=x+"px";layer.top=y+"px";}
function setLayerBackgroundColor(name,color){var layer=getLayer(name);layer.backgroundColor=color;}
function hideLayer(name){var layer=getLayer(name);layer.visibility="hidden";}
function showLayer(name){var layer=getLayer(name);layer.visibility="visible";}
function clipLayer2(name,clipleft,cliptop,clipright,clipbottom){var layer=getLayer(name);layer.clip='rect('+cliptop+' '+clipright+' '+clipbottom+' '+clipleft+')';}
function clipLayer(name,clipleft,cliptop,clipright,clipbottom){var layer=getLayer(name);var newWidth=clipright-clipleft;var newHeight=clipbottom-cliptop;layer.height=newHeight;layer.width=newWidth;layer.top=cliptop+"px";layer.left=clipleft+"px";}
function panClipLayer(name,clipleft,cliptop,clipright,clipbottom){var layer=getLayer(name);if(layer!=null){layer.clip='rect('+cliptop+' '+clipright+' '+clipbottom+' '+clipleft+')';}
return false;}
var isMoving=false;var idx,idy;var idLayer;function startMove(e,divId){idLayer=document.getElementById(divId);isMoving=true;getXY(e);idx=theX-idLayer.offsetLeft;idy=theY-idLayer.offsetTop;document.onmousemove=updateMove;document.onmouseup=stopMove;}
function updateMove(e){if(!isMoving||(idLayer==null))return;getXY(e);idLayer.style.left=theX-idx;idLayer.style.top=theY-idy;if(idLayer.offsetLeft<0)
idLayer.style.left=0;if(idLayer.offsetTop<0)
idLayer.style.top=0;}
function stopMove(){if(!isMoving||(idLayer==null))return;idLeft=idLayer.offsetLeft;idTop=idLayer.offsetTop;isMoving=false;idLayer=null;}
var teleCoordSys=-9999;function writemousestring(mouseString){return false;}
function showMouseString(mouseString){document.getElementById("XYcoord").innerHTML=mouseString;}
function showScale(){document.getElementById("theScale").innerHTML="Schaal: 1:"+Math.round(teleScale);}
function hideMouseString(){document.getElementById("XYcoord").innerHTML="";}
