// JavaScript Document
// Old Baldy
// <![CDATA[

  var timeoutID = 0;
  var map;
  var zoom = 14;
  var center_lat = "44.3523645";
  var center_lon = "-104.0079";
  var iWidthOV = 150;				// Changes the Width and Height of the OverView map in the LR corner, 
  var iHeightOV = 120;  			// (cont'd) should be smaller and proportional
  var iRightLogo = iWidthOV;	// This changes the absolute right position of the Ridgerider Logo, based on iWidth
  var iRightGSC = iRightLogo + iWidthOV; //   " " of the ScaleControl, based on iRightLogo, and the width of the logo (150)

	ICOgreen  =  new GIcon();
	ICOgreen.image  =  "http://labs.google.com/ridefinder/images/mm_20_green.png";
	ICOgreen.shadow  =  "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	ICOgreen.iconSize  =  new GSize(12, 20);
	ICOgreen.shadowSize  =  new GSize(22, 20);
	ICOgreen.iconAnchor  =  new GPoint(6, 20);
	ICOgreen.infoWindowAnchor  =  new GPoint(3, 24);
	
	ICOblue  =  new GIcon();
	ICOblue.image  =  "http://labs.google.com/ridefinder/images/mm_20_blue.png";
	ICOblue.shadow  =  "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	ICOblue.iconSize  =  new GSize(12, 20);
	ICOblue.shadowSize  =  new GSize(22, 20);
	ICOblue.iconAnchor  =  new GPoint(6, 20);
	ICOblue.infoWindowAnchor  =  new GPoint(3, 24);
	
	ICObrown  =  new GIcon();
	ICObrown.image  =  "http://labs.google.com/ridefinder/images/mm_20_brown.png";
	ICObrown.shadow  =  "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	ICObrown.iconSize  =  new GSize(12, 20);
	ICObrown.shadowSize  =  new GSize(22, 20);
	ICObrown.iconAnchor  =  new GPoint(6, 20);
	ICObrown.infoWindowAnchor  =  new GPoint(3, 24);

	ICOdbs  =  new GIcon();
	ICOdbs.image  =  "/images/icodbs.png";
	ICOdbs.shadow  =  "/images/icodbs_sh.png";
	ICOdbs.iconSize  =  new GSize(31, 40);
	ICOdbs.shadowSize  =  new GSize(52, 40);
	ICOdbs.iconAnchor  =  new GPoint(16, 40);
	ICOdbs.infoWindowAnchor  =  new GPoint(3, 24);

//Point01
   var Point01_Text = "<p class='gm_hdr'>Short Fork</p><p class='gm_txt'>Left for Counter Clockwise, Right for Clockwise.</p>";
   var Point01_Lat = 44.34278;
   var Point01_Long = -104.00579;
   var Point01 = new GMarker(new GLatLng(Point01_Lat,Point01_Long),ICOblue);
     GEvent.addListener(Point01, "click", function()
{
     Point01.openInfoWindowHtml(Point01_Text);
});

//Point02
   var Point02_Text = "<p class='gm_hdr'>Hard Turn</p><p class='gm_txt'>Clockwise: remember to take a hard<br />right at the bottom of a short rocky drop.</p>";
   var Point02_Lat = 44.3427;
   var Point02_Long = -104.0195;
   var Point02 = new GMarker(new GLatLng(Point02_Lat,Point02_Long),ICOblue);
     GEvent.addListener(Point02, "click", function()
{
     Point02.openInfoWindowHtml(Point02_Text);
});

//Point03
   var Point03_Text = "<p class='gm_hdr'>Bridge Crossing</p><p class='gm_txt'></p>";
   var Point03_Lat = 44.35013;
   var Point03_Long = -104.01272;
   var Point03 = new GMarker(new GLatLng(Point03_Lat,Point03_Long),ICOblue);
     GEvent.addListener(Point03, "click", function()
{
     Point03.openInfoWindowHtml(Point03_Text);
});

