/* 
	This script, website, and all map data is Copyright© 2008 WCG:ITX, Inc. All Rights Reserved 
	William Walseth - bill@wcg-itx.com http://www.wcg-itx.com
*/













































var overviewmap=null;var overviewpoints=null;var localmap=null;var localpoints=null;var strLocalMapName=null;var startZoom=8;var s0=null;var s8;var i2=null;var currentMarker=null;var i3=null;var nZoom;var center;var nicEdit=null;var editText="";var rightContent=null;var dtStart=null;var i5=null;var i7=null;var i8=null;var s6="";var b1=false;function showMap(bMap, strVideo){if(bMap){document.getElementById("overviewmap").style.display="";}else{document.getElementById("overviewmap").style.display="none";}}function showOverviewSites(x3){var sites=x3.documentElement.getElementsByTagName("site");if(x3.documentElement.getAttribute("err")){document.getElementById("overviewmap").innerHTML=x3.documentElement.getAttribute("err");return;}s6=x3.documentElement.getAttribute("overviewmap");overviewmap=new GMap(document.getElementById("overviewmap"));overviewmap.addControl(new GSmallMapControl());overviewmap.setCenter(new GLatLng(0,0),0);overviewmap.enableDoubleClickZoom();try{overviewmap.addControl(new WCGColor());}catch(err){delete err;}var bounds=new GLatLngBounds();var i=0;overviewpoints=new Array();for(i=0; i < sites.length; i++){overviewpoints.push(new f20(sites[i], overviewmap));}for(id in overviewpoints){bounds.extend(f16(overviewpoints[id], overviewmap), overviewmap);}var nZoom=overviewmap.getBoundsZoomLevel(bounds);if(nZoom > 12){nZoom=12;}overviewmap.setZoom(nZoom);overviewmap.setCenter(bounds.getCenter());overviewmap.setMapType(G_HYBRID_MAP);}function showLocalSites(x3){var sites=x3.documentElement.getElementsByTagName("site");if(x3.documentElement.getAttribute("err")){document.getElementById("localmap").innerHTML=x3.documentElement.getAttribute("err");return;}s6=x3.documentElement.getAttribute("localmap");localmap=new GMap(document.getElementById("localmap"));localmap.addControl(new GSmallMapControl());localmap.setCenter(new GLatLng(0,0),0);localmap.enableDoubleClickZoom();try{localmap.addControl(new WCGColor());}catch(err){delete err;}var bounds=new GLatLngBounds();var i=0;localpoints=new Array();for(i=0; i < sites.length; i++){localpoints.push(new f20(sites[i], localmap));}for(id in localpoints){bounds.extend(f16(localpoints[id], localmap), localmap);}var nZoom=localmap.getBoundsZoomLevel(bounds);if(nZoom > 12){nZoom=12;}localmap.setMapType(G_HYBRID_MAP);localmap.setZoom(nZoom);localmap.setCenter(bounds.getCenter());}function getIcon(name){var icon=new  GIcon();var s3Base=document.location.href.replace(/home\.aspx/, "");icon.iconSize=new GSize(32,32);icon.shadowSize=new GSize(59,32);icon.iconAnchor=new GPoint(16,32);icon.infoWindowAnchor=new GPoint(16,0);icon.image=s3Base+"/images/"+name+".png";icon.printImage=s3Base+"/images/"+name+".png";icon.shadow=s3Base+"/images/msmarker.shadow.png";icon.printShadow=s3Base+"/images/msmarker.shadow.png";return icon;}function f20(i1, map){this.i1=i1;this.map=map;}function countOrder(marker, b){return marker.count;}function f16(pointData, map){var i1=pointData.i1;var latlng=new GLatLng(i1.getAttribute("lat"), i1.getAttribute("lon"));var marker=null;var icon=getIcon(i1.getAttribute("icon"));var strTitle="";if(pointData.map==overviewmap){strTitle=i1.getAttribute("name")+": ";var count=parseInt(i1.getAttribute("count"));if(count > 1){strTitle+=count+" spots.";}else{strTitle+=count+" spot.";}strTitle+="\rCurrent max wind speed: "+parseFloat(i1.getAttribute("wknots")).toFixed(1)+" knots. ";strTitle+="\rClick this marker to view this map and wind forecast.";marker=new GMarker(latlng,{icon:icon, title:strTitle, zIndexProcess:countOrder});marker.count=count;}else{strTitle=i1.getAttribute("name");strTitle+="\rCurrent wind speed: "+parseFloat(i1.getAttribute("wknots")).toFixed(1)+" knots. ";strTitle+="\rClick this marker to view this map and wind forecast.";marker=new GMarker(latlng,{icon:icon, title:strTitle});}pointData.marker=marker;GEvent.addListener(marker, 'click',function(){f18(pointData);});var visible=false;pointData.show=function(){if(!visible){map.addOverlay(marker);visible=true;}}pointData.show();return latlng;}function f18(pointData){i2=pointData.i1;if(pointData.map==overviewmap){s3="kitesurfing/"+i2.getAttribute("name");}else{s3="kitesurfing/"+strLocalMapName;}window.open(s3, "_self");}function displayMarker(i1){var description=f10(i1);currentMarker.openInfoWindowHtml(description);if(i2.getAttribute("w2")){showWeather2();}else{showWeather();}f2();}function showWeather(){if(i2.getAttribute("currentWeather")){var s9=i2.getAttribute("currentWeather");i7.innerHTML=sideBarLinks("weather")+"<br/>"+s9;}else{i7.innerHTML=sideBarLinks("weather")+"<br/>Weather information will be availble within 30 minutes.";}}function showWeather2(){if(i2.getAttribute("w2")){var s9=i2.getAttribute("w2");i7.innerHTML=sideBarLinks("w2")+"<br/>"+s9;}}function closeForm(){filterPoints("all");f13();i8.innerHTML=rightContent;}function f9(){var s2=i2.getAttribute("desc");if(s2=="<br/>"){s2=null;}if(s2=="<br />"){s2=null;}if(s2==null){if(i2.getAttribute("locked")){s2="";}else{s2="<p>Do you ride here? Please share some information about this spot!</p><p><b><a href='#' onclick='getSpotForm(false);'>Click here</a></b> to write a brief description of this spot, including launch conditions, parking, and access issues.</p>";}}i7.innerHTML=sideBarLinks("description")+"<br/>"+ s2;}function showLink(){var nZoom=map.getZoom();var s3="http://localkitespots.com/vmap.aspx?site="+i2.getAttribute("dt");var strLinkText=i2.getAttribute("name")+" Kitesurfing Map";s3+="&zoom="+nZoom;i7.innerHTML=sideBarLinks("link")+"<p>Share this map with others!</p><p>Copy the following link, to share a view of the current map with others.</p><p>When the link is opened, the map will be zoomed-in just the way you see it now, with the current spot open, and weather forecast showing.</p><a href='"+s3+"'>"+strLinkText+"</a></p><p>If you are posting to a forum, you can use this BB mark-up. [url="+s3+"]"+strLinkText+"[/url]";}function f21(){var from=document.getElementById("from");var to=document.getElementById("to");var s4="<h1>Directions</h1>";map.setMapType(G_MAP_TYPE);i7.innerHTML=s4;f17(from.value, to.value, "en_US");return false;}function popupZoomIn(){nZoom=map.getZoom();map.setZoom(16);}function popupZoomOut(){map.setZoom(nZoom);}function displayDirectionForm(strToFrom){var s4="<form id='dir' onsubmit='return f21();'>";if(strToFrom=="to"){s4+="Directions From:<input size='30' id='from'/><br/>To:"+i2.getAttribute("name")+"<input type='hidden' id='to' value='"+i2.getAttribute("name")+"@"+i2.getAttribute("lat")+","+i2.getAttribute("lon")+"'/>";}else{s4+="Directions From:"+i2.getAttribute("name")+"<br/>To:<input size='30' id='to'/><input type='hidden' id='from' value='"+i2.getAttribute("name")+"@"+i2.getAttribute("lat")+","+i2.getAttribute("lon")+"'/>";}s4+="<br/><input type='submit' value='Get Directions'/></form>";var divPop=document.getElementById("popupcontent");divPop.innerHTML=s4;}function f10(i1){var s4="<div style='width: 260px; height: 200px; overflow-x: auto; overflow-y: auto;'>";s4+=getCurrentSiteName();if(i1.getAttribute("event")){s4+="<p>"+i1.getAttribute("event")+"</p>";}s4+="directions <a href='#' onclick='displayDirectionForm(\"to\");'>to</a> | <a href='#' onclick='displayDirectionForm(\"form\")'>from</a>";if(i2.getAttribute("locked")){s4+=" | <img alt='Locked.  No updates can be made to this spot.' title='Locked.  No updated can be made to this spot.' src='images/lock.png'/>";}else{s4+=" | <a href='#' onclick='getSpotForm(false);'><img alt='Edit Spot Description' title='Edit Spot Description' src='images/database_edit.png'/></a>";}s4+=" | <a href='#' onclick='popupZoomIn();'><img alt='Zoom In' title='Zoom In' src='images/magnifier_zoom_in.png'></a>";s4+=" | <a href='#' onclick='popupZoomOut();'><img alt='Zoom Out' title='Zoom Out' src='images/magnifier_zoom_out.png'></a>";var s2=i1.getAttribute("desc");if((s2==null)||(s2.length < 10)){s2="<p>Do you ride here? Please share some information about this spot!</p><p><b><a href='#' onclick='getSpotForm(false);'>Click here</a></b> to write a brief description of this spot, including launch conditions, parking, and access issues.</p>";}s4+="<br/><div id='popupcontent'>"+s2+"</div>";s4+="</div>";return s4;}function addMoveableMarker(i3){var latlng;var strTitle="New Spot";if(i3){var latlng=new GLatLng(i3.getAttribute("lat"), i3.getAttribute("lon"));strTitle="Move: "+i3.getAttribute("name");}else{var latlng=map.getCenter();}if(i5 !=null){updateLatLon();return;}var icon=getIcon("newpoint");i5=new GMarker(latlng,{draggable: true, bouncy: true, icon:icon, title:strTitle});map.addOverlay(i5);i5.enableDragging();GEvent.addListener(i5,"dragend",function(){updateLatLon();});}function f13(){if(i5 !=null){map.removeOverlay(i5);i5=null;}}function updateLatLon(){var latlon=i5.getPoint();map.setCenter(latlon);var eleLat=document.getElementById("lat");eleLat.value=latlon.lat();var eleLng=document.getElementById("lon");eleLng.value=latlon.lng();}function getSpotForm(bNew){if(bNew==false){i3=i2;f7(i3);}else{i3=null;}addMoveableMarker(i3);var s3="spotform.xml?"+new Date().valueOf();var i6=GXmlHttp.create();i6.open("GET", s3, true);i6.onreadystatechange=function(){if(i6.readyState==4){rightContent=i8.innerHTML;nicEdit=null;filterPoints("hide");if(i3==null){i8.innerHTML="<h1>New Spot</h1>"+i6.responseText;i7.innerHTML="<p>Thanks for adding your spot.  To add your spot:</p><ul><li>Move the <img src='images/newpoint.png'/>marker to your spot</li><li>Zoom in close, to ensure the exact location</li><li>Enter the Name & Description below</li><li>Click 'Save'</li></ul></p>";nicEdit=new nicEditor({buttonList : ['bold','italic','underline','ul', 'image', 'link']}).panelInstance('desc');}else{var s4="<h1>"+i3.getAttribute("name")+"</h1>"+i6.responseText;i8.innerHTML=i6.responseText;mapSiteToForm(i3);nicEdit=new nicEditor({buttonList : ['bold','italic','underline','ul', 'image', 'link']}).panelInstance('desc');var eleDesc=document.getElementById("desc");nicEdit.nicInstances[0].setContent(eleDesc.value);}}}i6.send(null);}function mapSiteToForm(i1){var eleLat=document.getElementById("lat");eleLat.value=i2.getAttribute("lat");var eleLng=document.getElementById("lon");eleLng.value=i2.getAttribute("lon");var eleName=document.getElementById("name");eleName.value=i2.getAttribute("name");var eleDt=document.getElementById("dt");eleDt.value=i2.getAttribute("dt");var eleCheck=document.getElementById("surf");eleCheck.checked=i2.getAttribute("surf");var eleCheck=document.getElementById("snow");eleCheck.checked=i2.getAttribute("snow");var eleCheck=document.getElementById("land");eleCheck.checked=i2.getAttribute("land");var eleCheck=document.getElementById("buggy");eleCheck.checked=i2.getAttribute("buggy");var levels=document.forms['dataform'].elements['level'];var strLevel=i2.getAttribute("level");for(i=0; i < levels.length; i++){if(levels[i].value==strLevel){levels[i].checked=true;}else{levels[i].checked=false;}}var eleDesc=document.getElementById("desc");if(i2.getAttribute("desc")){eleDesc.value=i2.getAttribute("desc");} else{eleDesc.value="";}}function f6(){if(self.innerHeight)return self.innerHeight;if(typeof(window.innerWidth)=='number')return window.innerHeight; if(document.documentElement && document.documentElement.clientHeight)return document.documentElement.clientHeight;if(document.body)return document.body.clientHeight;return 0;}function f2(){return;}function init(){var script=document.createElement("script");script.type="text/javascript";script.src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAA_D7fAcA1B5ytQUNxVpDjZRSBwJabexkKh5GMKZdw4CLTRLKBoRR2hPaiVquWCIpigRWAfDgO-TFTAg&async=2&callback=loadMap";document.body.appendChild(script);}function loadMapControlScripts(){var wcgcolor=document.createElement("script");wcgcolor.type="text/javascript";wcgcolor.src="wcgcolor.js";document.body.appendChild(wcgcolor);}function loadMap(){loadMapControlScripts();var overviewRequest=GXmlHttp.create();overviewRequest.open("GET", "datasvc.aspx?svc=mapsummary&reload="+new Date().valueOf(), true);overviewRequest.onreadystatechange=function(){if(overviewRequest.readyState==4){var x3=overviewRequest.responseXML;if(overviewRequest.status !=200){document.getElementById("overviewmap").innerHTML=overviewRequest.responseText;return;}showOverviewSites(x3);}}overviewRequest.send(null);var localRequest=GXmlHttp.create();var localmap=document.getElementById("localmap");var strLocalMap=localmap.getAttribute("localmap");strLocalMapName=localmap.getAttribute("localmapname");localRequest.open("GET", "datasvc.aspx?svc=mapdata&loc="+strLocalMap+"&reload="+new Date().valueOf(), true);localRequest.onreadystatechange=function(){if(localRequest.readyState==4){var x3=localRequest.responseXML;if(localRequest.status !=200){document.getElementById("localmap").innerHTML=localRequest.responseText;return;}showLocalSites(x3);}}localRequest.send(null);}window.onresize=f2;