var objectRef=null,contourRef=null,x=null,y=null,isNS=false;if(navigator.appName.toLowerCase().indexOf("microsoft")<0)isNS=true;var isPreIE7=false;if(!isNS){var fullVersionIE=parseFloat(navigator.userAgent.substring(versionOffset+5,navigator.userAgent.length));isPreIE7=parseInt(fullVersionIE)<7}var par_left=0,par_top=0;74;var xpos=0,ypos=0,chartID=0,windowSet=0,x_cnt=null,y_cnt=null,isOnContour=0,isOnChart=0,newWidth=1024,newHeight=768,menuHeight,tracing=false,chartMode="move",mercator=1,transmercator=2,polyconic=3,lambert=4,stereographic=5,chartType=mercator,scrollParams,mapFixedDiv,mapMovingDiv,chart,contour,contourWidth,pos,contourHolderDiv=100,xR,yR,jg,mapW=0,mapH=0,mapFixedDivOffsets,initT=0,hasTiles=false,prm,isWk=false,isCutOut=false,isGE=false,mkk="ctl00_mainContent_mark",mkk_only="ctl00_mainContent_members_only",wkLayer="",avW=screen.width,avH=screen.height,isMeas=false,isSlow=false,initialized=false,tide="https://easytide.ukho.gov.uk/EASYTIDE/EasyTide/ShowPrediction.aspx?PredictionLength=7&DaylightSavingOffset=0&PrinterFriendly=True&HeightUnits=0&GraphSize=7&PortID=",boat="http://www.boatlaunch.co.uk/default.aspx?page=display&nodeid=",guru="http://www.windguru.cz/int/index.php?go=1&vs=1&sc=",light="http://www.lighthousefriends.com/light.asp?ID=",popL,popT,popW,popH;function initChart(){if(location.href.toLowerCase().indexOf("measure.aspx")>=0)isMeas=true;else isMeas=false;if(location.href.toLowerCase().indexOf("wreck.aspx")>=0)isWk=true;else isWk=false;if(location.href.toLowerCase().indexOf("googleearth.aspx")>=0){isWk=false;isGE=true}if(typeof document.getElementById("googleMap")!="undefined")if(document.getElementById("googleMap"))isGE=true;if(typeof document.getElementById("admintiles")!="undefined")if(document.getElementById("admintiles"))isSlow=true;if(typeof document.getElementById("tiles")!="undefined")if(document.getElementById("tiles")!=null)hasTiles=true;var d=document.getElementsByTagName("body"),h=document.getElementsByTagName("html");if(hasTiles&&!isWk){d[0].style.overflow="hidden";d[0].style.visibility="visible";h[0].style.overflow="hidden";var g=document.getElementById(mapFixedDivID);if(window.addEventListener)g.addEventListener("DOMMouseScroll",wheel,false);else g.onmousewheel=wheel;if(cutOut.length!=0)isCutOut=true;if(initT==0){prm=Sys.WebForms.PageRequestManager.getInstance();prm.add_endRequest(reload)}}if(typeof chartimage!="undefined")if(document.getElementById(chartimage)){chart=document.getElementById(chartimage);mapMovingDiv=document.getElementById(mapMovingDivID);mapFixedDiv=document.getElementById(mapFixedDivID);wkLayer=document.getElementById("ctl00_mainContent_wrecks");pos=document.getElementById(coord);xR=document.getElementById(xRealID);yR=document.getElementById(yRealID);if(isCutOut)chartMode="move";initializeEvents();if(!isWk){document.getElementById("calibrator").style.width=parseInt(window.screen.width)+"px";setmapFixedDivWidthAndHeight();contourHolderDiv=200;removePreviousPolys();if(typeof xArrays!="undefined")xArrays.length>0&&drawPols(xArrays,yArrays,tArrays,fxArrays,fyArrays,idArrays)}else{popL=parseInt(screen.width/2);popT=0;popW=popL;popH=parseInt(screen.height);chartMode="move";newWidth=parseInt(mapFixedDiv.style.width);newHeight=parseInt(mapFixedDiv.style.height)}mapW=parseInt(mapFixedDiv.style.width);mapH=parseInt(mapFixedDiv.style.height);offsets=calcOffsets(mapFixedDiv);centerToX=centerToX+chXBorder;centerToY=centerToY+chYBorder;if(centerToX!=null&&centerToY!=null&&xR!=null&&yR!=null)if(centerToX!=xR.value||centerToY!=yR.value){centerToX=parseInt(xR.value);centerToY=parseInt(yR.value)}mapMovingDiv.style.left=parseInt(mapW/2-centerToX)+"px";mapMovingDiv.style.top=parseInt(mapH/2-centerToY)+"px";if(document.getElementById("contour")){contour=document.getElementById("contour");if(typeof document.getElementById("smallChart")!="undefined")if(document.getElementById("smallChart")!=null){var j=document.getElementById("smallChart");j.onclick=moveChart}contour.style.width=parseInt(Math.round(contourHolderDiv*mapW/imgRealWidth))+"px";contourWidth=parseInt(contour.style.width);contour.style.height=parseInt(Math.round(contourWidth*(mapH/mapW)))+"px";contour.style.left=parseInt(Math.round((centerToX-mapW/2)*(contourWidth/mapW)))+"px";contour.style.top=parseInt(Math.round((centerToY-mapH/2)*(contourWidth/mapW)))+"px";contour.style.display="block"}var e=calcOffsets(mapMovingDiv);par_left=parseInt(-(mapW/2-centerToX)+parseInt(mapFixedDiv.style.borderWidth)*2+e[0]);par_top=parseInt(-(mapH/2-centerToY)+parseInt(mapFixedDiv.style.borderWidth)*2+e[1]);if(typeof selectedArea!="undefined")if(selectedArea)if(document.getElementById(selectedArea)){var f=document.getElementById(selectedArea);if(f.value.indexOf(",")>0){var a=f.value.split("|"),b=document.getElementById("lin");b.style.top=Math.min(a[1],a[3])+"px";b.style.left=Math.min(a[0],a[2])+"px";b.style.width=Math.abs(a[0]-a[2])+"px";b.style.height=Math.abs(a[1]-a[3])+"px";b.style.visibility="visible";var c=document.getElementById("lininfo");c.style.visibility="visible";c.innerHTML=a[4]+"<br />"+a[5];c.style.left=parseInt(parseInt(b.style.left)+parseInt(b.style.width)/2)+"px";c.style.top=parseInt(b.style.top)+parseInt(b.style.height)+10+"px"}}}checkTiles();SetupMenuForIE6();if(typeof document.getElementById("dist")!="undefined")if(document.getElementById("dist")!=null){var i=document.getElementById("dist");i.style.width="200px"}if(isGE&&!isWk){d[0].style.overflow="hidden";d[0].style.visibility="visible";h[0].style.overflow="hidden";mapFixedDiv=document.getElementById(mapFixedDivID);newWidth=parseInt(window.screen.width)-5;newHeight=parseInt(document.body.offsetHeight)-55;if(newHeight<0)newHeight=0;document.getElementById("googleWidthSpacer").width=newWidth+"px";document.getElementById("googleHeightSpacer").height=newHeight+"px";mapFixedDiv.style.height=newHeight+"px";mapFixedDiv.style.width=newWidth+"px"}}function reload(b,a){loadTileParameters();initT=1;initChart();if(a.get_error()!=undefined)if(a.get_response().get_statusCode()=="12007"||a.get_response().get_statusCode()=="12029"){alert("Please make sure you are connected to internet");return false}}function initializeEvents(){mapMovingDiv.onmousedown=catchMouseDownEvents;mapMovingDiv.onmousemove=catchMouseMoveEvents;mapMovingDiv.onmouseup=catchMouseUpEvents;mapMovingDiv.onmouseover=catchMouseOverEvents;mapMovingDiv.onmouseout=catchMouseOutEvents;mapMovingDiv.onclick=catchMouseClickEvents;mapMovingDiv.onkeydown=getDownKey;mapMovingDiv.onkeyup=cancelDownKey}var keyDepressed=0,moveWk=null,moveDiv=null,wk_init=[];function getDownKey(a){if(!a)a=window.event;if(a.keyCode==16)keyDepressed=16;return true}function cancelDownKey(a){if(!a)a=window.event;if(a.keyCode==16){keyDepressed=0;chartMode="move";moveWk=null;moveDiv=null}return true}function catchMouseDownEvents(a){if(keyDepressed==16){element=getTargetTillParentWithID(a);if(chartMode!="moveWk"&&element.id.toLowerCase().indexOf("wk")>=0){chartMode="moveWk";moveWk=document.getElementById(element.id);wk_init[0]=parseInt(moveWk.style.left);wk_init[1]=parseInt(moveWk.style.top)}}if(chartMode=="move"||chartMode=="moveWk"||chartMode=="moveDiv"||chartMode=="mark"||chartMode=="poly")down(a);else{statusM=true;startM=true;lstart(a)}if(chartMode=="bear")jg&&jg.clear();return false}function catchMouseMoveEvents(a){if(!isPreIE7)displayPosition(a);else!startM&&displayPosition(a);if(chartMode=="move"||chartMode=="moveWk"||chartMode=="moveDiv"||chartMode=="mark")move(a);else startM&&ldraw(a);if(isWk)if(chartMode=="move"){var b=[];b=getCursorPos(a);var c=getScrollXY();popT=b[1]+c[1]}return false}var cur_down=[],cur_up=[];function down(a){if(chartMode=="move"){objectRef=mapMovingDiv;chart.style.cursor="move";isOnContour=0;if(isOnChart==0)isOnChart=1}cur_down=getCursorPos(a);return false}function setMoveDiv(a){chartMode="moveDiv";moveDiv=document.getElementById("iframeDiv");moveDiv.onmousemove=doMoveDiv;moveDiv.onmouseup=up;cur_down=getCursorPos(a);return false}function move(a){switch(chartMode){case "move":isOnChart==1&&doMoveChart(a);break;case "moveWk":doMoveWk(a);break;case "moveDiv":doMoveDiv(a)}return false}function doMoveChart(a){if(objectRef!=null){cur_up=getCursorPos(a);posx=parseInt(mapMovingDiv.style.left)+cur_up[0]-cur_down[0];posy=parseInt(mapMovingDiv.style.top)+cur_up[1]-cur_down[1];mapMovingDiv.style.left=posx+"px";mapMovingDiv.style.top=posy+"px";xR.value=parseInt(-posx+parseInt(mapFixedDiv.style.width)/2);yR.value=parseInt(-posy+parseInt(mapFixedDiv.style.height)/2);if(document.getElementById("contour")){var b=-posx/(mapW/contourWidth),c=-posy/(mapW/contourWidth);contour.style.left=parseInt(b)+"px";contour.style.top=parseInt(c)+"px"}chart.style.cursor="move";cur_down=getCursorPos(a)}return false}function doMoveWk(a){if(moveWk!=null){cur_up=getCursorPos(a);posx=parseInt(moveWk.style.left)+cur_up[0]-cur_down[0];posy=parseInt(moveWk.style.top)+cur_up[1]-cur_down[1];moveWk.style.left=posx+"px";moveWk.style.top=posy+"px";cur_down=getCursorPos(a)}return false}function doMoveDiv(a){if(moveDiv!=null){cur_up=getCursorPos(a);posx=parseInt(moveDiv.style.left)+cur_up[0]-cur_down[0];posx=parseInt(moveDiv.style.left)+cur_up[0]-cur_down[0];posy=parseInt(moveDiv.style.top)+cur_up[1]-cur_down[1];moveDiv.style.left=posx+"px";moveDiv.style.top=posy+"px";cur_down=getCursorPos(a);popL=posx;popT=posy}return false}function up(){if(isOnChart==1){checkTiles();objectRef=null;chart.style.cursor="crosshair"}switch(chartMode){case "moveWk":keyDepressed=0;chartMode="move";var b=moveWk.id.replace("wk",""),a=parseInt(moveWk.style.left),c=parseInt(moveWk.style.top);if(confirm("do you want to move ?"))doPostBackAsync("changePos",b+";"+a+";"+c+";"+xR.value+";"+yR.value);else{moveWk.style.left=wk_init[0]+"px";moveWk.style.top=wk_init[1]+"px"}moveWk=null;break;case "moveDiv":chartMode="move";moveDiv=null}return false}function catchMouseUpEvents(a){var c=getTargetTillParentWithID(a),b=c.id.substring(0,2);if(b.indexOf("mk")<0&&b.substring(0,2).indexOf("ho")<0)if(chartMode=="move"||chartMode=="moveWk"||chartMode=="mark"||chartMode=="moveDiv")up(a);else{startM=false;lstop(a)}else{isOnChart=0;chartMode=="mark"}return false}function catchMouseOverEvents(b){if(chartMode!="moveWk"&&chartMode!="moveDiv"&&!startM){var a=getTargetTillParentWithID(b),c=a.id.substring(2);switch(a.id.substring(0,2)){case "wk":wreck_onmouseover(a);break;case "uk":a.title="ukho report "+c;break;case "im":wreckImage_onmouseover(a);break;case "c_":subchart_onmouseover(b);break;case "mw":wreck_onmouseover(a);break}}return false}function catchMouseOutEvents(b){if(chartMode!="moveWk"&&chartMode!="moveDiv")if(!startM){var a=getTargetTillParentWithID(b);switch(a.id.substring(0,2)){case "wk":wreck_onmouseout(a);break;case "im":wreckImage_onmouseout(a);break;case "c_":subchart_onmouseout(b);break;case "mw":wreck_onmouseout(a)}}return false}function catchMouseClickEvents(b){if(chartMode=="mark")enterMark(b);else if(!startM&&chartMode!="moveWk"&&chartMode!="moveDiv"){var a=getTargetTillParentWithID(b);switch(a.id.substring(0,2)){case "wk":oCw(a.id.replace("wk",""),true,1,false);break;case "uk":oCw(a.id.replace("uk",""),true,0,false);break;case "im":wreckImage_onclick(a.title);break;case "c_":subchart_onclick(b);break;case "mk":chartMode="mark";doPostBackAsync("editMark",a.id);break;case "re":var c=document.getElementById(a.id);c.style.display="none";return true;break;case "ho":chartMode="mark";doPostBackAsync("editMark",a.id)}}if(chartMode=="poly")a.id.indexOf("chartimage")>=0&&drawBall(b);return false}var xArray=[],yArray=[],ballFocus=false,rad=3,polyGonClosed=false;function getXY(b){scrollParams=getScrollXY();offsets=calcOffsets(mapFixedDiv);var c=mapMovingDiv;if(!isNS)b=window.event;var d=b.clientX-parseInt(c.style.left)+scrollParams[0]-offsets[0],e=b.clientY-parseInt(c.style.top)+scrollParams[1]-offsets[1],a=[];a[0]=d;a[1]=e;return a}var jg_edit;function drawBall(g){if(!polyGonClosed){if(typeof jg_edit=="undefined")jg_edit=new jsGraphics(mapMovingDiv);jg_edit.setColor("#FF0000");var a=getXY(g),h=a[0],i=a[1],d=a[0]-rad,c=a[0]-2*rad,f=a[1]-rad,e=a[1]-2*rad;xArray[xArray.length]=a[0];yArray[yArray.length]=a[1];xArray.length>=2&&jg_edit.drawLine(xArray[xArray.length-2],yArray[xArray.length-2],xArray[xArray.length-1],yArray[xArray.length-1]);jg_edit.fillEllipse(d,f,2*rad,2*rad);jg_edit.paint();var b=document.createElement("div");b.setAttribute("style","padding:0px;z-index:100;cursor:pointer;background-image:url(../img/nav/wreck.gif);background-repeat:repeat;z-index:100;width:"+4*rad+"px;height:"+4*rad+"px;border:0px solid black;position:absolute;top:"+e+"px;left:"+c+"px;");b.setAttribute("class","f0p");if(xArray.length==1){b.setAttribute("onmouseover","ballHover(event)");b.setAttribute("onmouseout","ballUnHover(event)");b.setAttribute("onclick","ballClick(event)");ballFocus=false}else ballFocus=true;mapMovingDiv.appendChild(b)}return false}function ballHover(){ballFocus&&paintBall("#FFFF00")}var jg_polys,registered_tits;function removePreviousPolys(){var b=document.getElementById("ctl00_mainContent_map");typeof jg_polys!="undefined"&&jg_polys.clear();if(registered_tits!=null)for(i=0;i<registered_tits.length;i++){var a=registered_tits[i];if(typeof a!="undefined")if(a!=null)try{b.removeChild(a)}catch(c){break}}}function drawPols(a,e,m,o,p,q){var c=document.getElementById("ctl00_mainContent_map");jg_polys=new jsGraphics(c);jg_polys.setStroke(1);jg_polys.setColor("#FF0000");var b=[];for(i=0;i<a.length;i++){var d=q[i].toString(),g="poly_"+d,k=d.indexOf("_")<0;for(j=0;j<a[i].length;j++){var f=j-1;if(j==0)f=a[i].length-1;jg_polys.drawLine(a[i][j],e[i][j],a[i][f],e[i][f]);jg_polys.fillEllipse(a[i][j]-rad,e[i][j]-rad,2*rad,2*rad);if(!k){var l=createButton(g+i.toString()+j.toString(),d+i.toString()+j.toString(),m[i],e[i][j]-20,a[i][j]+20);c.appendChild(l);b[b.length]=l}}var h=document.getElementById(g);if(typeof h!="undefined")h!=null&&c.removeChild(h);if(k){var n=createButton(g,d,m[i],p[i],o[i]);c.appendChild(n)}b[b.length]=n}jg_polys.paint();if(b.length>0)registered_tits=b}function createButton(c,b,d,f,e){var a=document.createElement("div");a.setAttribute("id",c);a.innerHTML="<input id='"+b+"' type='button' value='"+d+"' style='background-color:#FFFF00;position:absolute;top:"+f+"px;left:"+e+"px;border:1px solid #000000;cursor:pointer !important;z-index:200;' onclick=doPostBackAsync('filterPoly','"+b+"') />";return a}function savePoly(){if(xArray.length>=3){var b="";for(i=0;i<xArray.length;i++)b+=xArray[i]+";"+yArray[i]+"|";var a=document.getElementById("polyValue");a=a.value;if(a!=""){removeWindow("savePoly");changeChartMode("move");polyGonClosed=false;xArray=[];yArray=[];jg_edit.clear();doPostBackAsync("savePoly",a+"&"+b)}}}function paintBall(b){jg_edit.setColor(b);var d=xArray[0]-rad,c=xArray[0]-2*rad,f=yArray[0]-rad,e=yArray[0]-2*rad;jg_edit.fillEllipse(d,f,2*rad,2*rad);jg_edit.paint();var a=document.createElement("div");a.setAttribute("style","z-index:100;padding:0px;cursor:pointer;background-image:url(../img/nav/wreck.gif);background-repeat:repeat;z-index:100;width:"+4*rad+"px;height:"+4*rad+"px;border:0px solid black;position:absolute;top:"+e+"px;left:"+c+"px;");a.setAttribute("class","f0p");a.setAttribute("onmouseover","ballHover(event)");a.setAttribute("onmouseout","ballUnHover(event)");a.setAttribute("onclick","ballClick(event)");mapMovingDiv.appendChild(a)}function ballUnHover(){ballFocus&&paintBall("#FF0000")}function ballClick(f){if(ballFocus){var e=getXY(f),a=document.createElement("div");a.setAttribute("id","confirmPoly");var b=document.createElement("input");b.setAttribute("type","button");b.setAttribute("class","displayButton");b.setAttribute("value","YES");var c=document.createElement("input");c.setAttribute("type","button");c.setAttribute("class","displayButton");c.setAttribute("value","NO");b.setAttribute("onclick","ballSave(event);removeWindow('confirmPoly');");c.setAttribute("onclick","removeWindow('confirmPoly');");var d=document.createElement("div");d.innerHTML="do you want to close the polygon and save it?<br /><br />";a.appendChild(d);a.appendChild(b);a.appendChild(c);a.setAttribute("style","position:absolute;top:"+(e[1]+10)+"px;left:"+(e[0]+10)+"px;background-color: #FFFFFF; border: 0.1em solid #000099;width:150px;height:60px;padding:4px;z-index:100;");mapMovingDiv.appendChild(a)}}function ballSave(){jg_edit.setColor("#FF0000");jg_edit.drawLine(xArray[xArray.length-1],yArray[xArray.length-1],xArray[0],yArray[0]);jg_edit.paint();polyGonClosed=true;var d=document.getElementById("confirmPoly"),a=document.createElement("div");a.setAttribute("id","savePoly");var f=document.createTextNode("give the polygon a name:"),e=document.createElement("div");e.innerHTML="<input type='text' id='polyValue' name='polyValue' value='' class='w150' value='polygon' />";var c=document.createElement("input");c.setAttribute("type","button");c.setAttribute("class","displayButton");c.setAttribute("value","SAVE");var b=document.createElement("input");b.setAttribute("type","button");b.setAttribute("class","displayButton");b.setAttribute("value","CANCEL");c.setAttribute("onclick","savePoly(event)");b.setAttribute("onclick","removeWindow('confirmPoly');removeWindow('savePoly');");a.appendChild(f);a.appendChild(e);a.appendChild(c);a.appendChild(b);a.setAttribute("style","position:absolute;top:"+parseInt(d.style.top)+"px;left:"+parseInt(d.style.left)+"px;background-color: #FFFFFF; border: 0.1em solid #000099;width:150px;height:60px;padding:4px;z-index:100;");mapMovingDiv.appendChild(a);var g=document.getElementById("polyValue");g.focus()}function removeWindow(b){var a=document.getElementById(b);a!=null&&mapMovingDiv.removeChild(a);return false}function changeChartMode(b){var a=null;if(b=="mark")a=document.getElementById(markButton);else a=document.getElementById(b);if(a.src.indexOf("_off")>0)chartMode=b;if(a.src.indexOf("_on.gif")>=0&&b!="mark")chartMode="move";for(var e=["move","rect","bear","poly"],d=0;d<e.length;d++){var f=document.getElementById(e[d]);f.src=f.src.replace("_on","_off")}if(a.src.indexOf("_on.gif")>=0&&b!="mark")chartMode="move";var c=null;if(chartMode!="mark"){c=document.getElementById(chartMode);c.src=c.src.replace("_off","_on")}initializeEvents()}function changeDis(a){posdis=a}function changePop(a){popup=a}function displayPosition(c){if(mapMovingDiv)if(getPos(c)){mapMovingDiv.style.cursor="crosshair";rad2deg(latStop,true);var a=hr;rad2deg(lonStop,false);var b=hr;pos.innerHTML=getDispTable(a,b);userLat!=0&&userLon!=0&&showHome(latStop,lonStop)}else{mapMovingDiv.style.cursor="default";pos.innerHTML=" out of range "}return false}function showHome(j,k){if(!isWk){var g=40030.1736/(2*Math.PI),c,b,l,m;c=userLat*Math.PI/180;b=j*Math.PI/180;longhrStart=userLon*Math.PI/180;longhrStop=k*Math.PI/180;distKm=g*Math.acos(Math.sin(c)*Math.sin(b)+Math.cos(c)*Math.cos(b)*Math.cos(longhrStop-longhrStart));distNm=distKm/1.852;distNm=Math.round(10*distNm)/10;var a=Math.atan2(Math.sin(longhrStop-longhrStart)*Math.cos(b),Math.cos(c)*Math.sin(b)-Math.sin(c)*Math.cos(b)*Math.cos(longhrStop-longhrStart));a=Math.round(a*180/Math.PI,1);if(a<0)a=360+a;if(a>338)bearSt[0]=360;else bearSt[0]=0;var d=0,e=Math.abs(a-bearSt[0]);for(i=0;i<bearSt.length;i++)if(Math.abs(a-bearSt[i])<e){d=i;e=Math.abs(a-bearSt[i])}var h=bearArr[d],f=document.getElementById("dist");f.innerHTML="DIST: "+distNm+" nm  BEAR: "+a+" "+h}return false}function checkTiles(){if(!isMeas&&isSlow&&!isWk){var g=neededTiles;doNeededTiles();g!=neededTiles&&initialized&&doPostBackAsync("fetchtiles",neededTiles);initialized=true}if(hasTiles&&xR!=null){var n=[],b,a;if(!isCutOut){var k=parseInt(xR.value)-newWidth/2,h=parseInt(xR.value)+newWidth/2,m=parseInt(yR.value)-newHeight/2,l=parseInt(yR.value)+newHeight/2,c=Math.max(parseInt(k/tdw),0),e=Math.min(parseInt(h/tdw),cols-1),d=Math.max(parseInt(m/tdh),0),f=Math.min(parseInt(l/tdh),rows-1);if(e<c)e=c+1;if(f<d)f=d+1;for(i=d;i<=f;i++)for(j=c;j<=e;j++){a=tileBase+"_"+j+"_"+i;b=document.getElementById(a);if(b)b.src=tileLoc+a+imgExt}}else{a=tileBase+"_0_0";b=document.getElementById(a);b.src=cutOut}}}var neededTiles="";function doNeededTiles(){var c=Math.floor((parseInt(xR.value)-avW/2)/tdw),d=Math.floor((parseInt(yR.value)-avH/2)/tdh),a=Math.floor((parseInt(xR.value)+avW/2)/tdw),b=Math.floor((parseInt(yR.value)+avH/2)/tdh);if(c<0)c=0;if(c>cols-1)c=cols-1;if(d<0)d=0;if(d>rows-1)d=rows-1;if(a<0)a=0;if(a>cols-1)a=cols-1;if(b<0)b=0;if(b>rows-1)b=rows-1;neededTiles=c+";"+a+";"+d+";"+b}var x0,y0,x1,y1,xx1,yy1,xx0,yy0;x0=y0=x1=y1=ww1=yy1=xx0=yy0=0;var wl=50,hl=50,topl=10,leftl=10,startM=false,statusM=false,meas_start,meas_stop;function start_meas(){mode=chartMode;if(typeof chartimage!="undefined")if(document.getElementById(chartimage)!=null){din=document.getElementById("distinfo");bin=document.getElementById("bearinginfo");meas=document.getElementById("measDiv")}}function lstart(a){if(statusM){scrollParams=getScrollXY();offsets=calcOffsets(mapFixedDiv);if(!isNS)a=window.event;x0=a.clientX-parseInt(mapMovingDiv.style.left)+scrollParams[0]-offsets[0]-3;y0=a.clientY-parseInt(mapMovingDiv.style.top)+scrollParams[1]-offsets[1]-3;if(x0<0)x0=0;if(y0<0)y0=0;getPos(a);latStart=latStop;latDispStart=latDispStop;lonStart=lonStop;lonDispStart=lonDispStop;meas_start=getCursorPos(a)}return false}function lstop(){startM=false;return false}var newPostBack;function ldraw(a){scrollParams=getScrollXY();offsets=calcOffsets(mapFixedDiv);if(startM){var n=mapMovingDiv;if(!isNS)a=window.event;x1=a.clientX-parseInt(n.style.left)+scrollParams[0]-offsets[0]-3;y1=a.clientY-parseInt(n.style.top)+scrollParams[1]-offsets[1]-3;if(x1<0)x1=0;if(y1<0)y1=0;var x=document.getElementById("lin"),m=document.getElementById("distinfo"),l=document.getElementById("bearinginfo");getPos(a);calc_pos();var p="<input id='canc' type='button' class='button' onclick='jg.clear();' value='cancel' />";if(chartMode=="rect"){var i=Math.min(y0,y1),g=Math.min(x0,x1),d=Math.abs(x0-x1),b=Math.abs(y0-y1);if(d<0)d=0;if(b<0)b=0;if(jg)jg!==null&&jg.clear();jg=new jsGraphics(wkLayer);jg.setColor("#FF0000");jg.setStroke(1);jg.drawRect(g,i,d,b);var e,f,r=document.getElementById(bLatMax).value,t=document.getElementById(bLongMin).value,s=document.getElementById(bLatMin).value,u=document.getElementById(bLongMax).value;jg.paint();meas_stop=getCursorPos(a);if(meas_stop[1]>meas_start[1])f=meas_stop[1]+10;else f=meas_stop[1]-60;if(meas_stop[1]>meas_start[0])e=meas_stop[0]+10;else e=meas_stop[0]-150-10;e=Math.min(meas_start[0],meas_stop[0])+5;f=Math.max(meas_start[1],meas_stop[1])+5;var h=document.getElementById(expDiv);h.style.display="block";h.style.left=e+"px";h.style.top=f+"px";var q=document.getElementById(infExp);q.value="?la1="+r+"?lo1="+t+"?la2="+s+"?lo2="+u+"?w="+newWidth+"?h="+newHeight+"?topLx="+g+"?topLy="+i+"?botRx="+(g+d)+"?botRy="+(i+b)}else{if(jg)jg!==null&&jg.clear();jg=new jsGraphics(wkLayer);jg.setColor("#00FF00");jg.setStroke(1);jg.drawLine(x0-5,y0,x0+5,y0);jg.drawLine(x0,y0-5,x0,y0+5);jg.setColor("#FF0000");jg.drawLine(x1-5,y1,x1+5,y1);jg.drawLine(x1,y1-5,x1,y1+5);jg.setColor("#0000FF");jg.drawLine(x0,y0,x1,y1);var c=parseInt(Math.sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)));jg.setColor("#FF0000");jg.drawEllipse(x0-c,y0-c,2*c,2*c);jg.setColor("#FFFFFF");var w=m.innerHTML+" "+l.innerHTML,o=w.length,v=o*4,j,k;if(y1>y0)k=y1+20;else k=y1-20;if(x1>x0)j=x1+20;else j=x1-v-20;jg.drawString("<ul class='bearInfo'><li>"+m.innerHTML+"</li><li>"+l.innerHTML+"</li><li>"+p+"</li></ul>",j,k);jg.paint()}return false}}function displaybox(g,f,e,a){var d=document.getElementById("distinfo");d.style.display="none";var b=document.getElementById("bearinginfo");b.style.display="none";var c="";if(a<1){a=Math.round(a*1e3);c="dist: "+a+" m"}else{a=Math.round(10*a)/10;c="dist: "+a+" km"}d.innerHTML="dist: "+g+" nm <br />"+c;b.innerHTML="bear: "+f+"&deg;"+e;if(chartMode=="rect"){d.innerHTML=latDispStart+" "+lonDispStart;b.innerHTML=latDispStop+" "+lonDispStop;b.style.visible="hidden";document.getElementById(bLatMax).value=latStart;document.getElementById(bLatMin).value=latStop;document.getElementById(bLongMax).value=lonStop;document.getElementById(bLongMin).value=lonStart}}var distNm,distKm,bearArr=Array("N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"),bearSt=Array(0,23,45,68,90,113,135,158,180,203,225,248,270,293,315,338);function calc_pos(){var d=4e4/(2*Math.PI);distKm=d*Math.acos(Math.sin(Math.PI/180*latStart)*Math.sin(Math.PI/180*latStop)+Math.cos(Math.PI/180*latStart)*Math.cos(Math.PI/180*latStop)*Math.cos(Math.PI/180*(lonStop-lonStart)));distNm=distKm/1.852;if(distNm>1)distNm=Math.round(10*distNm)/10;else distNm=Math.round(1e3*distNm)/1e3;var a;if(x1>=x0)a=90+180/Math.PI*Math.atan((y1-y0)/(x1-x0));else a=180+90+180/Math.PI*Math.atan((y1-y0)/(x1-x0));a=Math.round(a);if(a>338)bearSt[0]=360;else bearSt[0]=0;var b=0,c=Math.abs(a-bearSt[0]);for(i=0;i<bearSt.length;i++)if(Math.abs(a-bearSt[i])<c){b=i;c=Math.abs(a-bearSt[i])}var e=bearArr[b];displaybox(distNm,a,e,distKm)}var latDispStart,lonDispStart,latDispStop,lonDispStop,latStart,latStop,lonStart,lonStop;function getPos(l){var m=false;if(!isNS)l=window.event;scrollParams=getScrollXY();offsets=calcOffsets(mapFixedDiv);var c=l.clientX-parseInt(mapMovingDiv.style.left)+scrollParams[0]-offsets[0],d=l.clientY-parseInt(mapMovingDiv.style.top)+scrollParams[1]-offsets[1];if(isPreIE7){c=c-2;d=d-2}var i=0,e=0;if(typeof dX!="undefined")i=dX;if(typeof dY!="undefined")e=dY;m=true;if(i!=0){var r=i*d/chHeight*(1-(c-chXBorder)/(chWidth/2));c=c+parseInt(r)}if(e!=0){var p=c-chXBorder-parseInt(chWidth/2),k=(parseInt(chWidth/2)*parseInt(chWidth/2)+e*e)/(2*e),j=Math.abs(parseInt(e-k*(1-Math.sqrt(1-p*p/(k*k)))));if(e<0)j=-j;d=d-j}var g=0,n=0,o=0,h=0,f=0;switch(chartType){case mercator:hr=(2*Math.atan(Math.exp((b-d)/a))-Math.PI/2)*180/Math.PI;break;case transmercator:hr=latMax+(latMin-latMax)/chHeight*(d-chYBorder);break;case polyconic:if(isCutOut){c=parseInt(c)+parseInt(chXBorder);d=parseInt(d)+parseInt(chYBorder)}c=(c-lon0px*zoomLevel/100)/(xMul*zoomLevel/100);d=(lat0px*zoomLevel/100-d)/(yMul*zoomLevel/100);g=calcPolyPhi(c,d);hr=g*180/Math.PI;break;case lambert:if(isCutOut){c=parseInt(c)+parseInt(chXBorder);d=parseInt(d)+parseInt(chYBorder)}c=(c-lon0px*zoomLevel/100)/(xMul*zoomLevel/100);d=(lat0px*zoomLevel/100-d)/(yMul*zoomLevel/100);n=Math.sqrt(c*c+(lamRo-d)*(lamRo-d));o=Math.atan(c/(lamRo-d));hr=(2*Math.atan(Math.pow(lamF/n,1/lamN))-Math.PI/2)*180/Math.PI;break;case stereographic:var s=d;if(isCutOut){c=parseInt(c)+parseInt(chXBorder);d=parseInt(d)+parseInt(chYBorder)}c=(c-lon0px*zoomLevel/100)/(xMul*zoomLevel/100);d=(lat0px*zoomLevel/100-d)/(yMul*zoomLevel/100);h=Math.sqrt(c*c+d*d);f=2*Math.atan(h/(2*earthRadius));hr=Math.asin(Math.cos(f)*Math.sin(lat0)+d*Math.sin(f)*Math.cos(lat0)/h)*180/Math.PI}latStop=hr;rad2deg(hr,true);latDispStop=hr;switch(chartType){case mercator:hr=longMin+(longMax-longMin)/chWidth*(c-chXBorder);break;case transmercator:hr=longMin+(longMax-longMin)/chWidth*(c-chXBorder);break;case polyconic:hr=(lon0+Math.asin(c*Math.tan(g))/Math.sin(g))*180/Math.PI;break;case lambert:hr=(lon0+o/lamN)*(180/Math.PI);break;case stereographic:hr=(Math.PI/2+Math.atan(c*Math.sin(f)/(h*Math.cos(lat0)*Math.cos(f)-d*Math.sin(lat0)*Math.sin(f))))*180/Math.PI;var q=d;if(lat0>0)q=-d;if(q<0)if(c<0)hr=hr-270;else hr=90+hr;else if(c>0)hr=hr-90;else hr=hr-90}lonStop=hr;rad2deg(hr,false);lonDispStop=hr;return m}var pA,pB,polyPhi;function calcPolyPhi(b,d){var f=b,g=d;pA=d+lat0;pB=pA*pA+b*b;polyPhi=pA;var e=10,c=0,a=10;while(a>=1e-9){c++;a=calcDeltaPhi();polyPhi=polyPhi+a;if(c>e)a=0}return polyPhi}function calcDeltaPhi(){var b=Math.tan(polyPhi),a=pA*(polyPhi*b+1)-polyPhi-.5*(polyPhi*polyPhi+pB)*b;a=-a/((polyPhi-pA)/b-1);return a}function getTarget(b){var a=null;if(!isNS)a=window.event.srcElement;else a=b.target;return a}function getTargetTillParentWithID(b){var a=getTarget(b);while(a.id==null)a=a.offsetParent;if(a!==null)if(a.id==""||a.id=="undefined")while(a.id=="")if(a.offsetParent!==null)a=a.offsetParent;else break;return a}function rad2deg(b,f){var c,g,e,a,d;if(f)if(b<0)d="S";else d="N";else if(b<0)d="W";else d="E";if(chartType!=stereographic){if(b>180){b=-(360-b);rad2deg(b,f);return false}if(b<-180){b=360+b;rad2deg(b,f);return false}}b=Math.abs(b);c=parseInt(b);g=Math.round((b-c)*6e4);e=parseInt(g/1e3);if(e<10)e="0"+e;a=g-e*1e3;switch(posdis){case 0:if(a<100)a="0"+a;if(a<10)a="0"+a;if(userRights==0)a=a.toString().slice(0,1)+"XX";hr=c+"&deg;"+e+","+a+d;break;case 1:if(a<100)a="0"+a;if(a<10)a="0"+a;hr=c+","+((b-c)*10).toString().replace(".","").substring(0,7)+d;if(userRights==0)hr=c+","+(b-c).toString().replace(".","").substring(0,2)+"XXXXX"+d;break;case 2:a=Math.round(a*60/1e3);if(a<10)a="0"+a;if(userRights==0)a=a.toString().slice(0,1)+"X";else a=a.toString().slice(0,2);hr=c+"&deg;"+e+"'"+a+'"'+d}}function getDispTable(a,b){return '<table class="posDis"><tr><td style="width:6%">LAT:&nbsp;</td><td style="width:44%;text-align:left;">'+a+'</td><td style="width:6%">&nbsp;LON:&nbsp;</td><td style="width:44%;text-align:left;"> '+b+"</td></tr></table>"}function rad2ddmmmmm(a){var g,d,f,c,b,e;if(a<0)e="2";else e="1";if(a>180){a=-(360-a);rad2ddmmmmm(a);return false}if(a<-180){a=360+a;rad2ddmmmmm(a);return false}a=Math.abs(a);d=parseInt(a);f=(a-d)*60;c=parseInt(f);b=Math.round((f-c)*1e3);if(c<10)c="0"+c;if(b<100)b="0"+b;if(b<10)b="0"+b;hr=d+"|"+c+"|"+b+"|"+e}function ignoreEnterKey(){if(getKey()==122)return false}function fW(b){var a=document.getElementById("ctl00_mainContent_fromWk");a.value=b;return false}function tW(b){var a=document.getElementById("ctl00_mainContent_toWk");a.value=b;return false}var oldClass="zoomInfo100";function handle(b,f){var c;if(f==0)if(b<0)c="zooM";else c="zooP";else c=f;var a=true;if(!isWk){var e=document.getElementById("ctl00_mainContent_zoomInf");oldClass=e.className;var d=e.className,j=parseInt(zoomArray[0]),i=parseInt(zoomArray[zoomArray.length-1]);if(zoomLevel==j&&b<0){a=false;d="zoomInfoMaxMin"}if(zoomLevel==i&&b>=0){a=false;d="zoomInfoMaxMin"}e.className=d}else{var h=parseInt(zoomArray[0]),g=parseInt(zoomArray[zoomArray.length-1]);if(zoomLevel==h&&b<0)a=false;if(zoomLevel==g&&b>=0)a=false}if(f!=0)a=true;a&&doPostBackAsync("zoomPostBack",c)}function doPostBackAsync(a,b){prm=Sys.WebForms.PageRequestManager.getInstance();!Array.contains(prm._asyncPostBackControlIDs,a)&&prm._asyncPostBackControlIDs.push(a);!Array.contains(prm._asyncPostBackControlClientIDs,a)&&prm._asyncPostBackControlClientIDs.push(a);__doPostBack(a,b)}function wheel(a){var b=0;if(!a)a=window.event;if(a.wheelDelta){b=a.wheelDelta/120;if(window.opera)b=-b}else if(a.detail)b=-a.detail/3;b&&handle(b,0);a.preventDefault&&a.preventDefault();a.returnValue=false}function reloadChart(m,J,K,v,y,z,o,p,n,k,h,i,H,I,e,f,j,d,c,s,t,F,G,w,u,r,g,C,B,D,E,A,x,l,q){toCenter=m;centerToX=J;centerToY=K;factor=v;latMax=y;latMin=z;longMax=o;longMin=p;chWidth=n;chHeight=k;chXBorder=h;chYBorder=i;a=H;b=I;isMercator=e;userRights=f;zoomLevel=j;imgRealWidth=d;imgRealHeight=c;userLat=s;userLon=t;dX=F;dY=G;imgExt=w;cutOut=u;tracing=r;if(cutOut.length!=0)isCutOut=true;else{isCutOut=false;hasTiles=true}chartType=g;lon0=C;lat0=B;xMul=D;yMul=E;lon0px=A;lat0px=x;tileLoc=q;tileBase=l;if(isWk){initT=0;initChart();checkTiles()}checkTiles()}function loadTileParameters(){var test=document.getElementById("ctl00_mainContent_SM"),tileP=document.getElementById("ctl00_mainContent_TP"),splitter=tileP.innerHTML.split(";");center=eval(splitter[0]);centerToX=eval(splitter[1]);centerToY=eval(splitter[2]);factor=splitter[3];chWidth=splitter[4];chHeight=splitter[5];chXBorder=splitter[6];chYBorder=splitter[7];a=splitter[8];b=splitter[9];zoomLevel=splitter[10];imgRealWidth=splitter[11];imgRealHeight=splitter[12];tileLoc=splitter[13];tdw=splitter[14];tdh=splitter[15];rows=splitter[16];cols=splitter[17];userLon=splitter[19];userLat=splitter[18];dX=splitter[20];dY=splitter[21]}function enterEasy(c){if(typeof document.getElementById("ctl00_mainContent_easyLatHr")!="undefined")if(document.getElementById("ctl00_mainContent_easyLatHr")!=null){var f=document.getElementById("ctl00_mainContent_easyLat"),g=document.getElementById("ctl00_mainContent_easyLon"),d=document.getElementById("ctl00_mainContent_easyLatHr"),e=document.getElementById("ctl00_mainContent_easyLonHr");scrollParams=getScrollXY();if(!isNS)c=window.event;xpos=c.clientX-par_left+scrollParams[0]-parseInt(mapMovingDiv.style.left);ypos=c.clientY-par_top+scrollParams[1]-parseInt(mapMovingDiv.style.top);hr=(2*Math.atan(Math.exp((b-ypos)/a))-Math.PI/2)*180/Math.PI;d.value=hr.toString().replace(".",",");rad2deg(hr,true);f.value=hr;hr=longMin+(longMax-longMin)/chWidth*(xpos-chXBorder);e.value=hr.toString().replace(".",",");rad2deg(hr,false);g.value=hr}enterMark(c);return false}function showMark(){}function hideMark(){}function enterMark(){if(typeof document.getElementById("ctl00_mainContent_mLatDeg")!="undefined")if(document.getElementById("ctl00_mainContent_mLatDeg")!=null){var d=document.getElementById("ctl00_mainContent_mLatDeg"),f=document.getElementById("ctl00_mainContent_mLatMin"),g=document.getElementById("ctl00_mainContent_mLatSec"),e=document.getElementById("ctl00_mainContent_det_ladi_val"),h=document.getElementById("ctl00_mainContent_mLonDeg"),j=document.getElementById("ctl00_mainContent_mLonMin"),k=document.getElementById("ctl00_mainContent_mLonSec"),i=document.getElementById("ctl00_mainContent_det_lodi_val"),b=document.getElementById("ctl00_mainContent_easyLatHr"),c=document.getElementById("ctl00_mainContent_easyLonHr");hr=latStop;b.value=hr;rad2ddmmmmm(hr);var a=hr.split("|");d.value=a[0];f.value=a[1];g.value=a[2];e.value=a[3];hr=lonStop;c.value=hr;rad2ddmmmmm(hr);a=hr.split("|");h.value=a[0];j.value=a[1];k.value=a[2];i.value=a[3]}return false}function getCursorPos(b){if(!isNS)b=window.event;var c=b.clientX,d=b.clientY,a=[];a[0]=c;a[1]=d;return a}var targetDiv=null,subchartID=0,subchartDivs=[],subchartDir="",is4Divs=true;function subchart_onmouseover(f){getSubchart(f);if(is4Divs){for(i=0;i<subchartDivs.length;i++){var a=document.getElementById(subchartDivs[i]);if(a!=null){a.className=a.className.replace("U","H");var k=parseInt(a.style.top),j=parseInt(a.style.left),h=parseInt(a.style.width),g=parseInt(a.style.height);if(a.className.indexOf("vr")>0){var d=parseInt(a.style.left);d=d-2;a.style.left=d+"px";if(isPreIE7){var c=parseInt(a.style.width);c=c+2;a.style.width=c+"px"}}if(a.className.indexOf("hb")>0){var e=parseInt(a.style.top);e=e-2;a.style.top=e+"px";if(isPreIE7){var b=parseInt(a.style.height);b=b+2;a.style.height=b+"px"}}}}if(subchartDir!="");}else targetDiv.style.borderWidth="2px"}function subchart_onmouseout(e){getSubchart(e);if(is4Divs)for(i=0;i<subchartDivs.length;i++){var a=document.getElementById(subchartDivs[i]);if(a!=null){a.className=a.className.replace("H","U");if(a.className.indexOf("vr")>0){var b=parseInt(a.style.left);b=b+2;a.style.left=b+"px"}if(a.className.indexOf("hb")>0){var c=parseInt(a.style.top);c=c+2;a.style.top=c+"px"}}}else targetDiv.style.borderWidth="1px";var d=document.getElementById("directionDiv");d.style.display="none"}function getSubchart(e){subchartDivs=[];targetDiv=getTargetTillParentWithID(e);if(isPreIE7)if(targetDiv.id==null||targetDiv.id=="")targetDiv=targetDiv.offsetParent;subchartID=targetDiv.id.split("_")[2];if(targetDiv.id.indexOf("_bg")<0){var d=targetDiv.id.toLowerCase().indexOf("c_ew")==0,b=targetDiv.id.split("_"),a="",c=b[4];for(i=0;i<5;i++)a+=b[i]+"_";if(a!="")for(j=0;j<c;j++){if(d&&j<c/2)a=a.replace("w_","e_");if(d&&j>=c/2)a=a.replace("e_","w_");subchartDivs[j]=a+j}}else is4Divs=false;if(targetDiv.id.indexOf("di")>0){b=targetDiv.id.split("di");if(b.length>0)subchartDir=b[1].split("_")[0]}return false}function subchart_onclick(a){if(!isWk)doPostBackAsync("chartChange",subchartID);else{getSubchart(a);if(subchartID>0)location.href="chart.aspx?"+subchartID}return false}var oldZIndex=0,oldBackgroundColor="transparent",oldChildBackgroundColor="transparent",oldChildColor="Transparent";function wreckImage_onmouseover(a){a.className="imgOver";a=a.offsetParent;a.zIndex=9999;a=a.offsetParent;wreck_onmouseover(a)}function wreckImage_onmouseout(a){a.className="imgOut";a=a.offsetParent;a.zIndex=4;a=a.offsetParent;wreck_onmouseout(a)}function wreckImage_onclick(a){var b=document.getElementById("imgToShow");b.src="img/wrecks/"+a}function closeImage(){var a=document.getElementById("imgToShow");a.src="img/nav/wreck.gif"}function getImgDims(b){var c=document.getElementById("imgDivParent");if(b)if(b.src.indexOf("wreck.gif")<0){var a=new Image;a.src=b.src;var e=newWidth/newHeight,d=a.width/a.height;if(a.width>newWidth||a.height>newHeight)if(d>e){a.width=newWidth;a.height=parseInt(newWidth/d)}else{a.height=newHeight;a.width=parseInt(newHeight*d)}b.style.width=a.width+"px";b.style.height=a.height+"px";var g=parseInt(a.width),f=parseInt(a.height);c.style.display="block";c.style.width=g+10+"px";c.style.height=f+35+"px"}else c.style.display="none";else c.style.display="none"}function wreck_onmouseover(b){oldZIndex=b.style.zIndex;oldBackgroundColor=b.style.backgroundColor;b.style.zIndex=99;b.style.backgroundColor="#FFFF00";var c="#000099",d="#FFFFFF";if(b.className.indexOf("dead")>=0)c="#EEEEEE";var a=b.getElementsByTagName("div");if(a.length>0){oldChildBackgroundColor=a[0].style.backgroundColor;oldChildColor=a[0].style.color;for(i=0;i<a.length;i++){a[0].style.backgroundColor=c;a[0].style.color="#FFFFFF"}}}function wreck_onmouseout(b){b.style.zIndex=oldZIndex;b.style.backgroundColor=oldBackgroundColor;var a=b.getElementsByTagName("div");if(a.length>0)for(i=0;i<a.length;i++){a[0].style.backgroundColor=oldChildBackgroundColor;a[0].style.color=oldChildColor}}function showHide(b){var c=document.getElementById(b).style.display,d=document.getElementById("ctl00_mainContent_lbl_filter_div");if(d){var a=document.getElementById("ctl00_mainContent_lbl_filter_div").getElementsByTagName("div");for(i=0;i<a.length;i++)if(a[i].id.indexOf("_div")>=0)a[i].style.display="none"}if(c=="none")document.getElementById(b).style.display="block";else document.getElementById(b).style.display="none";return false}var jgn,previousElementIds;function showHideWks(c,f){previousElementIds!=null&&previousElementIds!=f&&hidePrevious(previousElementIds);previousElementIds=f;var n=document.getElementById(c.id.replace("mwk","mn")),l=c.style.backgroundImage.src,b=new Image;b.src=l;var m=parseInt(c.style.paddingTop),d=parseInt(b.height/2);d=6;var i=parseInt(c.style.left)+45,j=parseInt(c.style.top)+d,g=i,h=j,k=f.split(";"),e=false;for(b=0;b<k.length;b++){var a=document.getElementById(k[b]);if(a.style.display=="none"){if(!e){jgn&&jgn.clear();jgn=new jsGraphics(mapMovingDiv);jgn.setColor("#FF0000");jgn.setStroke(1);e=true}a.style.display="block";a.style.zIndex=40;g=parseInt(a.style.left)-2;h=parseInt(a.style.top)+d;jgn.drawLine(i,j,g,h)}else{a.style.display="none";a.style.zIndex=4}}if(e)jgn.paint();else jgn.clear()}function hidePrevious(c){var a=c.split(";");for(i=0;i<a.length;i++)if(typeof document.getElementById(a[i])!="undefined"){var b=document.getElementById(a[i]);if(b){b.style.display="none";b.style.zIndex=4}}}function moveChart(a){if(!isNS)a=window.event;scrollParams=getScrollXY();var h=a.clientX-par_left+scrollParams[0],i=a.clientY-par_top+scrollParams[1],g=parseInt(parseInt(contour.style.width)/2),f=parseInt(parseInt(contour.style.height)/2),b=h-g,c=i-f;contour.style.left=b+"px";contour.style.top=c+"px";var d=-parseInt(b*(mapW/contourWidth)),e=-parseInt(c*(mapW/contourWidth));mapMovingDiv.style.left=d+"px";mapMovingDiv.style.top=e+"px";xR.value=parseInt(-d+mapW/2);yR.value=parseInt(-e+mapH/2);centerToX=parseInt(xR.value);centerToY=parseInt(yR.value);checkTiles();return false}var rosaceArrowDim=18;function setmapFixedDivWidthAndHeight(){menuHeight=calcOffsets(mapFixedDiv)[1];newWidth=parseInt(window.screen.width)-2*rosaceArrowDim;newHeight=parseInt(document.body.offsetHeight)-menuHeight-rosaceArrowDim;document.getElementById("widthSpacer").width=newWidth+"px";document.getElementById("heightSpacer").height=newHeight+"px";if(newHeight<0)newHeight=0;mapFixedDiv.style.height=newHeight+"px";mapFixedDiv.style.width=newWidth+"px";if(typeof xWidth!="undefined")if(document.getElementById(xWidth)){document.getElementById(xWidth).value=newWidth;document.getElementById(yHeight).value=newHeight}var c=parseInt(newHeight/1.5),d=15;if(typeof wList!="undefined")if(document.getElementById(wList)!=null){var b=document.getElementById(wList),f=b.getElementsByTagName("span");if(f.length>d)b.style.height=c-15+"px";else b.style.height="auto"}if(typeof infoList!="undefined")if(document.getElementById(infoList)!=null)var g=document.getElementById(infoList);if(typeof mList!="undefined")if(document.getElementById(mList)!=null){var a=document.getElementById(mList),e=a.getElementsByTagName("span");if(e.length>d)a.style.height=c-15+"px";else a.style.height="auto"}popL=parseInt(newWidth/2)+rosaceArrowDim;popT=menuHeight;popW=parseInt(newWidth/2);popH=newHeight}function doPostBackScreen(){var a=document.getElementsByTagName("body");a[0].style.overflow="hidden";a[0].style.visibility="visible";var b=document.getElementsByTagName("html");b[0].style.overflow="hidden";mapFixedDiv=document.getElementById("ctl00_mainContent_mapEnclosingDiv");setmapFixedDivWidthAndHeight();doPostBackToForm("measurements","w="+parseInt(screen.width)+"&h="+parseInt(screen.height)+"&nw="+parseInt(mapFixedDiv.style.width)+"&nh="+parseInt(mapFixedDiv.style.height))}function cTP(c,d){var a=parseInt(mapFixedDiv.style.width),b=parseInt(mapFixedDiv.style.height);mapMovingDiv.style.left=parseInt(a/2-c)+"px";mapMovingDiv.style.top=parseInt(b/2-d)+"px";xR.value=parseInt(a/2-parseInt(mapMovingDiv.style.left));yR.value=parseInt(b/2-parseInt(mapMovingDiv.style.top));centerToX=parseInt(xR.value);centerToY=parseInt(yR.value);var e=parseInt(parseInt(mapFixedDiv.style.width)/2)-xR.value,f=parseInt(parseInt(mapFixedDiv.style.height)/2)-yR.value;if(document.getElementById("contour")){var g=-e/(a/contourWidth),h=-f/(a/contourWidth);contour.style.left=parseInt(g)+"px";contour.style.top=parseInt(h)+"px"}checkTiles()}function centerMarkerToPix(e,f,b,c){var a=parseInt(mapFixedDiv.style.width),d=parseInt(mapFixedDiv.style.height);mapMovingDiv.style.left=parseInt(a/2-e)+"px";mapMovingDiv.style.top=parseInt(d/2-f)+"px";xR.value=parseInt(a/2-parseInt(mapMovingDiv.style.left));yR.value=parseInt(d/2-parseInt(mapMovingDiv.style.top));centerToX=parseInt(xR.value);centerToY=parseInt(yR.value);if(b<latMin||b>latMax||c<longMin||c>longMax){location.href="chart.aspx?lat="+b.toString().replace(".",",")+"?lon="+c.toString().replace(".",",")+"?name=";return}var g=parseInt(parseInt(mapFixedDiv.style.width)/2)-xR.value,h=parseInt(parseInt(mapFixedDiv.style.height)/2)-yR.value;if(document.getElementById("contour")){var i=-g/(a/contourWidth),j=-h/(a/contourWidth);contour.style.left=parseInt(i)+"px";contour.style.top=parseInt(j)+"px"}checkTiles()}function hin(a){a.style.zIndex=30}function uin(a){a.style.zIndex=20}var map=null,lat="52.5",lon="2.50",marker=null,tip;function loadAPI(d,b){var c=document.getElementById(d);if(c.value=="on"){var a=document.createElement("script");a.src=b;a.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(a)}return true}function StartGoogleMaps(){return true}function load(g,h,f,e,d){lat=g;lon=h;initZoom=f;wkName=e;while(typeof GBrowserIsCompatible()=="undefined");if(GBrowserIsCompatible()){var i=document.getElementById("googleMap");map=new GMap2(i);map.setCenter(new GLatLng(lat,lon),initZoom);switch(d){case "0":map.setMapType(G_HYBRID_MAP);break;case "1":map.setMapType(G_SATELLITE_MAP);break;case "2":map.setMapType(G_NORMAL_MAP)}map.addControl(new GSmallZoomControl);map.enableDoubleClickZoom();map.enableScrollWheelZoom();var a=new GIcon;a.image="img/nav/chartmenu/wreckRed11px.gif";a.iconSize=new GSize(11,11);a.iconAnchor=new GPoint(5,5);var c=new GLatLng(lat,lon);marker1=new GMarker(c,{icon:a,title:wkName});map.addOverlay(marker1);map.openInfoWindow(c,wkName);tip=document.createElement("div");tip.setAttribute("id","wkText");var b=new GPoint;b=map.fromLatLngToDivPixel(c);tip.style.left=b.x+10;tip.style.top=b.y-6;tip.style.position="absolute";Gchart=document.getElementById("googleMap");Gchart.onmousemove=Gmove;GEvent.addListener(map,"move",initGoogle);GEvent.addListener(map,"zoomend",pbZoom);GEvent.addListener(map,"mousemove",function(a){rad2deg(a.lat(),true);var b=hr;rad2deg(a.lng(),false);var c=hr;document.getElementById(coord).innerHTML=getDispTable(b,c)});initGoogle()}}function pbZoom(){doPostBackToForm("googlezoom",map.getZoom())}function initGoogle(){var a=map.getBounds(),d=a.getSouthWest(),c=a.getNorthEast(),b=c.lat(),e=d.lat();pos=document.getElementById("ctl00_mainContent_googlePos");tr=Grad2deg(b,"lat",3)}function nauticalMap(){CustomGetTileUrl=function(a,b){var f=genQrst(a.x,a.y,b),c=1<<b-1,d=1<<b-2,e=1<<b-3;if(a.x&c&&a.x&d&&a.x&e||!(a.x&c)&&!(a.x&d))return G_NORMAL_MAP.getTileLayers()[0].getTileUrl(a,b);else return "./tiles/"+genPathFromQrst(f)};var c=new GCopyright(1,new GLatLngBounds(new GLatLng(-90,-90),new GLatLng(90,152)),1,'<a target="_blank" href="http://www.geogarage.com">geogarage.com</a> with maps source from <a target="_blank" href="http://www.1yachtua.com">1yachtua.com</a>'),a=new GCopyrightCollection("Map overlay by:");a.addCopyright(c);var b=[new GTileLayer(a,2,11)];b[0].getTileUrl=CustomGetTileUrl;var d=new GMapType(b,G_SATELLITE_MAP.getProjection(),"Nautical");map.addMapType(d)}function genPathFromQrst(c){for(var b=[],e=c.length,a=0;(a+1)*6<=e;a++)b.push(c.substr(a*6,6));var d="";for(j=0;j<b.length;a++)d+=b[j]+"/";return d+c+".png"}function genQrst(c,d,e){for(var a=1<<e-1,b="t",f=e;f>0;f--){if(c&a&&d&a)b+="s";else if(c&a&&!(d&a))b+="r";else if(!(c&a)&&!(d&a))b+="q";else if(!(c&a)&&d&a)b+="t";a=a>>1}return b}function Gmove(c){scrollParams=getScrollXY();if(!isNS)c=window.event;var f=document.getElementById("googleMap"),a=f,d=0,e=0;while(a){d+=a.offsetLeft;e+=a.offsetTop;a=a.offsetParent}xposG=c.clientX+scrollParams[0];yposG=c.clientY+scrollParams[1];var g=parseInt(xposG)-parseInt(d),h=parseInt(yposG)-parseInt(e),b=map.fromContainerPixelToLatLng(new GPoint(g,h)),i=Grad2deg(b.lat(),"lat",3),j=Grad2deg(b.lng(),"lon",3),k=b.lat().toString().substring(0,10),l=b.lng().toString().substring(0,10)}function Grad2deg(c,g){var e,f,b,a,d;if(g=="lon")if(c<0)d="W";else d="E";if(g=="lat")if(c<0)d="S";else d="N";c=Math.abs(c);e=parseInt(c);f=Math.round((c-e)*6e4);b=parseInt(f/1e3);a=f-b*1e3;if(b<10)b="0"+b;if(a<100)a="0"+a;if(a<10)a="0"+a;return e+"*"+b+","+a+d}function runViewer(j,f,g,l,m,k,h,d,e,c,i){var b="http://www.charts.noaa.gov/OnLineViewer/zoomifyDynamicViewer.swf",a="";a+="zoomifyImagePath=http://www.charts.noaa.gov/OnLineViewer/"+j;a+="&zoomifyY="+f;a+="&zoomifyMinZoom="+g;a+="&zoomifyX="+l;a+="&zoomifyY="+m;a+="&zoomifyZoom="+k;a+="&zoomifyToolbar="+h;a+="&zoomifyNavWindow="+d;a+="&zoomifyNavWidth="+e;a+="&zoomifyNavHeight="+c;a+="&zoomifySlider="+i;document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" name="theMovie0" align="texttop" id="theMovie0"  style="width: 96em; height: 600px">\n');document.write('<param name="FlashVars" value ="'+a+'">\n');document.write('<param name="src" value="'+b+'" />\n');document.write('<EMBED FlashVars="'+a+'" SRC="'+b+'" BGCOLOR="#ffffff" MENU="false" width="922" height="544" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" name="theMovie0">\n');document.write("</embed></object>\n")}var jg_ok,jg_ie,jg_fast,jg_dom,jg_moz;function _chkDHTM(a,b,c){b=a.document.body||null;jg_ie=b&&typeof b.insertAdjacentHTML!="undefined"&&a.document.createElement;jg_dom=b&&!jg_ie&&typeof b.appendChild!="undefined"&&typeof a.document.createRange!="undefined"&&typeof (c=a.document.createRange()).setStartBefore!="undefined"&&typeof c.createContextualFragment!="undefined";jg_fast=jg_ie&&a.document.all&&!a.opera;jg_moz=jg_dom&&typeof b.style.MozOpacity!="undefined";jg_ok=!!(jg_ie||jg_dom)}function _pntCnvDom(){var a=this.wnd.document.createRange();a.setStartBefore(this.cnv);a=a.createContextualFragment(jg_fast?this._htmRpc():this.htm);this.cnv&&this.cnv.appendChild(a);this.htm=""}function _pntCnvIe(){this.cnv&&this.cnv.insertAdjacentHTML("BeforeEnd",jg_fast?this._htmRpc():this.htm);this.htm=""}function _pntDoc(){this.wnd.document.write(jg_fast?this._htmRpc():this.htm);this.htm=""}function _pntN(){}function _mkDiv(c,d,b,a){this.htm+='<div style="position:absolute;left:'+c+"px;top:"+d+"px;width:"+b+"px;height:"+a+"px;clip:rect(0,"+b+"px,"+a+"px,0);background-color:"+this.color+(!jg_moz?";overflow:hidden":"")+';"></div>'}function _mkDivIe(c,d,b,a){this.htm+="%%"+this.color+";"+c+";"+d+";"+b+";"+a+";"}function _mkDivPrt(c,d,b,a){this.htm+='<div style="position:absolute;border-left:'+b+"px solid "+this.color+";left:"+c+"px;top:"+d+"px;width:0px;height:"+a+"px;clip:rect(0,"+b+"px,"+a+"px,0);background-color:"+this.color+(!jg_moz?";overflow:hidden":"")+';"></div>'}var _regex=/%%([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);/g;function _htmRpc(){return this.htm.replace(_regex,'<div style="overflow:hidden;position:absolute;background-color:$1;left:$2px;top:$3px;width:$4px;height:$5px"></div>\n')}function _htmPrtRpc(){return this.htm.replace(_regex,'<div style="overflow:hidden;position:absolute;background-color:$1;left:$2px;top:$3px;width:$4px;height:$5px;border-left:$4px solid $1"></div>\n')}function _mkLin(i,g,e,d){if(i>e){var k=e,l=d;e=i;d=g;i=k;g=l}var f=e-i,c=Math.abs(d-g),h=i,a=g,j=g>d?-1:1,b;if(f>=c){b=c<<1,pru=b-(f<<1),p=b-f,ox=h;while(f>0){--f;++h;if(p>0){this._mkDiv(ox,a,h-ox,1);a+=j;p+=pru;ox=h}else p+=b}this._mkDiv(ox,a,e-ox+1,1)}else{b=f<<1,pru=b-(c<<1),p=b-c,oy=a;if(d<=g){while(c>0){--c;if(p>0){this._mkDiv(h++,a,1,oy-a+1);a+=j;p+=pru;oy=a}else{a+=j;p+=b}}this._mkDiv(e,d,1,oy-d+1)}else{while(c>0){--c;a+=j;if(p>0){this._mkDiv(h++,oy,1,a-oy);p+=pru;oy=a}else p+=b}this._mkDiv(e,oy,1,d-oy+1)}}}function _mkLin2D(m,k,j,i){if(m>j){var o=j,q=i;j=m;i=k;m=o;k=q}var c=j-m,a=Math.abs(i-k),l=m,f=k,n=k>i?-1:1,e=this.stroke,h,b,g;if(c>=a){if(c>0&&e-3>0){b=(e*c*Math.sqrt(1+a*a/(c*c))-c-(e>>1)*a)/c;b=(!(e-4)?Math.ceil(b):Math.round(b))+1}else b=e;h=Math.ceil(e/2);g=a<<1,pru=g-(c<<1),p=g-c,ox=l;while(c>0){--c;++l;if(p>0){this._mkDiv(ox,f,l-ox+h,b);f+=n;p+=pru;ox=l}else p+=g}this._mkDiv(ox,f,j-ox+h+1,b)}else{if(e-3>0){b=(e*a*Math.sqrt(1+c*c/(a*a))-(e>>1)*c-a)/a;b=(!(e-4)?Math.ceil(b):Math.round(b))+1}else b=e;d=Math.round(e/2);g=c<<1,pru=g-(a<<1),p=g-a,oy=f;if(i<=k){++h;while(a>0){--a;if(p>0){this._mkDiv(l++,f,b,oy-f+h);f+=n;p+=pru;oy=f}else{f+=n;p+=g}}this._mkDiv(j,i,b,oy-i+h)}else{while(a>0){--a;f+=n;if(p>0){this._mkDiv(l++,oy,b,f-oy+h);p+=pru;oy=f}else p+=g}this._mkDiv(j,oy,b,i-oy+h+1)}}}function _mkLinDott(e,f,i,j){if(e>i){var l=i,m=j;i=e;j=f;e=l;f=m}var c=i-e,d=Math.abs(j-f),g=e,h=f,k=f>j?-1:1,b=true,a;if(c>=d){a=d<<1,pru=a-(c<<1),p=a-c;while(c>0){--c;b&&this._mkDiv(g,h,1,1);b=!b;if(p>0){h+=k;p+=pru}else p+=a;++g}}else{a=c<<1,pru=a-(d<<1),p=a-d;while(d>0){--d;b&&this._mkDiv(g,h,1,1);b=!b;h+=k;if(p>0){++g;p+=pru}else p+=a}}b&&this._mkDiv(g,h,1,1)}function _mkOv(u,v,r,q){var j=++r>>1,c=++q>>1,l=r&1,k=q&1,h=u+j,m=v+c,b=0,a=c,n=0,i=c,f=j*j<<1,s=f<<1,g=c*c<<1,t=g<<1,o=(f>>1)*(1-(c<<1))+g,p=(g>>1)-f*((c<<1)-1),e,d;while(a>0)if(o<0){o+=g*((b<<1)+3);p+=t*++b}else if(p<0){o+=g*((b<<1)+3)-s*(a-1);p+=t*++b-f*((a--<<1)-3);e=b-n;d=i-a;if(e&2&&d&2){this._mkOvQds(h,m,b-2,a+2,1,1,l,k);this._mkOvQds(h,m,b-1,a+1,1,1,l,k)}else this._mkOvQds(h,m,b-1,i,e,d,l,k);n=b;i=a}else{p-=f*((a<<1)-3);o-=s*--a}e=j-n+1;d=(i<<1)+k;a=m-i;this._mkDiv(h-j,a,e,d);this._mkDiv(h+n+l-1,a,e,d)}function _mkOv2D(L,M,y,x){var c=this.stroke;y+=c+1;x+=c+1;var w=y>>1,g=x>>1,u=y&1,h=x&1,k=L+w,m=M+g,b=0,d=g,q=w*w<<1,B=q<<1,r=g*g<<1,C=r<<1,o=(q>>1)*(1-(g<<1))+r,p=(r>>1)-q*((g<<1)-1);if(c-4<0&&(!(c-2)||y-51>0&&x-51>0)){var n=0,a=g,H,t,D;while(d>0)if(o<0){o+=r*((b<<1)+3);p+=C*++b}else if(p<0){o+=r*((b<<1)+3)-B*(d-1);p+=C*++b-q*((d--<<1)-3);H=b-n;t=a-d;if(H-1){D=H+1+(c&1);t=c}else if(t-1){D=c;t+=1+(c&1)}else D=t=c;this._mkOvQds(k,m,b-1,a,D,t,u,h);n=b;a=d}else{p-=q*((d<<1)-3);o-=B*--d}this._mkDiv(k-w,m-a,c,(a<<1)+h);this._mkDiv(k+w+u-c,m-a,c,(a<<1)+h)}else{var K=y-(c<<1)>>1,v=x-(c<<1)>>1,G=0,s=v,z=K*K<<1,I=z<<1,A=v*v<<1,J=A<<1,E=(z>>1)*(1-(v<<1))+A,F=(A>>1)-z*((v<<1)-1),i=[],j=[],e=[];i[0]=0;j[0]=g;e[0]=v-1;while(d>0){if(o<0){i[i.length]=b;j[j.length]=d;o+=r*((b<<1)+3);p+=C*++b}else if(p<0){i[i.length]=b;o+=r*((b<<1)+3)-B*(d-1);p+=C*++b-q*((d--<<1)-3);j[j.length]=d}else{p-=q*((d<<1)-3);o-=B*--d}if(s>0)if(E<0){E+=A*((G<<1)+3);F+=J*++G;e[e.length]=s-1}else if(F<0){E+=A*((G<<1)+3)-I*(s-1);F+=J*++G-z*((s--<<1)-3);e[e.length]=s-1}else{F-=z*((s<<1)-3);E-=I*--s;e[e.length-1]--}}n=-u,a=g,_oy=e[0],l=i.length,H,t;for(var f=0;f<l;f++)if(typeof e[f]!="undefined"){if(e[f]<_oy||j[f]<a){b=i[f];this._mkOvQds(k,m,b,a,b-n,a-_oy,u,h);n=b;a=j[f];_oy=e[f]}}else{b=i[f];this._mkDiv(k-b,m-a,1,(a<<1)+h);this._mkDiv(k+n+u,m-a,1,(a<<1)+h);n=b;a=j[f]}this._mkDiv(k-w,m-a,1,(a<<1)+h);this._mkDiv(k+n+u,m-a,1,(a<<1)+h)}}function _mkOvDott(p,q,k,j){var i=++k>>1,b=++j>>1,r=k&1,n=j&1,o=n^1,s=p+i,t=q+b,e=0,a=b,c=i*i<<1,l=c<<1,d=b*b<<1,m=d<<1,f=(c>>1)*(1-(b<<1))+d,g=(d>>1)-c*((b<<1)-1),h=true;while(a>0){if(f<0){f+=d*((e<<1)+3);g+=m*++e}else if(g<0){f+=d*((e<<1)+3)-l*(a-1);g+=m*++e-c*((a--<<1)-3)}else{g-=c*((a<<1)-3);f-=l*--a}h&&a>=o&&this._mkOvQds(s,t,e,a,1,1,r,n);h=!h}}function _mkRect(b,c,e,d){var a=this.stroke;this._mkDiv(b,c,e,a);this._mkDiv(b+e,c,a,d);this._mkDiv(b,c+d,e+a,a);this._mkDiv(b,c+a,a,d-a)}function _mkRectDott(a,b,d,c){this.drawLine(a,b,a+d,b);this.drawLine(a+d,b,a+d,b+c);this.drawLine(a,b+c,a+d,b+c);this.drawLine(a,b,a,b+c)}function jsgFont(){this.PLAIN="font-weight:normal;";this.BOLD="font-weight:bold;";this.ITALIC="font-style:italic;";this.ITALIC_BOLD=this.ITALIC+this.BOLD;this.BOLD_ITALIC=this.ITALIC_BOLD}var Font=new jsgFont;function jsgStroke(){this.DOTTED=-1}var Stroke=new jsgStroke;function jsGraphics(a,b){this.setColor=function(a){this.color=a.toLowerCase()};this.setStroke=function(a){this.stroke=a;if(!(a+1)){this.drawLine=_mkLinDott;this._mkOv=_mkOvDott;this.drawRect=_mkRectDott}else if(a-1>0){this.drawLine=_mkLin2D;this._mkOv=_mkOv2D;this.drawRect=_mkRect}else{this.drawLine=_mkLin;this._mkOv=_mkOv;this.drawRect=_mkRect}};this.setPrintable=function(a){this.printable=a;if(jg_fast){this._mkDiv=_mkDivIe;this._htmRpc=a?_htmPrtRpc:_htmRpc}else this._mkDiv=a?_mkDivPrt:_mkDiv};this.setFont=function(a,c,b){this.ftFam=a;this.ftSz=c;this.ftSty=b||Font.PLAIN};this.drawPolyline=this.drawPolyLine=function(b,c){for(var a=b.length-1;a;){--a;this.drawLine(b[a],c[a],b[a+1],c[a+1])}};this.fillRect=function(c,d,b,a){this._mkDiv(c,d,b,a)};this.drawPolygon=function(a,b){this.drawPolyline(a,b);this.drawLine(a[a.length-1],b[a.length-1],a[0],b[0])};this.drawEllipse=this.drawOval=function(c,d,b,a){this._mkOv(c,d,b,a)};this.fillEllipse=this.fillOval=function(t,u,j,s){var i=j>>1,b=s>>1,v=j&1,q=s&1,r=t+i,k=u+b,c=0,a=b,f=b,d=i*i<<1,o=d<<1,e=b*b<<1,p=e<<1,g=(d>>1)*(1-(b<<1))+e,h=(e>>1)-d*((b<<1)-1),n,m,l;if(j)while(a>0)if(g<0){g+=e*((c<<1)+3);h+=p*++c}else if(h<0){g+=e*((c<<1)+3)-o*(a-1);n=r-c;m=(c<<1)+v;h+=p*++c-d*((a--<<1)-3);l=f-a;this._mkDiv(n,k-f,m,l);this._mkDiv(n,k+a+q,m,l);f=a}else{h-=d*((a<<1)-3);g-=o*--a}this._mkDiv(r-i,k-f,j,(f<<1)+q)};this.fillArc=function(B,C,z,y,i,j){var o=z>>1,e=y>>1,k=z&1|(y&1)<<16,d=B+o,c=C+e,b=0,a=e,t=b,n=a,l=o*o<<1,w=l<<1,m=e*e<<1,x=m<<1,q=(l>>1)*(1-(e<<1))+m,r=(m>>1)-l*((e<<1)-1),u,s,v,p,h=1<<(Math.floor((i%=360)/180)<<3)|2<<(Math.floor((j%=360)/180)<<3)|(i>=j)<<16,f=new Array(e+1),g=new Array(e+1);i*=Math.PI/180;j*=Math.PI/180;u=d+Math.round(o*Math.cos(i));s=c+Math.round(-e*Math.sin(i));_mkLinVirt(f,d,c,u,s);v=d+Math.round(o*Math.cos(j));p=c+Math.round(-e*Math.sin(j));_mkLinVirt(g,d,c,v,p);while(a>0)if(q<0){q+=m*((b<<1)+3);r+=x*++b}else if(r<0){q+=m*((b<<1)+3)-w*(a-1);t=b;r+=x*++b-l*((a--<<1)-3);this._mkArcDiv(t,a,n,d,c,k,f,g,h);n=a}else{r-=l*((a<<1)-3);q-=w*--a;if(a&&(f[a]!=f[a-1]||g[a]!=g[a-1])){this._mkArcDiv(b,a,n,d,c,k,f,g,h);t=b;n=a}}this._mkArcDiv(b,0,n,d,c,k,f,g,h);if(k>>16)if(h>>16){var A=s<=c||p>c?d-b:d;this._mkDiv(A,c,b+d-A+(k&65535),1)}else h&1&&p>c&&this._mkDiv(d-b,c,b,1)};this.fillPolygon=function(j,c){var a,b,m,k,i,d,n,e,g,h,l,o=j.length;if(!o)return;m=c[0];k=c[0];for(a=1;a<o;a++){if(c[a]<m)m=c[a];if(c[a]>k)k=c[a]}for(b=m;b<=k;b++){var f=[];l=0;for(a=0;a<o;a++){if(!a){g=o-1;h=0}else{g=a-1;h=a}d=c[g];e=c[h];if(d<e){i=j[g];n=j[h]}else if(d>e){e=c[g];d=c[h];n=j[g];i=j[h]}else continue;if(b>=d&&b<e)f[l++]=Math.round((b-d)*(n-i)/(e-d)+i);else if(b==k&&b>d&&b<=e)f[l++]=Math.round((b-d)*(n-i)/(e-d)+i)}f.sort(_CompInt);for(a=0;a<l;a+=2)this._mkDiv(f[a],b,f[a+1]-f[a]+1,1)}};this.drawString=function(a,b,c){this.htm+='<div style="position:absolute;white-space:nowrap;left:'+b+"px;top:"+c+"px;font-family:"+this.ftFam+";font-size:"+this.ftSz+";color:"+this.color+";"+this.ftSty+'">'+a+"</div>"};this.drawStringRect=function(c,d,e,b,a){this.htm+='<div style="position:absolute;overflow:hidden;left:'+d+"px;top:"+e+"px;width:"+b+"px;text-align:"+a+";font-family:"+this.ftFam+";font-size:"+this.ftSz+";color:"+this.color+";"+this.ftSty+'">'+c+"</div>"};this.drawImage=function(d,e,f,b,a,c){this.htm+='<div style="position:absolute;left:'+e+"px;top:"+f+"px;"+(b?"width:"+b+"px;":"")+(a?"height:"+a+"px;":"")+'"><img src="'+d+'"'+(b?' width="'+b+'"':"")+(a?' height="'+a+'"':"")+(c?" "+c:"")+"></div>"};this.clear=function(){this.htm="";if(this.cnv)this.cnv.innerHTML=""};this._mkOvQds=function(e,f,i,j,a,b,l,k){var c=e-i,d=e+i+l-a,h=f-j,g=f+j+k-b;if(d>c+a){this._mkDiv(d,h,a,b);this._mkDiv(d,g,a,b)}else a=d-c+a;this._mkDiv(c,h,a,b);this._mkDiv(c,g,a,b)};this._mkArcDiv=function(b,e,o,n,l,m,j,k,d){var h=n+b+(m&65535),f,g=o-e,c,i,a;if(!g)g=1;b=n-b;if(d&16711680){f=l-e-g;if(d&255){if(d&2){c=Math.max(b,k[e]);a=h-c;a>0&&this._mkDiv(c,f,a,g)}if(d&1){i=Math.min(h,j[e]);a=i-b;a>0&&this._mkDiv(b,f,a,g)}}else this._mkDiv(b,f,h-b,g);f=l+e+(m>>16);if(d&65280){if(d&256){c=Math.max(b,j[e]);a=h-c;a>0&&this._mkDiv(c,f,a,g)}if(d&512){i=Math.min(h,k[e]);a=i-b;a>0&&this._mkDiv(b,f,a,g)}}else this._mkDiv(b,f,h-b,g)}else{if(d&255){if(d&2)c=Math.max(b,k[e]);else c=b;if(d&1)i=Math.min(h,j[e]);else i=h;f=l-e-g;a=i-c;a>0&&this._mkDiv(c,f,a,g)}if(d&65280){if(d&256)c=Math.max(b,j[e]);else c=b;if(d&512)i=Math.min(h,k[e]);else i=h;f=l+e+(m>>16);a=i-c;a>0&&this._mkDiv(c,f,a,g)}}};this.setStroke(1);this.setFont("verdana,geneva,helvetica,sans-serif","12px",Font.PLAIN);this.color="#000000";this.htm="";this.wnd=b||window;!jg_ok&&_chkDHTM(this.wnd);if(jg_ok)if(a){if(typeof a=="string")this.cont=document.all?this.wnd.document.all[a]||null:document.getElementById?this.wnd.document.getElementById(a)||null:null;else if(a==window.document)this.cont=document.getElementsByTagName("body")[0];else this.cont=a;this.cnv=this.wnd.document.createElement("div");this.cnv.style.fontSize=0;this.cont.appendChild(this.cnv);this.paint=jg_dom?_pntCnvDom:_pntCnvIe}else this.paint=_pntDoc;else this.paint=_pntN;this.setPrintable(false)}function _mkLinVirt(g,h,i,m,n){var c=Math.abs(m-h),d=Math.abs(n-i),f=h,o=i,j=h>m?-1:1,k=i>n?-1:1,b,e=0,a;if(c>=d){a=d<<1,pru=a-(c<<1);b=a-c;while(c>0){--c;if(b>0){g[e++]=f;o+=k;b+=pru}else b+=a;f+=j}}else{a=c<<1,pru=a-(d<<1);b=a-d;while(d>0){--d;o+=k;g[e++]=f;if(b>0){f+=j;b+=pru}else b+=a}}for(var l=g.length,e=l-e;e;)g[l-e--]=f}function _CompInt(a,b){return a-b}