//Point04
   var Point04_Text = "<p class='gm_hdr'>Gully Crossing</p><p class='gm_txt'>Big grassy gully crossing.</p>";
   var Point04_Lat = 44.35835;
   var Point04_Long = -104.00463;
   var Point04 = new GMarker(new GLatLng(Point04_Lat,Point04_Long),ICOblue);
     GEvent.addListener(Point04, "click", function()
{
     Point04.openInfoWindowHtml(Point04_Text);
});

//Point05
   var Point05_Text = "<p class='gm_hdr'>Summit Intersection</p><p class='gm_txt'>Start of the Summit Spur<br />Clockwise: turn right-or left after summit ascent<br />Counter Clockwise: turn left-or continue straight after summit ascent.</p>";
   var Point05_Lat = 44.35957;
   var Point05_Long = -104.00511;
   var Point05 = new GMarker(new GLatLng(Point05_Lat,Point05_Long),ICOblue);
     GEvent.addListener(Point05, "click", function()
{
     Point05.openInfoWindowHtml(Point05_Text);
});

//Point06
   var Point06_Text = "<p class='gm_hdr'>Summit</p><p class='gm_txt'>Old Baldy Mountain 6096 Feet</p>";
   var Point06_Lat = 44.36184;
   var Point06_Long = -104.01523;
   var Point06 = new GMarker(new GLatLng(Point06_Lat,Point06_Long),ICObrown);
     GEvent.addListener(Point06, "click", function()
{
     Point06.openInfoWindowHtml(Point06_Text);
});

//Point07
   var Point07_Text = "<p class='gm_hdr'>Old Baldy Damn</p><p class='gm_txt'>A bridge crossing and spur to Taco Alley.</p>";
   var Point07_Lat = 44.36076;
   var Point07_Long = -104.00182;
   var Point07 = new GMarker(new GLatLng(Point07_Lat,Point07_Long),ICOblue);
     GEvent.addListener(Point07, "click", function()
{
     Point07.openInfoWindowHtml(Point07_Text);
});

//Point08
   var Point08_Text = "<p class='gm_hdr'>Aspen Grove</p><p class='gm_txt'>A muddy sweeping drop through a large Aspen Forest.</p>";
   var Point08_Lat = 44.35498;
   var Point08_Long = -103.99842;
   var Point08 = new GMarker(new GLatLng(Point08_Lat,Point08_Long),ICOblue);
     GEvent.addListener(Point08, "click", function()
{
     Point08.openInfoWindowHtml(Point08_Text);
});

//Point09
   var Point09_Text = "<p class='gm_hdr'>Watering Hole</p><p class='gm_txt'>Muddy bog, dried out by mid-summer.</p>";
   var Point09_Lat = 44.34384;
   var Point09_Long = -104.00623;
   var Point09 = new GMarker(new GLatLng(Point09_Lat,Point09_Long),ICOblue);
     GEvent.addListener(Point09, "click", function()
{
     Point09.openInfoWindowHtml(Point09_Text);
});

//Point10
   var Point10_Text = "<p class='gm_hdr'>Trailhead</p><p class='gm_txt'>Trailhead and Parking for Old Baldy and Rimrock Trails.</p>";
   var Point10_Lat = 44.342322;
   var Point10_Long = -104.0044;
   var Point10 = new GMarker(new GLatLng(Point10_Lat,Point10_Long),ICOgreen);
     GEvent.addListener(Point10, "click", function()
{
     Point10.openInfoWindowHtml(Point10_Text);
});
  
