function wgOpacityControl(A){this.overlay=A}wgOpacityControl.prototype=new GControl();wgOpacityControl.prototype.setSlider=function(B){var A=Math.round((58*B));this.slide.left=A;this.knob.style.left=A+"px";this.knob.style.top="0px"};wgOpacityControl.prototype.setOpacity=function(){this.overlay.getTileLayer().opacity=this.slide.left/58;this.map.removeOverlay(this.overlay);this.map.addOverlay(this.overlay)};wgOpacityControl.prototype.initialize=function(E){var D=this;this.map=E;var A;var C=navigator.userAgent.toLowerCase();if((C.indexOf("msie")>-1)&&(C.indexOf("opera")<1)){this.ie=true}else{this.ie=false}var B=document.createElement("div");B.style.width="70px";B.style.height="21px";if(this.ie){A="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://marina.geowake.com/chartServer/res/img/opacity-slider.png', sizingMethod='crop');";B.innerHTML='<div id="wgOpacitySlider" style="height:21px; width:70px; '+A+'" ></div>'}else{B.innerHTML='<div id="wgOpacitySlider" style="height:21px; width:70px; background-image: url(http://marina.geowake.com/chartServer/res/img/opacity-slider.png)" ></div>'}if(this.ie){A="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://marina.geowake.com/chartServer/res/img/opacity-slider.png', sizingMethod='crop');";this.knob=document.createElement("div");this.knob.style.height="21px";this.knob.style.width="13px";this.knob.style.overflow="hidden";this.knob_img=document.createElement("div");this.knob_img.style.height="21px";this.knob_img.style.width="83px";this.knob_img.style.filter=A;this.knob_img.style.position="relative";this.knob_img.style.left="-70px";this.knob.appendChild(this.knob_img)}else{this.knob=document.createElement("div");this.knob.style.height="21px";this.knob.style.width="13px";this.knob.style.backgroundImage="url(http://marina.geowake.com/chartServer/res/img/opacity-slider.png)";this.knob.style.backgroundPosition="-70px 0px";this.knob.style.left="58px";this.knob.style.top="0px"}B.appendChild(this.knob);this.slide=new GDraggableObject(this.knob,{container:B});this.slide.setDraggableCursor("pointer");this.slide.setDraggingCursor("pointer");this.container=B;this.setSlider(this.overlay.getTileLayer().opacity);GEvent.addListener(this.slide,"dragend",function(){D.setOpacity()});return B};wgOpacityControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,47))};wgOpacityControl.prototype.addControl=function(){this.map.getContainer().appendChild(this.container);this.setSlider(this.overlay.getTileLayer().opacity)};wgOpacityControl.prototype.removeControl=function(){this.map.getContainer().removeChild(this.container)}
var map;var gw;var marinas_map;var gwWidgetCharts;var geocoder;var wgnewstr0=new Array(2);var wgsubloop=new Array(3);var wgtilelayers0;var opacityControl;var wgchartList=new Array(20);var wgchartListNum=0;var wgchartListSelect=-1;var gwAdType="lite";$(document).ready(function(){HideCtrl("chartList-box-container");HideCtrl("searchcontrol");HideCtrl("aSrchDone");$("#searchBox").focus(function(){if($(this).attr("value")=="Search Now"){$(this).attr("value","")}});$("#searchBox").blur(function(){if($(this).attr("value")==""){$(this).attr("value","Search Now")}})});function LoadMap(B,C,G,E,A,F){if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("map_canvas"));if((B!=0)&&(C!=0)&&(G>0)){map.setCenter(new GLatLng(B,C),G)}else{if($.cookie("_gwWidgetMapCenter")){var D=$.cookie("_gwWidgetMapCenter").split(",");map.setCenter(new GLatLng(D[0],D[1]),13)}else{map.setCenter(new GLatLng(25.767,-80.1394),13)}}map.setMapType(G_HYBRID_MAP);map.addControl(new GScaleControl());map.enableScrollWheelZoom();if(E){gwAdType=E}gw=new gWake(map,gwAdType);gw.AddOverlay();gw.updateOnMove();gwWidgetCharts=new widgetCharts(map);gwWidgetCharts.updateChartOnMove();gwWidgetCharts.doChartMove();geocoder=new GClientGeocoder();opacityControl=new wgOpacityControl(wgcustommap0);map.addControl(opacityControl);if(A=="true"){GEvent.addListener(map,"moveend",function(){var H=map.getCenter();$.cookie("_gwWidgetMapCenter",H.lat()+","+H.lng(),{expires:14})});marinas_map=new GWMarinasGMap(map,gw,F);marinas_map.add_markers();GEvent.addListener(map,"moveend",function(){marinas_map.add_markers()});GEvent.addListener(map,"zoomend",function(){marinas_map.zoom_handler()})}}}function loadKML(A){if(A!=""){gwWidgetCharts.addKMLOverlay(A)}}function displaySearch(){ShowCtrl("searchcontrol");ShowCtrl("aSrchDone");HideCtrl("divGW");HideCtrl("chartList-box-container");HideCtrl("divChatImg");HideCtrl("imgSrch")}function closeSearch(){ShowCtrl("divGW");HideCtrl("searchcontrol");HideCtrl("aSrchDone");ShowCtrl("divChatImg");ShowCtrl("imgSrch")}function ShowCtrl(A){var B=document.getElementById(A);B.style.visibility="visible";B.style.display="block"}function HideCtrl(A){var B=document.getElementById(A);B.style.visibility="hidden";B.style.display="none"}function showAddress(A){if(geocoder){geocoder.getLatLng(A,function(B){if(!B){alert(A+" not found")}else{map.setCenter(B,13);var C=new GMarker(B);map.addOverlay(C);C.openInfoWindowHtml(A);try{onMapViewChanged()}catch(D){}}})}}function widgetCharts(A){this.map=A}widgetCharts.prototype.addKMLOverlay=function(A){this.kmloverlay=new GGeoXml(A);try{this.map.addOverlay(this.kmloverlay)}catch(B){}};widgetCharts.prototype.removeKMLOverlay=function(A){try{this.map.removeOverlay(this.kmloverlay)}catch(B){}};widgetCharts.prototype.updateChartOnMove=function(){this.defineOverlays();this.map.addOverlay(wgcustommap0);GEvent.addListener(this.map,"moveend",function(){gwWidgetCharts.doChartMove()})};widgetCharts.prototype.doChartMove=function(){ne=this.map.getBounds().getNorthEast();sw=this.map.getBounds().getSouthWest();dhtmlLoadScript("http://marina.geowake.com/chartServer/chart?key="+_Gwakeapikey+"&bbox="+ne.y+","+ne.x+","+sw.y+","+sw.x+"&z="+this.map.getZoom()+"&type=json&obj=gwWidgetCharts")};dhtmlLoadScript=function(A){var B=document.createElement("script");B.src=A;B.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(B)};widgetCharts.prototype.updateCharts=function(F){var D=F.charts;var C="<h4>Select a chart below to display on the map</h4>";this.updateChartList(D);C+='<ul id="chartList_Select">';if(wgchartListNum==0){C+='<ul onhover="">No charts were made available for this area. Simply scroll and zoom to a different area. Check out all the nautical charts at <a href="http://www.geowake.com" target="_blank">www.geowake.com</a></ul>'}for(var B=0;B<wgchartListNum;B++){var A=wgchartList[B].chartdir.split("/");var G=A[1];var E=wgchartList[B].name;C+='<li title="Click to toggle" onclick="gwWidgetCharts.chartChange('+B+');">'+E+"</li>"}C+="</ul>";document.getElementById("chartList-box").innerHTML=C;if(wgchartListSelect>-1){$("#chartList_Select li").eq(wgchartListSelect).css("text-decoration","underline")}};widgetCharts.prototype.chartChange=function(A){if(A==wgchartListSelect){this.map.removeOverlay(wgcustommap0);wgchartListSelect=-1;$("#chartList_Select li").eq(A).css("text-decoration","none");opacityControl.removeControl()}else{this.map.removeOverlay(wgcustommap0);if(wgchartListSelect>-1){$("#chartList_Select li").eq(wgchartListSelect).css("text-decoration","none")}$("#chartList_Select li").eq(A).css("text-decoration","underline");wgchartListSelect=A;this.map.addOverlay(wgcustommap0);opacityControl.addControl()}};widgetCharts.prototype.updateChartList=function(F){var B=new Array(20);var A=0;var E;if(F.length>0){E=0;for(var D=0;D<wgchartListNum;D++){for(var C=0;C<F.length;C++){if(wgchartList[D].chartdir==F[C].chartdir){if(wgchartListSelect==D){B[A]=B[0];B[0]=wgchartList[wgchartListSelect];A++;wgchartListSelect=0;E=1;break}else{B[A]=wgchartList[D];A++;break}}}}if(E==0){this.map.removeOverlay(wgcustommap0);wgchartListSelect=-1}for(C=0;C<F.length;C++){E=0;if(wgchartListNum>0){for(D=0;D<wgchartListNum;D++){if(F[C].chartdir==wgchartList[D].chartdir){E=1;break}}if(E==0){B[A]=F[C];A++}}else{B[A]=F[C];A++}}wgchartList=B;wgchartListNum=A}else{wgchartList=B;wgchartListNum=0}};widgetCharts.prototype.defineOverlays=function(){wgsubloop[0]=1;var C=new GCopyrightCollection("YOUR COPYRIGHT :");var B=new GCopyrightCollection("Map Data");var A=new GCopyright(1,new GLatLngBounds(new GLatLng(-90,-180),new GLatLng(90,180)),4,"geowake.com");B.addCopyright(A);wgtilelayers0=new GTileLayer(C);wgtilelayers0.getTileUrl=WGCustomGetTileUrl0;wgtilelayers0.opacity=1;wgtilelayers0.isPng=function(){return true};wgtilelayers0.getOpacity=function(){return this.opacity};wgcustommap0=new GTileLayerOverlay(wgtilelayers0)};WGCustomGetTileUrl0=function(B,A){if(wgchartListSelect>=0){wgnewstr0=wgchartList[wgchartListSelect].chartdir.split("/")}return"http://tile1.geowake.com/chart002/"+wgnewstr0[0]+"/"+wgnewstr0[1]+"/"+WGTileToQuadKey(B.x,B.y,A)+".png"};function WGTileToQuadKey(B,G,F){var D="";for(var E=F;E>0;E--){var C=1<<(E-1);var A=0;if((B&C)!=0){A++}if((G&C)!=0){A+=2}D+=A}return D}

