<!-- (c) Copyright 2006-2008 by Golf World Map -->
var map;
var mkrs=new Array();
var mZ=false;
var v_fScr;
var v_offs=false;
var markerDs;
var photoLayer = new GLayer("com.panoramio.all");
var videoLayer = new GLayer("com.youtube.all");
photoLayer.Visible = true;
videoLayer.Visible = true;
var icon = new GIcon();
icon.image = "/img/mkr.png";
icon.transparent = "/img/mkr_t.png";
icon.iconSize = new GSize(16,32);
icon.iconAnchor = new GPoint(6,30);
icon.infoWindowAnchor = new GPoint(8, 2);
function cMkr(id,p,u,n,c,i,r){
 var mkr = new GMarker(p,icon);
 mkrs[id]=new Array();
 mkrs[id][0]=mkr;
 mkrs[id][1]=n;
 if(c!=""){
   mkrs[id][2]='<span class="fm"><br>'+c+'</span>';
 } else {
   mkrs[id][2]='';
 }
 if(i!=""){
    mkrs[id][3]='<span class="fm"><br><br>'+i+'</span>';
  } else {
    mkrs[id][3]='';
 }
 if(r=="r"){
  mkrs[id][4]="<div id='mkr_d'>-> <a class=lnk href=javascript:mkrC('"+u+"','l')>click to zoom into this region</a></div>";
 }else{
  mkrs[id][4]="<div id='mkr_d'>-> <a class=lnk href=javascript:mkrC('"+u+"','l')>click to zoom to this course<br>for more information and photos</a></div>";
 }
 if(v_fScr){
  GEvent.addListener(mkr,"mouseover",function(){oI(id);});
  GEvent.addListener(mkr,"mouseout",function(){cI()});
  GEvent.addListener(mkr,"click",function(){mkrC(u,'l');});
 }else{
  GEvent.addListener(mkr,"click",function(){mkrC(u);});
 }
 return mkr;
}
function oI(id){
 if(mkrs[id]){
  mkrs[id][0].openInfoWindowHtml('<span class="ft">'+mkrs[id][1]+'</span>'+mkrs[id][2]+mkrs[id][3]+'<span class="fs"><br><br>'+mkrs[id][4]+'</span>');
 }
}
function cI(){
 if(map){
  map.closeInfoWindow();
 }
}
function mkrC(u,l){
 var mkr_d=document.getElementById("mkr_d");
 if(mkr_d && (l=='l')){
  mkr_d.innerHTML='-> <span class="fst">loading...</span>';
 }
 if(u.length>0){
  window.location.href=u;
 }
}
function urlHash(){
 window.location.replace(window.location.href.substring(0,window.location.href.indexOf('#')) + '#' + map.getCenter().lat()+","+map.getCenter().lng()+","+map.getZoom());
}
function iM(n,e,s,w,cLat,cLng,fScr,d,offs){
 if (GBrowserIsCompatible()){
  v_offs=offs;
  v_fScr=fScr;
  if (v_fScr) {
   sFScr();
  }
  map=new GMap2(document.getElementById("map"));
  map.setCenter(new GLatLng(cLat,cLng),0);
  if(window.location.hash!=""){
   var h=window.location.hash;
   var lt=h.substring(1,h.indexOf(","));
   var lg=h.substring(h.indexOf(",")+1,h.lastIndexOf(","));
   var z=h.substring(h.lastIndexOf(",")+1);
   if((isNaN(parseFloat(lt)))||(isNaN(parseFloat(lg)))||(isNaN(parseInt(z)))) {
    map.setZoom(map.getBoundsZoomLevel(new GLatLngBounds(new GLatLng(s,w),new GLatLng(n,e))));
    map.savePosition();
   }else{
    map.setZoom(map.getBoundsZoomLevel(new GLatLngBounds(new GLatLng(s,w),new GLatLng(n,e))));
    map.savePosition();
    map.setCenter(new GLatLng(parseFloat(lt),parseFloat(lg)),parseInt(z));
   }
  }else{
   map.setZoom(map.getBoundsZoomLevel(new GLatLngBounds(new GLatLng(s,w),new GLatLng(n,e))));
   map.savePosition();
  }
  map.setMapType(G_SATELLITE_MAP);
  if (v_fScr) {
   map.addControl(new GLargeMapControl3D());
   map.addControl(new GScaleControl());
   map.addControl(new GMenuMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 39)));
   map.addMapType(G_PHYSICAL_MAP);
   map.addMapType(G_SATELLITE_3D_MAP);
   map.addOverlay(photoLayer);
   map.addOverlay(videoLayer);
   map.enableDoubleClickZoom();
   map.enableContinuousZoom();
   map.enableScrollWheelZoom();
   if (window.attachEvent) {
    window.attachEvent("onresize",function(){sFScr()} );
    window.attachEvent("onresize",function(){map.checkResize()} );
   } else {
    window.addEventListener("resize",function(){sFScr()},false);
    window.addEventListener("resize",function(){map.checkResize()},false);
   }
   GEvent.addListener(map,"zoom",function(){urlHash();});
   GEvent.addListener(map,"moveend",function(){urlHash();});
  }else{
   map.disableDragging();
  }
  if(d.length>0){
   photoLayer.Visible = false;
   videoLayer.Visible = false;
   photoLayer.hide();
   videoLayer.hide();
   pMkr = function(doc) {
    l = doc.split("%");
    for (var i=1; i<l.length; i++) {
     if (l[i].length > 1) {
      parts = l[i].split("|");
      map.addOverlay(cMkr(parts[0],new GLatLng(parseFloat(parts[1]),parseFloat(parts[2])),parts[3],parts[4],parts[5],parts[6],parts[7]));
     }
    }
   }
   GDownloadUrl(d,pMkr);
  }
  if(markerDs){
   photoLayer.Visible = false;
   videoLayer.Visible = false;
   photoLayer.hide();
   videoLayer.hide();
   setTimeout("aOverlays()",10);
  }
  if(v_fScr){
    map.addControl(new PhotosControl());
  }
  if(document.getElementById("m")){
   window.onscroll=function(){document.getElementById("m").style.visibility='hidden';}
  }
 }else{
  document.getElementById("nS").innerHTML='<br>Sorry, but your browser can not display the satellite images.<br>Please check this <a href="http://local.google.com/support/bin/answer.py?answer=16532&topic=1499">browser compatibility page</a> for more information.';
 }
}
function GUnload(){
 if (window.GUnloadApi){
  GUnloadApi();
 }
}
function gH(){
 var windowSize;
 if (window.self && self.innerWidth){
  if(v_offs){
   return self.innerHeight-103;
  }else{
   return self.innerHeight-91;
  }
 }
 if (document.documentElement && document.documentElement.clientHeight) {
  return document.documentElement.clientHeight;
 }
 if(v_offs){
  return document.body.clientHeight-110;
 }else{
  return document.body.clientHeight-100;
 }
}
function px(a){
 return Math.round(a) + "px";
}
function sFScr() {
 var h = gH();
 if (h < 330){
  h = 330;
 } else if (v_offs && (h < 600)){
  h = h + 12;
 }
 document.getElementById("map").style.height=px(h);
 var d = document.getElementById("d");
 if(d){
  d.style.height=parseInt(px(h))-5;
 }
}
function aMkr(id,lat,lng,u,n,c,i,r){
 if(!markerDs){
  markerDs=new Array();
 }
 var markerD = new Array(id,new GLatLng(parseFloat(lat),parseFloat(lng)),u,n,c,i,r);
 markerDs[markerDs.length]=markerD;
}
function aOverlays() {
 var bounds = new GLatLngBounds;
 var i=0;
 for (; i<markerDs.length; i++) {
  var m=cMkr(markerDs[i][0],markerDs[i][1],markerDs[i][2],markerDs[i][3],markerDs[i][4],markerDs[i][5],markerDs[i][6]);
  map.addOverlay(m);
  bounds.extend(m.getPoint());
 }
 var zL=map.getBoundsZoomLevel(bounds);
 if(i<=1){
  zL=6;
 }
 var nE=bounds.getNorthEast();
 var sW=bounds.getSouthWest();
 var cLat=(nE.lat()+sW.lat())/2;
 var cLng=(nE.lng()+sW.lng())/2;
 if(zL<=3 && cLng>45) {
  if(zL>1){
    zL=zL-1;
  }
  cLng=90-cLng;
 }
 if(zL>13){
  photoLayer.Visible = true;
  videoLayer.Visible = true;
  photoLayer.show();
  videoLayer.show()
 }else{
  photoLayer.Visible = false;
  videoLayer.Visible = false;
  photoLayer.hide();
  videoLayer.hide();
 }
 map.addControl(new PhotosControl());
 map.setCenter(new GLatLng(cLat,cLng),zL);
 map.savePosition();
 if(window.location.hash!=""){
  var h=window.location.hash;
  var lt=h.substring(1,h.indexOf(","));
  var lg=h.substring(h.indexOf(",")+1,h.lastIndexOf(","));
  var z=h.substring(h.lastIndexOf(",")+1);
  if(!((isNaN(parseFloat(lt)))||(isNaN(parseFloat(lg)))||(isNaN(parseInt(z))))) {
   map.setCenter(new GLatLng(parseFloat(lt),parseFloat(lg)),parseInt(z));
  }
 }
}
function PhotosControl() {
}
PhotosControl.prototype = new GControl();

PhotosControl.prototype.initialize = function(map) {
 var container = document.createElement("div");
 container.style.border = "1px solid black";
 container.style.fontSize = "12px";
 container.style.fontFamily = "Arial, sans-serif";
 container.style.width="80px";
 container.style.height="25px";
 container.style.backgroundColor = "#ffffff";
if (photoLayer.Visible) {
  var c = 'checked';
 } else {
  var c = '';
 }
 container.innerHTML = '<input type="checkbox" onclick="togglePhotoLayer()" ' +c+ '><b>Photos<\/b><\/input>';
 map.getContainer().appendChild(container);
 return container;
}
PhotosControl.prototype.getDefaultPosition = function() {
 return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
}
function togglePhotoLayer() {
 if(photoLayer.Visible){
  photoLayer.hide();
  videoLayer.hide();
  photoLayer.Visible=false;
  videoLayer.Visible=false;
 }else{
  photoLayer.show();
  videoLayer.show();
  photoLayer.Visible=true;
  videoLayer.Visible=true;
 }
}