//PointDBS
   var PointDBS_Text = "<p class='gm_hdr'>Deadwood Bicycles</p><p class='gm_txt'>&nbsp;&nbsp;&nbsp;180 Sherman Street<br />&nbsp;&nbsp;&nbsp;Deadwood, SD 57732<br />&nbsp;&nbsp;&nbsp;605.578.1345<br />&nbsp;&nbsp;&nbsp;DeadwoodBicycles.com<br />&nbsp;<br /><a class='gm' href='http://deadwoodbicycles.com/rides/rides.html' target='_self'>Deadwood Bicycles Rides Page</a></p>";
   var PointDBS_Lat = 44.37190727;  //44.37190727, -103.72799635
   var PointDBS_Long = -103.72799635;
   var PointDBS = new GMarker(new GLatLng(PointDBS_Lat,PointDBS_Long),ICOdbs);
     GEvent.addListener(PointDBS, "click", function()
{
     PointDBS.openInfoWindowHtml(PointDBS_Text);
});
  
  
function onLoad()
{
        map = new GMap2(document.getElementById("map"));
	map.enableDoubleClickZoom();
    map.enableScrollWheelZoom();
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(center_lat, center_lon), zoom, G_HYBRID_MAP);
    map.addControl(new GOverviewMapControl(new GSize(iWidthOV,iHeightOV)));
		map.addOverlay(Point01);
		map.addOverlay(Point02);
		map.addOverlay(Point03);
		map.addOverlay(Point04);
		map.addOverlay(Point05);
		map.addOverlay(Point06);
		map.addOverlay(Point07);
		map.addOverlay(Point08);
		map.addOverlay(Point09);
		map.addOverlay(Point10);
	    map.addOverlay(PointDBS);
//  Load Topo Map Overlay
    var topoCopyright = new GCopyright(1,
    new GLatLngBounds(new GLatLng(18,-169),new GLatLng(72,-66) ),
        5, "Copyright USGS");
    var topoCopyrightCollection = new GCopyrightCollection('Topo Maps');
    topoCopyrightCollection.addCopyright(topoCopyright);
    
    var topoTileSize = 256;
    var topoURL = 'http://terraservice.net/ogcmap6.ashx?version=1.1.1&request=GetMap&styles=&srs=EPSG:4326&format=image/jpeg&bgcolor=0xCCCCCC&exceptions=INIMAGE&layers=DRG';
    topoGetTileURL=function(tile, zoom){
	  var southWestPixel = new GPoint(tile.x*topoTileSize,(tile.y+1)*topoTileSize);
	  var northEastPixel = new GPoint((tile.x+1)*topoTileSize,tile.y*topoTileSize);
	  var southWestCoords = G_SATELLITE_MAP.getProjection().fromPixelToLatLng(southWestPixel,zoom);
	  var northEastCoords = G_SATELLITE_MAP.getProjection().fromPixelToLatLng(northEastPixel,zoom);
	  var bbox = southWestCoords.lng()+','+southWestCoords.lat()+','+northEastCoords.lng()+','+northEastCoords.lat();
	  return topoURL+'&bbox='+bbox+'&width='+topoTileSize+'&height='+topoTileSize;
    }
    var topoTileLayers = [new GTileLayer(topoCopyrightCollection,5,17)];
    topoTileLayers[0].getTileUrl = topoGetTileURL;
    var topoMap = new GMapType(topoTileLayers, G_SATELLITE_MAP.getProjection(), "Topo",
      {errorMessage:"Data Not Available", tileSize:topoTileSize});
    map.addMapType(topoMap);

