// JavaScript Document
// Tinton Trail
// <![CDATA[

  var timeoutID = 0;
  var map;
  var zoom = 12;
  var center_lat = "44.44345236"; //44.44345236, -103.921201225
  var center_lon = "-103.921201225";
  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);
	
	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);
	
	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'>Tinton Trailhead</p><p class='gm_txt'>A small lot just after the cattle guard. Beware of low flying peacocks.<br />&nbsp;<br />Spirt of the Hills Animal Sanctuary is right next to the trailhead.</p>";
   var Point01_Lat = 44.47175503;  //44.47175503, -103.90023708
   var Point01_Long = -103.90023708;
   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'>Turn Around Tinton Trail</p><p class='gm_txt'>The top of Tinton is near the Big Hill Trail System Trailhead.  When you come up to the fence, the trail splits. The BH TH is off to the right, roughly NW.</p>";
   var Point02_Lat = 44.41514969;  //44.41514969, -103.94216537
   var Point02_Long = -103.94216537;
   var Point02 = new GMarker(new GLatLng(Point02_Lat,Point02_Long),ICOred);
     GEvent.addListener(Point02, "click", function()
{
     Point02.openInfoWindowHtml(Point02_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(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 plTinton = new GPolyline.fromEncoded({
  color: "#CC0000",
  weight: 2,
  opacity: 0.8,
  points: "m{lnGn_dyR`K~KtA?U_GnB\\rDtErBuAnB`Bz@rBF`IdAbFd@fApCrBUnBz@zBzBdAfDFxAdECbC{@i@G\\p@hBrBdAlAxApExALz@xCrBzDqAbBC|Ah@|A|B|C_BbD~A]kD`@_ArDs@v@cDhAeBjAqAvBe@`@tA~AMfE~@|BzCXnD|AhDdK`Cz@dB`@hClAh@lAuCbAyG`BsB~@_Dr@m@`IpCnVkBbAhAtC~@`BIjBrGtAv@lCyAX}BfAaBdG_Cv@cB`BiBxCBzCuAfCC`Cw@~Bl@|A~E`I|ALtAuArDGtAhB{@tJlCjHv@|ChEfB~MxA|FbD~DbC~GpGhKtDzPzDfCjFv@XhCjDtGv@dLfAtCiC|C_CxFUxATxJv@bEFzE`CfC`FaD~@?]|PLj@dBrBb@zB",
  levels: "P?CDEEFDEEFGDCEDFDECACHCEBFDECGDEDCFDECHCDIDEDFCGCDEFDCFHCECFCECDGCDJDEDFDGCDEDFEHEFDGEIDFCEGDEFCEGHDECFBDP",
  zoomFactor: 2,
  numLevels: 18
});
  map.addOverlay(plTinton);

// Add DBS Logo
function ctrlLogo() {}

	ctrlLogo.prototype = new GControl();
	ctrlLogo.prototype.initialize = function() {
	var contents = document.createElement("div");
	contents.style.width="120px";			// Fixed Width of the Logo, do not change
	contents.style.height="120px";			// 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());

}   
//]]>
