function grabEl(a){if(IE4||dom){if(!IE4){whichEl=a.target}else{whichEl=event.srcElement}while(whichEl.id.indexOf("DRAG")==-1){if(IE4){whichEl=whichEl.parentElement}else{whichEl=whichEl.parentNode}if(whichEl==null){return}}}else{mouseX=a.pageX;mouseY=a.pageY;for(i=0;i<document.layers.length;i++){tempLayer=document.layers[i];if(tempLayer.id.indexOf("DRAG")==-1){continue}if((mouseX>tempLayer.left+tempLayer.clip.left)&&(mouseX<(tempLayer.left+tempLayer.clip.right))&&(mouseY>tempLayer.top+tempLayer.clip.top)&&(mouseY<(tempLayer.top+tempLayer.clip.bottom))){whichEl=tempLayer}}if(whichEl==null){return}}if(IE4){event.srcElement.style.cursor="move"}if(whichEl!=activeEl){if(IE4||dom){whichEl.style.zIndex=activeEl.style.zIndex+1}else{whichEl.moveAbove(activeEl)}activeEl=whichEl}dragging=true;if(IE4||dom){if(IE4){currentX=(event.clientX+document.body.scrollLeft);currentY=(event.clientY+document.body.scrollTop)}else{currentX=a.pageX;currentY=a.pageY;if(whichEl.id=="DRAGLOGO"){whichEl.style.left=currentX-fishxOffset;whichEl.style.top=currentY-fishyOffset}}}else{currentX=a.pageX;currentY=a.pageY;document.captureEvents(Event.MOUSEMOVE);document.onmousemove=moveEl}if((document.images.FISHCAPTION)&&(document.images.FISHCAPTION.src.search(/onedot/)<=0)){document.images.FISHCAPTION.src="onedot.gif"}return false}function syncgrid(){if(IE4){theX=0+document.body.scrollLeft;theY=0;pathgen("LATLAYER",theX,theY,theX,theY,1);theX=0;theY=0+document.body.scrollTop;pathgen("LONLAYER",theX,theY,theX,theY,1)}else{}}function moveEl(a){if(whichEl==null){return}if(IE4){newX=(event.clientX+document.body.scrollLeft);newY=(event.clientY+document.body.scrollTop)}else{newX=a.pageX;newY=a.pageY}setdraglogodirection();distanceX=(newX-currentX);distanceY=(newY-currentY);currentX=newX;currentY=newY;if(IE4||dom){if(IE4){whichEl.style.pixelLeft=parseInt(whichEl.style.pixelLeft+distanceX);whichEl.style.pixelTop=parseInt(whichEl.style.pixelTop+distanceY);if((document.body.clientWidth<=event.clientX)||((event.clientX<=10)&&(distanceX<=0))){document.body.scrollLeft+=distanceX}if((document.body.clientHeight<=event.clientY)||((event.clientY<=10)&&(distanceY<=0))){document.body.scrollTop+=distanceY}if(whichEl.id=="DRAGLOGO"){getLatLon()}}else{whichEl.style.left=parseInt(whichEl.style.left)+distanceX;whichEl.style.top=parseInt(whichEl.style.top)+distanceY;if(true){if((-20+document.body.clientWidth+document.body.scrollLeft<=newX)||((newX<=20+document.body.scrollLeft)&&(distanceX<=0))){document.body.scrollLeft+=distanceX}if((-20+document.body.clientHeight+document.body.scrollTop<=newY)||((newY<=20+document.body.scrollTop)&&(distanceY<=0))){document.body.scrollTop+=distanceY}}if(whichEl.id=="DRAGLOGO"){getLatLon(a)}}return false}else{whichEl.moveBy(distanceX,distanceY)}}function setdraglogodirection(){if(IE4||dom){if(document.images.FISHY){if(currentX>newX){if(document.images.FISHY.src.search(/left/)<=0){document.images.FISHY.src="tbfishleft.gif"}}if(currentX<newX){if(document.images.FISHY.src.search(/right/)<=0){document.images.FISHY.src="tbfishright.gif"}}}}else{if(document.layers.DRAGLOGO.document.images.FISHY){if(currentX>newX){if(document.layers.DRAGLOGO.document.images.FISHY.src.search(/left/)<=0){document.layers.DRAGLOGO.document.images.FISHY.src="tbfishleft.gif"}}if(currentX<newX){if(document.layers.DRAGLOGO.document.images.FISHY.src.search(/right/)<=0){document.layers.DRAGLOGO.document.images.FISHY.src="tbfishright.gif"}}}}}function checkEl(){if(whichEl!=null){return false}}function dropEl(){if(NS4){document.releaseEvents(Event.MOUSEMOVE)}whichEl=null;if(dragging&&gesyncloc=="true"&&LastLat!=""&&LastLon!=""){makekml("fishicononly")}dragging=false}function cursEl(a){if(IE4){if(event.srcElement.id.indexOf("DRAG")!=-1){event.srcElement.style.cursor="move"}}}function getLatLon(a){if(IE4){curX=(whichEl.style.pixelLeft)+fishxOffset;curY=(whichEl.style.pixelTop)+fishyOffset}else{curX=a.pageX;curY=a.pageY}calcLatLon();if(true&&activeEl.id=="DRAGLOGO"){displaystats()}return true}function calcLatLon(){Lat=curY-yOffset;Lon=curX-xOffset;ScaleLat=(Lat*ScaleHeight)/chartHeight;ScaleLon=(Lon*ScaleWidth)/chartWidth;BottomEdge=chartHeight+yOffset;RightEdge=chartWidth+xOffset;if(curY<yOffset||curY>BottomEdge||curX<xOffset||curX>RightEdge){CurLat=0;CurLon=0;CurDist=0;CurBear=0}else{Lat=ScaleHeight-ScaleLat+LoLat;Lon=ScaleWidth-ScaleLon+LoLon;CurLat=Lat;CurLon=Lon;CurDist=getlatlondist(homeportlat,homeportlon,CurLat,CurLon);CurBear=getbear(homeportlat,homeportlon,CurLat,CurLon)}}function getPixelCoord(a,b){if(b=="Lat"){thepixelcoord=(((HiLat-a)*chartHeight)/ScaleHeight)+yOffset}else{thepixelcoord=(((HiLon-a)*chartWidth)/ScaleWidth)+xOffset}return thepixelcoord}function mapincominglatlon(){if(inparams.search("lat=")!=-1&&inparams.search("lon=")!=-1){if(inparams.search("zoom=")!=(-1)){var c=new String(inparams.substring(inparams.search("zoom=")+5,inparams.search("lat=")-1));if(zoomlevel!=c){gotozoomlevel(c)}}var e=new String(inparams.substring(inparams.search("lat=")+4,inparams.search("lon=")));var b=new String(inparams.substring(inparams.search("lon=")+4,inparams.length));var a=new String(e.substring(e.search("_")+1,e.length));var d=new String(b.substring(b.search("_")+1,b.length));e=e.substring(0,e.search("_"));b=b.substring(0,b.search("_"));latd=parseInt(e);latm=parseFloat(a);lond=parseInt(b);lonm=parseFloat(d);CurLat=(latd*60)+latm;CurLon=(lond*60)+lonm;pixelLon=getPixelCoord(CurLon,"Lon");pixelLat=getPixelCoord(CurLat,"Lat");CurDist=getlatlondist(homeportlat,homeportlon,CurLat,CurLon);CurBear=getbear(homeportlat,homeportlon,CurLat,CurLon);return true}else{return false}}function sendfishtolatlon(){if(document.images.FISHCAPTION&&document.images.FISHCAPTION.src.search(/onedot/)<=0){document.images.FISHCAPTION.src="onedot.gif"}if(draglogohomex<pixelLon-Math.round(fishxOffset)){if(IE4||dom){document.images.FISHY.src="tbfishright.gif"}else{document.layers.DRAGLOGO.document.images.FISHY.src="tbfishright.gif"}}else{if(IE4||dom){document.images.FISHY.src="tbfishleft.gif"}else{document.layers.DRAGLOGO.document.images.FISHY.src="tbfishleft.gif"}}curX=Math.round(pixelLon);curY=Math.round(pixelLat);pathgen("DRAGLOGO",draglogohomex,draglogohomey,curX-fishxOffset,curY-fishyOffset,7);displaystats()}function formatcoord(b,a){ret_val="";if(b!=0){LatDegrees=Math.floor(b/60);LatMins=b-(60*LatDegrees);TheMins=Math.floor(LatMins);TheSecs=LatMins-TheMins;TheSecs=Math.round(TheSecs*100);if(TheSecs==100){TheSecs=0;TheMins=TheMins+1}if(TheMins==60){TheMins=0;LatDegrees=LatDegrees+1}if(TheMins<10){LatMinsString="0"+TheMins}else{LatMinsString=TheMins}if(TheSecs<10){LatSecsString="0"+TheSecs}else{LatSecsString=TheSecs}ret_val=LatDegrees+DegreesChar+" "+LatMinsString+"."+LatSecsString+MinsChar+" "+a}return ret_val}function getdist(d,b,c,a){asideval=(d-c);bsideval=(b-a);csideval=(asideval*asideval)+(bsideval*bsideval);calcdist=Math.sqrt(csideval);return calcdist}function getlatlondist(l,d,f,b){if(f==0||b==0){calcdist=0}else{l=((l/60)*Math.PI)/180;d=((-d/60)*Math.PI)/180;f=((f/60)*Math.PI)/180;b=((-b/60)*Math.PI)/180;var e=3440.06317;var g=f-l;var m=b-d;var k=Math.sin(g/2)*Math.sin(g/2)+Math.cos(l)*Math.cos(f)*Math.sin(m/2)*Math.sin(m/2);var h=2*Math.atan2(Math.sqrt(k),Math.sqrt(1-k));calcdist=e*h;calcdist=Math.round(calcdist*100)/100}return calcdist}function displaystats(){LastLat=CurLat;LastLon=CurLon;LastDist=CurDist;LastBear=CurBear;FormattedLat=LastLat==0?"":formatcoord(LastLat,"N");FormattedLon=LastLon==0?"":formatcoord(LastLon,"W");FormattedDist=LastDist+"";FormattedDist=FormattedDist.substring(FormattedDist.search(/\./)+1);FormattedDist=LastDist+(FormattedDist.length<=1?"0":"");FormattedDist=LastDist==0?"":FormattedDist+" "+distUnits;FormattedBear=LastLat==0?"":LastBear+DegreesChar;if(IE4||dom){document.forms.FISHY.lat.value=FormattedLat;document.forms.FISHY.lon.value=FormattedLon;document.forms.FISHY.dist.value=FormattedDist;document.forms.FISHY.bear.value=FormattedBear}else{document.layers.DRAGLOGO.document.forms.FISHY.lat.value=FormattedLat;document.layers.DRAGLOGO.document.forms.FISHY.lon.value=FormattedLon;document.layers.DRAGLOGO.document.forms.FISHY.dist.value=FormattedDist;document.layers.DRAGLOGO.document.forms.FISHY.bear.value=FormattedBear}if(FormattedLat!=""||FormattedLon!=""){TheLatLon=FormattedLat+" / "+FormattedLon}else{TheLatLon=""}window.defaultStatus=sstarray[curmappos][3]?sstarray[curmappos][3]:"   "+TheLatLon+(FormattedDist.length==0?"":"   Distance: ")+FormattedDist+(FormattedBear==0?"":"   Bearing: ")+FormattedBear}function pathgen(c,b,g,a,f,d){therex=Math.abs(Math.abs(b)-Math.abs(a))<d;if(!therex){b=b+(b==a?0:b>a?-d:d)}therey=Math.abs(Math.abs(g)-Math.abs(f))<d;if(!therey){g=g+(g==f?0:g>f?-d:d)}var e=new svetLayer(c);if(e.name!==null){e.moveTo(b,g);if(!therex||!therey){setTimeout('pathgen("'+c+'",'+b+","+g+","+a+","+f+","+d+")",10)}else{e.moveTo(a,f);if(c=="DRAGLOGO"){displaystats()}}}}function svetLayer(a){this.name=dom?document.getElementById(a):IE4?document.all[a]:NS4?document.layers[a]:null;if(this.name!==null){this.css=(dom||IE4)?this.name.style:this.name;this.x=parseInt(dom?this.css.pixelLeft:IE4?this.css.left:this.css.left);this.y=parseInt(dom?this.css.pixelTop:IE4?this.css.top:this.css.top);this.moveTo=moveTo;return this}else{return false}}function moveTo(a,b){if(dom||IE4){this.x=a;this.y=b;this.css.left=a;this.css.top=b}else{this.css.moveTo(a,b)}}function getbear(d,c,b,a){thebear=radToBrng(bearing((d/60)*Math.PI/180,-(c/60)*Math.PI/180,(b/60)*Math.PI/180,-(a/60)*Math.PI/180));thebear=thebear-MagVar;thebear=Math.round(thebear);if(thebear<0){thebear=thebear+360}return thebear}function bearing(e,d,c,b){var f=Math.sin(d-b)*Math.cos(c);var a=Math.cos(e)*Math.sin(c)-Math.sin(e)*Math.cos(c)*Math.cos(d-b);return(Math.atan2(-f,a))}function radToBrng(a){var b=(a*180/Math.PI+360)%360+1/7200;return(b)}function youarehere(){navigator.geolocation.getCurrentPosition(function(a){gpsLat=(a.coords.latitude*60);gpsLon=(a.coords.longitude*-60);if(gpsLat!=0&&gpsLon!=0){if((gpsLat>HiLat)||(gpsLat<LoLat)||(gpsLon>HiLon)||(gpsLon<LoLon)){}else{CurLat=gpsLat;CurLon=gpsLon;pixelLon=getPixelCoord(CurLon,"Lon");pixelLat=getPixelCoord(CurLat,"Lat");CurDist=getlatlondist(homeportlat,homeportlon,CurLat,CurLon);CurBear=getbear(homeportlat,homeportlon,CurLat,CurLon);sendfishtolatlon()}}})}function rollOver(a,b){if(!document.images){return}whichIm=document.images[a];if(b){whichIm.src=a+"over.jpg"}else{whichIm.src=a+"up.jpg"}}function rollClick(a){if(!document.images||ver4){return}whichIm=document.images[a];whichIm.src=a+"down.jpg";dummy=setTimeout('whichIm.src = "'+a+'over.jpg"',100)}function rollPress(a,b){whichIm=document.images[a];if(b){whichIm.src=a+"down.jpg"}else{whichIm.src=a+"over.jpg"}}function gethelp(){window.location="http://www.kelppaddy.com/viewtopic.php?f=1&t=195"}function gotozoomlevel(a){if(a!=0&&a<=1&&a>=(-1)){zoomingin=a>zoomlevel;while(zoomlevel!=a){if(zoomingin){zoominmap()}else{zoomoutmap()}}}}function zoominmap(){if(NS4){alert("Zoom is not available when using Netscape 4.x browsers.  Try Explorer to zoom now.");return}if(zoomlevel>=3||(NS4&&zoomlevel>=1)){alert("You are zoomed in all the way.");return}fromx=0;fromy=0;tox=0;toy=0;chartWidth=chartWidth*zoomvar;chartHeight=chartHeight*zoomvar;homeportx=homeportx*zoomvar;homeporty=homeporty*zoomvar;zoomvar=zoomvar-zoomstep;zoomlevel=zoomlevel+1;if(IE4||dom){if(CurLon==0||CurLat==0){}else{if(IE4){fromx=document.all.DRAGLOGO.style.pixelLeft;fromy=document.all.DRAGLOGO.style.pixelTop}else{fromx=parseInt(document.getElementById("DRAGLOGO").style.left);fromy=parseInt(document.getElementById("DRAGLOGO").style.top)}tox=getPixelCoord(CurLon,"Lon");toy=getPixelCoord(CurLat,"Lat");tox=Math.round(tox-fishxOffset);toy=Math.round(toy-fishyOffset);if(IE4||dom){document.images.FISHY.src="tbfishright.gif"}else{document.layers.DRAGLOGO.document.images.FISHY.src="tbfishright.gif"}pathgen("DRAGLOGO",tox,toy,tox,toy,10)}dealwpts("nopath");dealhspts("nopath");dealgrid("nopath");document.images.CHART.width=chartWidth;document.images.CHART.height=chartHeight;document.images.CLOUDMASK.width=chartWidth;document.images.CLOUDMASK.height=chartHeight;if(addonlayer!=""){document.images.ADDON.width=chartWidth;document.images.ADDON.height=chartHeight}if(!(fromx==0&&fromy==0&&tox==0&&toy==0)){window.scrollBy(tox-fromx,toy-fromy)}}}function zoomoutmap(){if(NS4){alert("Zoom is coming soon to Netscape browsers.  Try Explorer to zoom now.");return}if(zoomlevel<=(-3)||(NS4&&zoomlevel<=(-1))){alert("You are zoomed out all the way.");return}fromx=0;fromy=0;tox=0;toy=0;zoomvar=zoomvar+zoomstep;zoomlevel=zoomlevel-1;chartWidth=chartWidth/zoomvar;chartHeight=chartHeight/zoomvar;homeportx=homeportx/zoomvar;homeporty=homeporty/zoomvar;if(IE4||dom){if(CurLon==0||CurLat==0){}else{if(IE4){fromx=document.all.DRAGLOGO.style.pixelLeft;fromy=document.all.DRAGLOGO.style.pixelTop}else{fromx=parseInt(document.getElementById("DRAGLOGO").style.left);fromy=parseInt(document.getElementById("DRAGLOGO").style.top)}tox=getPixelCoord(CurLon,"Lon");toy=getPixelCoord(CurLat,"Lat");tox=Math.round(tox-fishxOffset);toy=Math.round(toy-fishyOffset);if(IE4||dom){document.images.FISHY.src="tbfishleft.gif"}else{document.layers.DRAGLOGO.document.images.FISHY.src="tbfishleft.gif"}pathgen("DRAGLOGO",tox,toy,tox,toy,10)}dealwpts("nopath");dealhspts("nopath");dealgrid("nopath");document.images.CHART.width=chartWidth;document.images.CHART.height=chartHeight;document.images.CLOUDMASK.width=chartWidth;document.images.CLOUDMASK.height=chartHeight;if(addonlayer!=""){document.images.ADDON.width=chartWidth;document.images.ADDON.height=chartHeight}if(!(fromx==0&&fromy==0&&tox==0&&toy==0)){window.scrollBy(tox-fromx,toy-fromy)}}}function dealwpts(d,c,a,b){dealhspts(d,c,a,b);for(x=1;x<9999;x++){wptlayer="WPT"+x;testlayer=dom?document.getElementById(wptlayer):IE4?document.all[wptlayer]:document.layers[wptlayer];if(testlayer==null){x=9999;return}else{wptLat=dom?document.getElementById(wptlayer).Lat:IE4?document.all[wptlayer].Lat:document.layers[wptlayer].Lat;wptLon=dom?document.getElementById(wptlayer).Lon:IE4?document.all[wptlayer].Lon:document.layers[wptlayer].Lon}if(showwpts){theLon=Math.floor((wptLon/100));theLon=(theLon*60)+(wptLon-(theLon*100));theLat=Math.floor(wptLat/100);theLat=(theLat*60)+(wptLat-(theLat*100));thelat=Math.round(getPixelCoord(theLon,"Lon")-wptxOffset);thelon=Math.round(getPixelCoord(theLat,"Lat")-wptyOffset)}else{thelat=-20;thelon=-20}if(d=="nopath"){pathgen(wptlayer,thelat,thelon,thelat,thelon,15)}else{if(c&&a&&b){pathgen(wptlayer,c,a,thelat,thelon,b)}else{pathgen(wptlayer,homeportx,homeporty,thelat,thelon,15)}}}}function DaysDiff(b,a){return Math.round((b-a)/86400000)}function dealhspts(d,c,a,b){curmapdate=new String(sstarray[curmappos][3]);curmapdate=curmapdate.substr(6,4)+curmapdate.substr(0,2)+curmapdate.substr(3,2)*1;datecurmapdate=new Date(curmapdate.substr(0,4)*1,(curmapdate.substr(4,2)-1)*1,curmapdate.substr(6,2)*1);for(x=1;x<9999;x++){wptlayer="HSPT"+x;testlayer=dom?document.getElementById(wptlayer):IE4?document.all[wptlayer]:document.layers[wptlayer];if(testlayer==null){x=9999;return}else{Hotspotname=dom?document.getElementById(wptlayer).Hotspotname:IE4?document.all[wptlayer].Hotspotname:document.layers[wptlayer].Hotspotname;var e=new String(dom?document.getElementById(wptlayer).Hotspotlink:IE4?document.all[wptlayer].Hotspotlink:document.layers[wptlayer].Hotspotlink);e=e.toLowerCase();wptLat=dom?document.getElementById(wptlayer).Lat:IE4?document.all[wptlayer].Lat:document.layers[wptlayer].Lat;wptLon=dom?document.getElementById(wptlayer).Lon:IE4?document.all[wptlayer].Lon:document.layers[wptlayer].Lon}if(showwpts){theLon=Math.floor((wptLon/100));theLon=(theLon*60)+(wptLon-(theLon*100));theLat=Math.floor(wptLat/100);theLat=(theLat*60)+(wptLat-(theLat*100));thelat=Math.round(getPixelCoord(theLon,"Lon")-hsptxOffset);thelon=Math.round(getPixelCoord(theLat,"Lat")-hsptyOffset)}else{thelat=-20;thelon=-20}if(d=="nopath"){pathgen(wptlayer,thelat,thelon,thelat,thelon,15)}else{if(c&&a&&b){pathgen(wptlayer,c,a,thelat,thelon,b)}else{pathgen(wptlayer,homeportx,homeporty,thelat,thelon,15)}}datehotspotdate=new Date(Hotspotname.substr(0,4)*1,(Hotspotname.substr(4,2)-1)*1,Hotspotname.substr(6,2)*1);daysdiff=DaysDiff(datehotspotdate,datecurmapdate);if(daysdiff>=(-hotdays+1)&&daysdiff<=0){if(daysdiff>=0){}else{daysdiff=daysdiff*-1}if(daysdiff<=7){switch(true){case dom:document.getElementById(Hotspotname+wptLat+wptLon).src="hotspot"+daysdiff+((daysdiff==0||d=="path")?"ani":"")+".gif";break;case IE4:document.all(Hotspotname+wptLat+wptLon).src="hotspot"+daysdiff+((daysdiff==0||d=="path")?"ani":"")+".gif";break;default:document.layers(Hotspotname+wptLat+wptLon).src="hotspot"+daysdiff+((daysdiff==0||d=="path")?"ani":"")+".gif";break}}else{switch(true){case dom:document.getElementById(Hotspotname+wptLat+wptLon).src="hotspotg.gif";break;case IE4:document.all(Hotspotname+wptLat+wptLon).src="hotspotg.gif";break;default:document.layers(Hotspotname+wptLat+wptLon).src="hotspotg.gif";break}}showLayer(wptlayer)}else{hideLayer(wptlayer)}}}function dealgrid(d,c,a,b){GridType="";for(x=1;x<9999;x++){wptlayer="GRID"+x;testlayer=dom?document.getElementById(wptlayer):IE4?document.all[wptlayer]:document.layers[wptlayer];if(testlayer==null){x=9999;return}else{wptLat=dom?document.getElementById(wptlayer).Lat:IE4?document.all[wptlayer].Lat:document.layers[wptlayer].Lat;wptLon=dom?document.getElementById(wptlayer).Lon:IE4?document.all[wptlayer].Lon:document.layers[wptlayer].Lon;GridType=dom?document.getElementById(wptlayer).GridType:IE4?document.all[wptlayer].GridType:document.layers[wptlayer].GridType}theLon=Math.floor((wptLon/100));theLon=(theLon*60)+(wptLon-(theLon*100));theLat=Math.floor(wptLat/100);theLat=(theLat*60)+(wptLat-(theLat*100));thelat=Math.round(getPixelCoord(theLon,"Lon"));thelon=Math.round(getPixelCoord(theLat,"Lat"));if(GridType=="Lat"){thelat=thelat+latgridoffset}else{thelon=thelon+longridoffset}if(d=="nopath"){pathgen(wptlayer,thelat,thelon,thelat,thelon,20)}else{if(c&&a&&b){pathgen(wptlayer,c,a,thelat,thelon,b)}else{pathgen(wptlayer,homeportx,homeporty,thelat,thelon,20)}}}}function nextmap(){if(curmappos>=sstarray.length-1){alert("You are on the most recent chart.")}else{curmappos=curmappos+1;updatemapdate();displaymap();dealhspts("nopath")}displaystats()}function prevmap(){if(curmappos<=0){alert("You are on the oldest chart.")}else{curmappos=curmappos-1;updatemapdate();displaymap();dealhspts("nopath")}displaystats()}function displaymap(){if(IE4|dom){if(sstarray[curmappos][3]){}else{document.images.MAPDATE.src=sstarray[curmappos][0]}if(sstarray[curmappos][2]){document.images.MAPTEMP.src=sstarray[curmappos][2]}else{document.images.MAPTEMP.src=sstarray[curmappos][0]}if(IE4){if(addonlayer!=""){document.images.ADDON.filters[0].apply()}if(sstarray[curmappos][4]){document.images.CLOUDMASK.filters[0].apply()}document.images.CHART.filters[0].apply()}if(sstarray[curmappos][4]){if(showcloudmask){document.images.CLOUDMASK.src=sstarray[curmappos][4]}else{document.images.CLOUDMASK.src="onedot.gif"}}else{document.images.CLOUDMASK.src="onedot.gif"}document.images.CHART.src=sstarray[curmappos][0];if(IE4){if(addonlayer!=""){document.images.ADDON.filters[0].play()}if(sstarray[curmappos][4]){document.images.CLOUDMASK.filters[0].play()}document.images.CHART.filters[0].play()}}else{if(sstarray[curmappos][4]){if(showcloudmask){document.layers.CLOUDMASKLAYER.document.images.CLOUDMASK.src=sstarray[curmappos][4]}else{document.layers.CLOUDMASKLAYER.document.images.CLOUDMASK.src="onedot.gif"}}else{document.layers.CLOUDMASKLAYER.document.images.CLOUDMASK.src="onedot.gif"}document.layers.CHARTLAYER.document.images.CHART.src=sstarray[curmappos][0];if(sstarray[curmappos][3]){}else{document.layers.MAPDATELAYER.document.images.MAPDATE.src=sstarray[curmappos][0]}if(sstarray[curmappos][2]){document.layers.MAPTEMPDRAG.document.images.MAPTEMP.src=sstarray[curmappos][2]}else{document.layers.MAPTEMPDRAG.document.images.MAPTEMP.src=sstarray[curmappos][0]}}}function displaymodis(){bbox="-"+HiLon/60+","+LoLat/60+",-"+LoLon/60+","+HiLat/60;var a=new String((IE4|dom)?document.images.CHART.src:document.layers.CHARTLAYER.document.images.CHART.src);if(a.search("aqua")!=-1){a="http://wms.jpl.nasa.gov/wms.cgi?request=GetMap&width=1024&height=1024&layers=daily_planet&styles=default&srs=EPSG:4326&format=image/jpeg&bbox="+bbox}else{a="http://wms.jpl.nasa.gov/wms.cgi?request=GetMap&width=1024&height=1024&layers=daily_planet&styles=default&srs=EPSG:4326&format=image/jpeg&bbox="+bbox}if(IE4|dom){if(!sstarray[curmappos][3]){document.images.MAPDATE.src="onedot.gif"}document.images.MAPTEMP.src="onedot.gif";if(IE4){document.images.CHART.filters[0].apply()}document.images.CHART.src=a;document.images.CLOUDMASK.src="onedot.gif";if(IE4){document.images.CHART.filters[0].play()}}else{document.layers.CHARTLAYER.document.images.CHART.src=a;document.layers.CLOUDMASKLAYER.document.images.CLOUDMASK.src="onedot.gif";if(!sstarray[curmappos][3]){document.layers.MAPDATELAYER.document.images.MAPDATE.src="onedot.gif"}document.layers.MAPTEMPDRAG.document.images.MAPTEMP.src="onedot.gif"}}function displaydapz(){wmsbbox="-"+HiLon/60+","+LoLat/60+",-"+LoLon/60+","+HiLat/60;bbox="[("+(LoLat/60)+"):("+(HiLat/60)+")][("+(360-(HiLon/60))+"):("+(360-(LoLon/60))+")]";var a=new String((IE4|dom)?document.images.CHART.src:document.layers.CHARTLAYER.document.images.CHART.src);a="getpng2.php";if(IE4|dom){if(!sstarray[curmappos][3]){document.images.MAPDATE.src="onedot.gif"}document.images.MAPTEMP.src="onedot.gif";if(IE4){document.images.CHART.filters[0].apply()}document.images.CHART.src=a;if(coastlayer!=""){document.images.CLOUDMASK.src=coastlayer}else{document.images.CLOUDMASK.src="onedot.gif"}if(IE4){document.images.CHART.filters[0].play()}}else{document.layers.CHARTLAYER.document.images.CHART.src=a;if(coastlayer!=""){document.layers.CLOUDMASKLAYER.document.images.CLOUDMASK.src=coastlayer}else{document.layers.CLOUDMASKLAYER.document.images.CLOUDMASK.src="onedot.gif"}if(!sstarray[curmappos][3]){document.layers.MAPDATELAYER.document.images.MAPDATE.src="onedot.gif"}document.layers.MAPTEMPDRAG.document.images.MAPTEMP.src="onedot.gif"}}function displaybottom(){if(bottomdetail!=""){if(IE4|dom){if(!sstarray[curmappos][3]){document.images.MAPDATE.src="onedot.gif"}document.images.MAPTEMP.src="onedot.gif";if(IE4){document.images.CHART.filters[0].apply()}document.images.CHART.src=bottomdetail;document.images.CLOUDMASK.src="onedot.gif";if(IE4){document.images.CHART.filters[0].play()}}else{document.layers.CHARTLAYER.document.images.CHART.src=bottomdetail;document.layers.CLOUDMASKLAYER.document.images.CLOUDMASK.src="onedot.gif";if(!sstarray[curmappos][3]){document.layers.MAPDATELAYER.document.images.MAPDATE.src="onedot.gif"}document.layers.MAPTEMPDRAG.document.images.MAPTEMP.src="onedot.gif"}}}function displaychart2(){if(cwregion=="bz"){if(chart2!=""){if(IE4|dom){if(!sstarray[curmappos][3]){document.images.MAPDATE.src="onedot.gif"}document.images.MAPTEMP.src="onedot.gif";if(IE4){document.images.CHART2.filters[0].apply()}document.images.CHART2.src=chart2;document.images.CLOUDMASK.src="onedot.gif";if(IE4){document.images.CHART2.filters[0].play()}}else{document.layers.CHARTLAYER2.document.images.CHART2.src=chart2;document.layers.CLOUDMASKLAYER.document.images.CLOUDMASK.src="onedot.gif";if(!sstarray[curmappos][3]){document.layers.MAPDATELAYER.document.images.MAPDATE.src="onedot.gif"}document.layers.MAPTEMPDRAG.document.images.MAPTEMP.src="onedot.gif"}}}}function displaytopo(){if(topodetail!=""){if(IE4|dom){if(!sstarray[curmappos][3]){document.images.MAPDATE.src="onedot.gif"}document.images.MAPTEMP.src="onedot.gif";if(IE4){document.images.CHART.filters[0].apply()}document.images.CHART.src=topodetail;if(IE4){document.images.CHART.filters[0].play()}}else{document.layers.CHARTLAYER.document.images.CHART.src=topodetail;if(sstarray[curmappos][3]){document.layers.MAPDATELAYER.document.images.MAPDATE.src="onedot.gif"}document.layers.MAPTEMPDRAG.document.images.MAPTEMP.src="onedot.gif"}}}function addZero(a){return((a<10)?"0":"")+a}function formatDate(c,l){var m=addZero(c.getDate());var g=addZero(c.getMonth()+1);var a=addZero(c.getFullYear());var f=addZero(c.getFullYear().toString().substring(3,4));var k=(l.indexOf("yyyy")>-1?a:f);var e=addZero(c.getHours());var d=addZero(c.getMinutes());var b=addZero(c.getSeconds());var h=l.replace(/dd/g,m).replace(/MM/g,g).replace(/y{1,4}/g,k);h=h.replace(/hh/g,e).replace(/mm/g,d).replace(/ss/g,b);return h}function hideLayer(a){if(document.getElementById){document.getElementById(a).style.visibility="hidden"}else{if(document.all){document.all[a].style.visibility="hidden"}else{if(document.layers){document.layers[a].visibility="hidden"}}}}function showLayer(a){if(document.getElementById){document.getElementById(a).style.visibility="visible"}else{if(document.all){document.all[a].style.visibility="visible"}else{if(document.layers){document.layers[a].visibility="visible"}}}}function datefromjulian(k){var t=parseInt(k);if(t<366){t=t+2453005}var g=t+0.5;var q=Math.floor(g);var l=g-q;var u=0;var o=0;if(q<2299161){u=q}else{o=Math.floor((q-1867216.25)/36524.25);u=q+1+o-Math.floor(o/4)}var s=u+1524;var p=Math.floor((s-122.1)/365.25);var n=Math.floor(365.25*p);var m=Math.floor((s-n)/30.6001);var r=s-n-Math.floor(30.6001*m)+l;var h=0;r=Math.floor(r);if(m<13.5){h=m-1}else{h=m-13}retval=addZero(h)+addZero(r)+"";return retval}function line(c,m,b,k,d){var f=b-c;var e=k-m;var h=Math.floor(Math.sqrt(f*f+e*e)/d);var l=getNormalizedAngle(c,m,b,k);var p=d*Math.cos(l);var n=-d*Math.sin(l);var o=[];for(var g=0;g<=h;g++){o[g*2]=Math.round(c+g*p);o[g*2+1]=Math.round(m+g*n)}if(o[g*2-2]!=b||o[g*2-1]!=k){o[g*2]=b;o[g*2+1]=k}j=0;xcor=[],ycor=[];for(g=0;g<o.length;g+=2){xcor[j]=o[g];ycor[j]=o[g+1];j++}for(g=0;g<xcor.length;++g){document.body.insertAdjacentHTML("beforeEnd",'<div id="MYLINE'+g+'" style="position:absolute;width:3px;height:3px;clip:rect(0,2,2,0);left:'+xcor[g]+"px;top:"+ycor[g]+'px;background-color:black">.</div>')}}function getNormalizedAngle(d,f,c,e){var b=Math.abs(d-c);var a=Math.abs(f-e);if(b==0&&a==0){angle=0}else{if(b==0){angle=Math.PI/2}else{angle=Math.atan(a/b)}}if(d<c){if(f<e){angle=Math.PI*2-angle}}else{if(f<e){angle=Math.PI+angle}else{angle=Math.PI-angle}}return angle}function bearing(e,f,a,c){var b=Math.sin(f-c)*Math.cos(a);var d=Math.cos(e)*Math.sin(a)-Math.sin(e)*Math.cos(a)*Math.cos(f-c);return(Math.atan2(-b,d))}function radToBrng(a){var c=(a*180/Math.PI+360)%360+1/7200;var b=Math.round(c*100)/100;return(b)}function brngToRad(b){var a=b*Math.PI/180;return(a)}function handlekey(a){if(IE4||dom){if(!IE4){thekey=a.which}else{thekey=window.event.keyCode}switch(thekey){case 84:if(cwregion=="bz"){if(runningtrack){runningtrack=false}else{runningtrack=true;pathgentimeline()}}break;case 116:if(cwregion=="bz"){if(runningtrack){runningtrack=false}else{runningtrack=true;pathgentimeline()}}break;case 71:makekml();break;case 103:makekml();break;case 66:displaybottom();break;case 98:displaybottom();break;case 80:prevmap();break;case 112:prevmap();break;case 78:nextmap();break;case 110:nextmap();break;case 83:displaymap();break;case 115:displaymap();break;case 45:if(dispmode!="print"){zoomoutmap()}break;case 43:if(dispmode!="print"){zoominmap()}break;case 61:if(dispmode!="print"){zoominmap()}break;case 67:showcloudmask=showcloudmask?false:true;displaymap();break;case 99:showcloudmask=showcloudmask?false:true;displaymap();break;case 119:if(showwpts){showwpts=false}else{showwpts=true}dealwpts("nopath");break;case 87:if(showwpts){showwpts=false}else{showwpts=true}dealwpts("nopath");break;case 109:displaymodis();break;case 77:displaymodis();break;case 122:if(cwregion=="bz"){displaydapz()}break;case 90:if(cwregion=="bz"){displaydapz()}break;case 7:makekml("waypointsonly");break;default:}}}function printhelp(){alert("PRINTING HELP:  First select FILE and then PRINT PREVIEW from the menu bar.  If you are using Internet Explorer select PRINT and then CURRENT PAGE and then PRINT again.  You may have to adjust all margins to .5.  IE should remember your margin settings.  If you are using NETSCAPE, select PRINT, and then MARGINS.  Set all margins to .25.  Select OK then PRINT then OK again.")}function regionhandler(){if(NS4){var a=document.layers.GOTOREGION.document.forms.myform.gotoregion.options[document.layers.GOTOREGION.document.forms.myform.gotoregion.selectedIndex].value}else{var a=document.myform.gotoregion.options[document.myform.gotoregion.selectedIndex].value}window.location.href=a}function datehandler(){if(NS4){if(document.layers.MAPDATELAYER.document.forms.dateform){curmappos=document.layers.MAPDATELAYER.document.forms.dateform.gotodate.selectedIndex}}else{if(document.dateform){curmappos=document.dateform.gotodate.selectedIndex}}displaymap();dealhspts("nopath");displaystats()}function updatemapdate(){if(NS4){if(document.layers.MAPDATELAYER.document.forms.dateform){document.layers.MAPDATELAYER.document.forms.dateform.gotodate.options[curmappos].selected=true}}else{if(document.dateform){document.dateform.gotodate.options[curmappos].selected=true}}}function changeport(a){switch(true){case dom:document.getElementById("WPTIMG"+a).src="micons/165.gif";if(homeport!=a){document.getElementById("WPTIMG"+homeport).src=document.getElementById("WPTIMG"+homeport).origimgsrc}break;case IE4:document.all("WPTIMG"+a).src="micons/165.gif";if(homeport!=a){document.all("WPTIMG"+homeport).src=document.all("WPTIMG"+a).origimgsrc}break;default:document.layers("WPTIMG"+a).src="micons/165.gif";if(homeport!=a){document.layers("WPTIMG"+homeport).src=document.layers("WPTIMG"+homeport).origimgsrc}break}if(document.images.FISHCAPTION&&document.images.FISHCAPTION.src.search(/onedot/)<=0){document.images.FISHCAPTION.src="onedot.gif"}homeport=a;for(x=1;x<9999;x++){wptlayer="WPT"+x;testlayer=dom?document.getElementById(wptlayer):IE4?document.all[wptlayer]:document.layers[wptlayer];if(testlayer==null){x=9999;return}itsamatch=false;switch(true){case dom:itsamatch=document.getElementById(wptlayer).wptname==a;break;case IE4:itsamatch=document.all(wptlayer).wptname==a;break;default:itsamatch=document.layers(wptlayer).wptname==a;break}if(itsamatch){switch(true){case dom:wptLat=document.getElementById(wptlayer).Lat;wptLon=document.getElementById(wptlayer).Lon;break;case IE4:wptLat=document.all[wptlayer].Lat;wptLon=document.all[wptlayer].Lon;break;default:wptLat=document.layers[wptlayer].Lat;wptLon=document.layers[wptlayer].Lon;break}x=9999;theLon=Math.floor((wptLon/100));theLon=(theLon*60)+(wptLon-(theLon*100));theLat=Math.floor(wptLat/100);theLat=(theLat*60)+(wptLat-(theLat*100));homeportlat=theLat;homeportlon=theLon;homeporty=Math.round(getPixelCoord(theLat,"Lat")-yOffset);homeportx=Math.round(getPixelCoord(theLon,"Lon")-xOffset);if(CurLat!=0&&CurLon!=0){CurDist=getlatlondist(homeportlat,homeportlon,CurLat,CurLon);CurBear=getbear(homeportlat,homeportlon,CurLat,CurLon)}displaystats()}}}function newwindow(a){if(window.tempbreak2&&!tempbreak2.closed){tempbreak2.location=a}else{tempbreak2=window.open(a)}tempbreak2.focus()}function pathgentimeline(){if(runningtrack){if(trPos<(tracklog.length-1)){thepathx=Math.round(getPixelCoord(tracklog[trPos],"Lon"));thepathy=Math.round(getPixelCoord(tracklog[trPos+1],"Lat"));runningtrack=true;setdraglogodirection(thepathx,thepathy);pathobj.moveTo(thepathx,thepathy);curX=thepathx;curY=thepathy;newX=curX;newY=curY;setdraglogodirection();currentX=curX;currentY=curY;trPos+=2;calcLatLon();displaystats();setTimeout("pathgentimeline()",20)}else{runningtrack=false;trPos=0}}}function makekml(f){var d=new String(window.location.href);var h=d.split("//");var k=h[1];var b=k.split("/");var g="http://"+b[0]+"/";if(sstarray[curmappos][3]){title=sstarray[curmappos][3]}else{title=sstarray[curmappos][0]}if(sstarray[curmappos][2]){legend=sstarray[curmappos][2]}else{legend=""}if(f=="waypointsonly"||f=="fishicononly"){title="";legend="";c="";chart2="";a=""}else{if(sstarray[curmappos][0]){var c=new String(sstarray[curmappos][0]);if(bottomdetail!=""){if(IE4|dom){if(document.images.CHART.src.indexOf(bottomdetail)!=-1){title="Bottom Detail";legend="";c=bottomdetail}}else{if(document.layers.CHARTLAYER.document.images.CHART.src.indexOf(bottomdetail)!=-1){c=bottomdetail}}}}else{var c=new String("")}if(sstarray[curmappos][4]&&c!=bottomdetail){chart2=sstarray[curmappos][4]}else{chart2=""}if(addonlayer!=""){var a=new String(addonlayer);a=a.substring(0,a.indexOf("gif"))+"png"}else{var a=new String("")}}logo="&logo="+g+"tempbreaklogo.gif";if(title!=""){if(NS4){var e=document.layers.GOTOREGION.document.forms.myform.gotoregion.options[document.layers.GOTOREGION.document.forms.myform.gotoregion.selectedIndex].text}else{var e=document.myform.gotoregion.options[document.myform.gotoregion.selectedIndex].text}title=e+" "+title;title="&title="+escape(title)}else{title="&title="}if(legend!=""){legend="&legend="+g+legend}else{legend="&legend="}if(c!=""){if(c.indexOf("http")==0){c="&chart1="+c}else{c="&chart1="+g+c}}else{c="&chart1="}if(chart2!=""&&showcloudmask){chart2="&chart2="+g+chart2}else{chart2="&chart2="}if(a!=""){a="&chart3="+g+a}else{a="&chart3="}if(LastLat==0){iconlat="&lat="}else{iconlat="&lat="+LastLat/60}if(LastLon==0){iconlon="&lon=";latlontitle="&latlontitle="}else{iconlon="&lon="+LastLon/60;latlontitle="&latlontitle=";if(IE4||dom){latlontitle=latlontitle+escape("Latitude: "+document.forms.FISHY.lat.value);latlontitle=latlontitle+escape("<br/>Longitude: "+document.forms.FISHY.lon.value);latlontitle=latlontitle+escape("<br/>Distance: "+document.forms.FISHY.dist.value);latlontitle=latlontitle+escape("<br/>Bearing: "+document.forms.FISHY.bear.value)}else{latlontitle=latlontitle+escape("Latitude: "+document.layers.DRAGLOGO.document.forms.FISHY.lat.value);latlontitle=latlontitle+escape("<br/>Longitude: "+document.layers.DRAGLOGO.document.forms.FISHY.lon.value);latlontitle=latlontitle+escape("<br/>Distance: "+document.layers.DRAGLOGO.document.forms.FISHY.dist.value);latlontitle=latlontitle+escape("<br/>Bearing: "+document.layers.DRAGLOGO.document.forms.FISHY.bear.value)}}if(f=="waypointsonly"){title="Waypoints";title="&title="+escape(title);waypointfile="&waypointfile="+sstdir+"magwpt.mgl"}else{waypointfile="&waypointfile="}if(f=="fishicononly"){title="Fish Icon";title="&title="+escape(title)}thezoom="&zoom="+zoomlevel;document.getElementById("kmlframe").src="makekml.php?"+title+c+chart2+a+legend+logo+"&HiLat="+HiLat/60+"&HiLon=-"+HiLon/60+"&LoLat="+LoLat/60+"&LoLon=-"+LoLon/60+latlontitle+waypointfile+iconlat+iconlon+thezoom};