var plLoop = new GPolyline.fromEncoded({
  color: "#DD0000",
  weight: 2,
  opacity: 0.8,
  points: "orsmGnjxyRC?F???CSGSM??f@SvB]~CCf@aA~CGbGPjCIf@CRK~Ho@rDs@zEG~CqAz@WRQRGz@CRbAbGjA~CbB~CB?Yf@a@R{@bBMf@b@bBNf@hAf@`Bf@o@z@ORYz@mAf@e@Rs@{@aB{EGkCqAcGw@_D{@?s@RyCRiERgAnAgBz@]RyAbBU?]Ra@{@CoA?oABg@Xg@tAsDQoASwBB{@Qg@]S]SmASOg@a@_Do@nA]bGC?sBRQ?]RO?k@Rm@?g@g@OSUf@{@Si@SiCwBU{@Sg@MSX?QSu@oA_@cBG{@]cB?SOoAISCSCg@YwBLoAz@oAd@{@h@{@\\{@??j@{@\\{@`@{@Jg@P{@?{@T{@d@g@TRN?f@{@d@{@KSk@{@US]{@O?a@?eCS]R{@g@i@g@w@Sk@SS{@iAcBcAg@mAg@_A{@G?w@f@gBz@ORMRCnACf@Yz@URyAf@w@RY?cA?_AR_Az@w@wBYkCUoAGSUSSg@eAg@e@cBa@oAIg@H{@Q{@Yg@OoA?{@IoADS?oAIoA?SH?I?Hg@?g@g@_DHcBp@oAlAg@~@g@TSTSxA{@\\?\\z@?z@Yz@NRH?l@g@fBRz@oAB?F?Pg@d@g@v@???\\g@n@Rh@S?Rn@Sd@ST?l@SH??R?z@\\?B?`@f@n@?p@?r@f@FRKvBF~CTnATz@??B?v@Rh@?j@?J?F?n@Rz@f@bAz@hAvBd@f@X?T?Nf@LRRRrBRvB?lAvBlAvBjAvBz@z@fDnAbAnAn@nAJvBj@bBd@bB`@z@nBjCv@z@`@?TSn@g@VRn@vBbDz@rAoAbBgEnDSd@Sd@oFXcBH?Rf@BRH?F?G?",
  levels: "P?@?AB@BCDEDFCDAGDEDFBACAEDH?BCDBEBCDCADCFCECFDCDEGCDEDABCDCBDECDFBCBDBECE?DAFACHBCBDBEBCAADFCDCAEABCGCDCEB?DBFBCDBCADECACDBCBEBCFCBDHCDE@CDAECBFADCAECDGCDAIBCDEBCDBFBCDCEA@@BCDGCDEABDBCBDABFCD?@BEC?BDBAGBCD@ACB?DEBCDCFCB?DCBE@ACDGDBCAEABDHDEDCFCDEGCDECBDCBFDEDGHDE@BI@AP",
  zoomFactor: 2,
  numLevels: 18
});
  map.addOverlay(plLoop);

var plSpur = new GPolyline.fromEncoded({
  color: "#FF00FF",
  weight: 2,
  opacity: 0.7,
  points: "i~vmGznxyRe@f@s@f@GR?RMRa@z@CRUnAs@vBu@RqAbBmAbBw@vB{@~C??OfERnAPf@JRn@vBBz@GbB????r@f@`@RBRB?\\f@CnAGf@`@R?RMnAHf@I?e@g@??KSYSa@f@?RFf@?RBR?S?R??B?",
  levels: "P?CABADAECDFCDE?GCBDCEC??CDA?FCBBDCB@B?ACDAEABAA?P",
  zoomFactor: 2,
  numLevels: 18
});
  map.addOverlay(plSpur);

// Add Ridge Rders Logo
function ctrlLogo() {}

	ctrlLogo.prototype = new GControl();
	ctrlLogo.prototype.initialize = function() {
	var contents = document.createElement("div");
	contents.style.width="150px";			// Fixed Width of the Logo, do not change
	contents.style.height="100px";			// Fixed Height of the Logo, do not change
	contents.innerHTML="<a href='http://deadwoodbicycles.com/rides/rides.html' target='_self'><img src='/images/logo_ctrl.png' alt='Deadwood Bicycles Logo' title='Click for Deadwood Bicycles Ride Page' border='0'></a>";
	document.getElementById('map').appendChild(contents);
	return contents;
      }
	ctrlLogo.prototype.printable=function(){return true};
	ctrlLogo.prototype.selectable=function(){return true};
	ctrlLogo.prototype.getDefaultPosition=function(){
	return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(iRightLogo,15))
      }

  map.addControl(new ctrlLogo());

}   
//]]>
