var csthTRACKLINEOPTIONS=
{
 strokeOpacity:.3,
 strokeColor:"",
 strokeWeight:3
}
function fChangeTeeName(value)
{
 USGMaps.hCourse.fActive().hTEE.Name=value;
}
function fRollTrackLineWeight()
{
 if(csthTRACKLINEOPTIONS.strokeWeight < 6)
  csthTRACKLINEOPTIONS.strokeWeight++;
 else
  csthTRACKLINEOPTIONS.strokeWeight=1;
 if(USGMaps.hCourse)
 {
  USGMaps.hCourse.fReBuildPolylines(csthTRACKLINEOPTIONS);
 }
 if(fGD("btnTRACKLINEWEIGHT"))
  fGD("btnTRACKLINEWEIGHT").value=csthTRACKLINEOPTIONS.strokeWeight;
}
function fRollTrackLineOpacity()
{
 if(csthTRACKLINEOPTIONS.strokeOpacity < 1.0)
  csthTRACKLINEOPTIONS.strokeOpacity = (csthTRACKLINEOPTIONS.strokeOpacity*100 + 10)/100;
 else
  csthTRACKLINEOPTIONS.strokeOpacity=0.0;
 if(USGMaps.hCourse)
 {
  USGMaps.hCourse.fReBuildPolylines(csthTRACKLINEOPTIONS);
 }
 if(fGD("btnTRACKLINEOPACITY"))
  fGD("btnTRACKLINEOPACITY").value=csthTRACKLINEOPTIONS.strokeOpacity;
}
function fChangeTrackLineColor()
{
 if(fGD("inpTRACKLINECOLOR").value=="")
 {
  csthTRACKLINEOPTIONS.strokeColor="";
 }
 else
 {
  csthTRACKLINEOPTIONS.strokeColor=fGD("inpTRACKLINECOLOR").value;
 }
 if(USGMaps.hCourse)
 {
  USGMaps.hCourse.fReBuildPolylines(csthTRACKLINEOPTIONS);
 }
 if(fGD("inpTRACKLINECOLOR"))
  fGD("inpTRACKLINECOLOR").value=csthTRACKLINEOPTIONS.strokeColor;
}
function fDistance(lat1,lng1,lat2,lng2,sys)
{
 var KMS=112.2;
 var toRad=Math.PI/180;
 var KM2MI=0.621371192;
 var MI2YDS=5280/3;
 var KM2YDS=1093.6133;
 var R = 6371; // km
 if(lat1==lat2 && lng1==lng2)
  return 0.0;
  
// return parseInt(Math.sqrt(Math.pow(lat1-lat2,2)+Math.pow(lng1-lng2,2))*KMS*KM2YDS*10)/10; 
  
  
 var dLat = (lat2-lat1)*toRad;
 var dLon = (lng2-lng1)*toRad; 
 var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
         Math.cos(lat1*toRad) * Math.cos(lat2*toRad) * 
         Math.sin(dLon/2) * Math.sin(dLon/2); 
 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
 return parseInt((R * c)*KM2YDS*10)/10;
}
var hFlagImages=
{
 "Public9":"/images/pins/pin9.gif"
 ,"Private9":"/images/pins/pin9Private.gif"
 ,"Semi-Private9":"/images/pins/pin9Semi-Private.gif"
 ,"Resort9":"/images/pins/pin9Resort.gif"
 ,"Military9":"/images/pins/pin9Military.gif"
 ,"Public18":"/images/pins/pin18.gif"
 ,"Private18":"/images/pins/pin18Private.gif"
 ,"Semi-Private18":"/images/pins/pin18Semi-Private.gif"
 ,"Resort18":"/images/pins/pin18Resort.gif"
 ,"Military18":"/images/pins/pin18Military.gif"
 ,"Public18_M":"/images/pins/pin18_ani.gif"
 ,"Private18_M":"/images/pins/pin18Private_ani.gif"
 ,"Semi-Private18_M":"/images/pins/pin18Semi-Private_ani.gif"
 ,"Resort18_M":"/images/pins/pin18Resort_ani.gif"
 ,"Military18_M":"/images/pins/pin18Military_ani.gif"
 ,"Pin":"/images/pins/pin.gif"
 ,"Pinlg":"/images/pins/pinlg.gif"
 ,"USFlag":"/images/pins/usflag.gif"
 ,"PinShadow":"/images/pins/pin_shad.png"
 ,"fPin":function(hole,dir)
 {
  if(dir)
   return dir+"/pin"+hole+".gif";
  return "/images/pins/pin"+hole+".gif";
 }
 ,"fTee":function(tee,position)
  {
   var img="";
   if(tee.indexOf("lac")>0 || tee.indexOf("ick")>0)
    img="/images/pins/Tee_Black.gif";
   else if(tee.indexOf("lue")>0 || tee.indexOf("ack")>0)
    img="/images/pins/Tee_Blue.gif";
   else if(tee.indexOf("hit")>0 || tee.indexOf("idd")>0)
    img="/images/pins/Tee_White.gif";
   else if(tee.indexOf("ree")>0 || tee.indexOf("lay") > 0)
    img="/images/pins/Tee_Green.gif";
   else if(tee.indexOf("ed")>0 || tee.indexOf("ont")>0 || tee.indexOf("orw")>0)
    img="/images/pins/Tee_Red.gif";
   else if(tee.indexOf("ell")>0 || tee.indexOf("uni")>0 || tee.indexOf("old")>0 || tee.indexOf("ats")>0)
    img="/images/pins/Tee_Yellow.gif";
   else if(tee.indexOf("urp")>0 || tee.indexOf("alm")>0)
    img="/images/pins/Tee_Purple.gif";
   else 
   {
    var acolor=["Green","Black","Blue","White","Red","Yellow","Purple","Green"]
    if(acolor[position])
     img="/images/pins/Tee_"+acolor[position]+".gif";
    else if(img=="")
     img="/images/pins/xhair.gif";
   }
   return img;
  }
 ,"fMark":function(hole){return "/images/pins/xhair.gif";}
 ,"fStroke":function(tee,position)
  {
   var color="";
   if(tee.indexOf("lac")>0 || tee.indexOf("ick")>0)
    color="black";
   else if(tee.indexOf("lue")>0 || tee.indexOf("ack")>0)
    color="blue";
   else if(tee.indexOf("hit")>0 || tee.indexOf("idd")>0)
    color="white";
   else if(tee.indexOf("ree")>0 || tee.indexOf("lay") > 0)
    color="green";
   else if(tee.indexOf("ed")>0 || tee.indexOf("ont")>0 || tee.indexOf("orw")>0)
    color="red";
   else if(tee.indexOf("ell")>0 || tee.indexOf("uni")>0 || tee.indexOf("old")>0 || tee.indexOf("ats")>0)
    color="yellow";
   else if(tee.indexOf("urp")>0 || tee.indexOf("alm")>0)
    color="purple";
   else if(color=="")
   {
    var acolor=["Green","Black","Blue","White","Red","Yellow","Purple","Green"]
    if(acolor[position]!=null)
     color=acolor[position];
    else if(color=="")
     color="cyan";
   }
   return color;
  }
};

