// JavaScript Document
// Spearfish Canyon and O'neil Pass
// <![CDATA[

  var timeoutID = 0;
  var map;
  var zoom = 10;
  var center_lat = "44.480830"; //  44.480830 -104.095459
  var center_lon = "-104.095459";
  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)

	ICOred  =  new GIcon();
	ICOred.image  =  "http://labs.google.com/ridefinder/images/mm_20_red.png";
	ICOred.shadow  =  "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	ICOred.iconSize  =  new GSize(12, 20);
	ICOred.shadowSize  =  new GSize(22, 20);
	ICOred.iconAnchor  =  new GPoint(6, 20);
	ICOred.infoWindowAnchor  =  new GPoint(3, 24);
	
	ICOyellow  =  new GIcon();
	ICOyellow.image  =  "http://labs.google.com/ridefinder/images/mm_20_yellow.png";
	ICOyellow.shadow  =  "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
	ICOyellow.iconSize  =  new GSize(12, 20);
	ICOyellow.shadowSize  =  new GSize(22, 20);
	ICOyellow.iconAnchor  =  new GPoint(6, 20);
	ICOyellow.infoWindowAnchor  =  new GPoint(3, 24);
	
	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);

	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'>Vore Buffalo Jump</p><p class='gm_txt'>A historic native site, currently being studied by the Univ. of Wyoming.<br />&nbsp;<br /><a class='gm' href='http://www.sundancewyoming.com/parallel/vore.htm' target='_blank'>Buffalo Jump</a></p>";
   var Point01_Lat = 44.536;
   var Point01_Long = -104.1572;
   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'>Beulah</p><p class='gm_txt'>Beulah Bar and Buffalo Jump Restraunt, Refuel up on Fat Tire.<br />&nbsp;<br /><a class='gm' href='http://www.beulah.com/' target='_blank'>Beulah, Wyoming</a></p>";
   var Point02_Lat = 44.5444;
   var Point02_Long = -104.0906;
   var Point02 = new GMarker(new GLatLng(Point02_Lat,Point02_Long),ICOyellow);
     GEvent.addListener(Point02, "click", function()
{
     Point02.openInfoWindowHtml(Point02_Text);
});

//Point03
   var Point03_Text = "<p class='gm_hdr'>Sundance</p><p class='gm_txt'>A historic Western Town in Wyoming, where once was jailed the Wild Bunch Gang member, Harry Longabaugh, aka: the Sundance Kid.<br />&nbsp;<br /><a class='gm' href='http://www.sundancewyoming.com/' target='_blank'>Sundance, Wyoming</a></p>";
   var Point03_Lat = 44.40640056;
   var Point03_Long = -104.37506318;
   var Point03 = new GMarker(new GLatLng(Point03_Lat,Point03_Long),ICOred);
     GEvent.addListener(Point03, "click", function()
{
     Point03.openInfoWindowHtml(Point03_Text);
});


//Point04
   var Point04_Text = "<p class='gm_hdr'>Valley Corner</p><p class='gm_txt'>Get a quick bite, or fill up your bottle as you start here on your ride to the wicked west.</p>";
   var Point04_Lat = 44.51792925;	
   var Point04_Long = -103.86989594;
   var Point04 = new GMarker(new GLatLng(Point04_Lat,Point04_Long),ICOgreen);
     GEvent.addListener(Point04, "click", function()
{
     Point04.openInfoWindowHtml(Point04_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.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(iRightGSC, 20)));
	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(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 plFishDance = new GPolyline.fromEncoded({
  color: "#ff0000",
  weight: 2,
  opacity: 0.7,
  points: "_|unGza~xR?b~BM|i@MnOk@vFoCzMiIrXcCvKmA`M?~C?~vACxEQlAc@`Bm@pAkFlE}@|Ao@bCm@rEoCzUeBpNaAvEyAdDwAnB_A~@ki@b`@{CtCuCxDiKpPcAvBwAzBoL`MyBvC}AxCuAdDs@fDcEdRaLb^iC~Kk@bFeI`w@aBnSKbJb@xHpDz^XtHNj{A?rGqApKyAxJAbHJlAzCbSV|IGtfD@zHVbFhHr\\bGbOpApEf@tEVxFa@hgB?dEuEl[K`BKhEGz`ACbGw@bMMnDPvD|@xLJpE@fDeAhp@ItW`@dRlAzRnDp_@pUn|AbLfv@XzBlEvl@`Lr`BnFz{@x@tPzCps@fBn_@f@pIfAjH|BjKzClI~InOlMhR|L`P|DjC|G`Eh^`PdJpExYpIdv@dTxPjFxDhAhEvBhBxAdoBt_BjEhEtCzDtAnBt}AvlCpd@rw@xEzF~IjHfJdE~BbA|D`CvDdDxGnIvCrFn\\lx@vYbs@~{@tuBro@x}A|DrKpBhG`FrVdEjXbGl_@zBbNt@zChEhOzCbLvDjOfBtLzAfJnOxj@",
  levels: "P?GEFHFGEFIDCECFCDGFJDEDFHDEGCEIDEFDGHEFJKEFGEIDFEGCFEJEDGFDHDIDKCDLDFDEGDEHFGIFHJCGHIEKFGEFHFGFIEGHGJFDGDIEFDLMEFGDEFHEIGJHEFIFGHKEFGEHP",
  zoomFactor: 2,
  numLevels: 18
});
  map.addOverlay(plFishDance);


// 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());

}   
//]]>
