// JavaScript Document
// Rochford
// <![CDATA[

  var timeoutID = 0;
  var map;
  var zoom = 11;
  var center_lat = "44.210"; 
  var center_lon = "-103.770";
  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);
	
	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);


//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);
});


//Point01
   var Point01_Text = "<p class='gm_hdr'>Ride Start</p><p class='gm_txt'>A large opening, for snow mobile parking provides a good starting point for this ride, a 1/4 mile from the US85 turnoff.</p>";
   var Point01_Lat = 44.304411; ////44.304411,-103.801146
   var Point01_Long = -103.801146;
   var Point01 = new GMarker(new GLatLng(Point01_Lat,Point01_Long),ICOgreen);
     GEvent.addListener(Point01, "click", function()
{
     Point01.openInfoWindowHtml(Point01_Text);
});

//Point02
   var Point02_Text = "<p class='gm_hdr'>Rochford</p><p class='gm_txt'>A great little Living Ghost town in the heart of the Black Hills. Food and Beverge available at the Moonshine Gulch.</p>";
   var Point02_Lat = 44.122808;
   var Point02_Long = -103.700724;
   var Point02 = new GMarker(new GLatLng(Point02_Lat,Point02_Long),ICOred);
     GEvent.addListener(Point02, "click", function()
{
     Point02.openInfoWindowHtml(Point02_Text);
});

//Point03
   var Point03_Text = "<p class='gm_hdr'>Dumont Trailhead</p><p class='gm_txt'>Water is available here at the Dumont Trailhead of the Mickelson Trail</p>";
   var Point03_Lat = 44.227;
   var Point03_Long = -103.7857;
   var Point03 = new GMarker(new GLatLng(Point03_Lat,Point03_Long),ICOblue);
     GEvent.addListener(Point03, "click", function()
{
     Point03.openInfoWindowHtml(Point03_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());	
    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(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 plRochRd = new GPolyline.fromEncoded({
  color: "#ff0000",
  weight: 2,
  opacity: 0.7,
  points: "i}kmGbspxRpy@{@vSpG|WbHzL?vN~EbN{ChZfQ~VOxVaKvDmEp]}H`Kk@zP}[xGiCrlAhN`LvF`HvIrHk@`K{@rHcPhKuLzFeTtAmLxRg`@~Cqh@jNuWj]uAvWqN~q@aVnAoFtn@aZjDsGlCkH~Ci@nw@YlHeE``@sDfHyF?_J}EgNzAgFtFwB`Ik@`V{ODa]xCqKrR_FjI_JtLqVxLiC|UqRtPkDfMeIlWoB|S}DzLj@bFwBtQwBtLgFxHuHdIyC~Ma@tLsK`HXnKcArGQbK?fD_RfGoTdDcHJcLuEkDb@qC`CmEPqRiF_JQoF",
  levels: "P?FGHFGIFGHGEJEHFIEFGFHEGIKGHIDHEFDJEGEHEFEFGIEGEHFLFGHFGEIFEGFHEFGJFGEFEDHFEP",
  zoomFactor: 2,
  numLevels: 18
});
  map.addOverlay(plRochRd);
	
// 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());

}
//]]>