﻿// Create marker information for start and finish gates
var night = false; // determine which image to use as webcam marker icon
 
// special markers intended for rental properties
var smarker = new Array();
smarker[smarker.length] = ["hotel.png",54.7663,-127.272483,'Sidewinder Inn','<p class="infowindowtitle"><a href="http://www.sidewinderinn.com" target="_blank">Sidewinder Inn</a></p><img src="mapsource/images/sidewinder.JPG" style="float:left; margin:0 5px 0 0;width:75px;height:56px;" /><p class="line-space">140 Prairie Road<br />offers exclusive accommodation in the Bulkley Valley Alpine environment.</p>'];
smarker[smarker.length] = ["hotel.png",54.766875,-127.275487,'Watson & Company Outdoors','<p class="infowindowtitle"><a href="http://www.watsonoutdoors.ca" target="_blank">Watson & Company Outdoors</a></p><img src="mapsource/images/watsonandco.jpg" style="float:left; margin:0 5px 0 0;width:75px;height:56px;" /><p class="line-space">213 Prairie Road<br />Bright and comfortable providing on-mountain accommodation.</p>'];
smarker[smarker.length] = ["resort.png",54.765216,-127.268921,'Hudson Bay Mountain Resort','<img src="mapsource/images/logo_HBMR.jpg" style="float:left; margin:0 5px 0 0;width:75px;height:99px;" /><p class="infowindowtitle"><a href="http://www.hudsonbaymountain.com" target="_blank">Hudson Bay Mountain Resort</a></p><p class="line-space">100 Prairie Road<br />Its always been about the powder.</p>'];

// lot markers
var lmarker = new Array();
lmarker[lmarker.length] = ["100",54.765043,-127.268406];
lmarker[lmarker.length] = ["120",54.765699,-127.271109];
lmarker[lmarker.length] = ["127",54.767674,-127.269600];
lmarker[lmarker.length] = ["130",54.765854,-127.271796];
lmarker[lmarker.length] = ["136",54.767754,-127.271817];
lmarker[lmarker.length] = ["140",54.766126,-127.272482];
lmarker[lmarker.length] = ["147",54.768509,-127.273073];
lmarker[lmarker.length] = ["201",54.765754,-127.274257];
lmarker[lmarker.length] = ["212",54.768645,-127.274467];
lmarker[lmarker.length] = ["213",54.766875,-127.275208];
lmarker[lmarker.length] = ["230",54.766665,-127.276989];
lmarker[lmarker.length] = ["301",54.767401,-127.280647];
lmarker[lmarker.length] = ["290",54.770099,-127.277213];
lmarker[lmarker.length] = ["294",54.770436,-127.275856];
lmarker[lmarker.length] = ["308",54.767785,-127.282632];
lmarker[lmarker.length] = ["319",54.769221,-127.282321];
lmarker[lmarker.length] = ["347",54.769481,-127.279016];
lmarker[lmarker.length] = ["350",54.770978,-127.280721];
lmarker[lmarker.length] = ["354",54.772451,-127.277271];

// Create the map image and markers
function lotMap() {
  if (GBrowserIsCompatible()) {
       // large scale map
       var wcmap = new GMap2(document.getElementById("course_loc"));
       wcmap.setCenter(new GLatLng(54.772900,-127.25), 3);
       wcmap.disableDragging();
       // add marker at store location
       var latlng = new GLatLng(54.772900,-127.25);
       wcmap.addOverlay(new GMarker(latlng, {title:'Prairie Cabin Owners, Smithers BC'}));
         
       // small scale map with markers
       var map = new GMap2(document.getElementById("course_map"));
       //map.setCenter(new GLatLng(54.774361,-127.261291), 14);
       map.setCenter(new GLatLng(54.767874,-127.275306), 15);
       map.setUIToDefault();
       //map.addMapType(G_SATELLITE_3D_MAP); // earth enabled
       map.addControl(new GMapTypeControl());
       map.setMapType(G_HYBRID_MAP); // set default view to normal+satellite

		// Lot markers
      for (i=0; i<lmarker.length; i++) {
		var lotIcon = MapIconMaker.createFlatIcon({shape: "circle", width: 20, height: 20, label: lmarker[i][0], labelColor:"#ffffff", labelSize:8, primaryColor: "#800000"});
       var point = new GLatLng(lmarker[i][1], lmarker[i][2]);		
		var lotno = new GMarker(point, {icon: lotIcon});
		map.addOverlay(lotno);
		}
        
       // Create a base icon for all of our special markers
       var hotelIcon = new GIcon();
       hotelIcon.image = "http://www.prairiecabinowners.com/mapsource/images/hotel.png";
       hotelIcon.iconSize = new GSize(32, 37);
       hotelIcon.iconAnchor = new GPoint(18, 42);
       hotelIcon.infoWindowAnchor = new GPoint(9, 2);

      // Create special markers     
      function createMarker(point,iconTitle,desc,source) {
       markerOptions = {icon:hotelIcon, title:iconTitle};
       var marker = new GMarker(point, markerOptions);
       GEvent.addListener(marker, "click", function() {
            //marker.openInfoWindowHtml('<p class="marker">'+desc+'</p>');
            marker.openExtInfoWindow(map, "snow_window", '<div class="marker">'+desc+'</div>', {beakOffset: 3} ); 
       });
       return marker;
      }
       
      // Display special markers markers
      for (i=0; i<smarker.length; i++) {
			hotelIcon.image = "http://www.prairiecabinowners.com/mapsource/images/"+smarker[i][0];
			var point = new GLatLng(smarker[i][1], smarker[i][2]);
			map.addOverlay(createMarker(point, smarker[i][3], smarker[i][4], smarker[i][0]))
      }
		      
      // Create an icon for webcam - actual live webcam picture
	  p1 = new GLatLng(54.768056, -127.271825);
	  var np = new GIcon();
	  np.image = night ? "http://www.sandrah.biz/netcam/cambtn/btn_night.jpg" : "http://www.sandrah.biz/netcam/jimmycam.jpg";
	  //np.shadow = "mapsource/images/shadow.png";
	  np.iconSize = new GSize(32, 32);
	  np.iconAnchor = new GPoint(16, 31);
      np.infoWindowAnchor = new GPoint(16, 16);
      
      // Create icon and marker to simulate a border for the np (webcam picture) icon
      var nps = new GIcon();
	  nps.image = "mapsource/images/surround.png";
	  nps.iconSize = new GSize(38, 38);
	  nps.iconAnchor = new GPoint(19, 34);
	  npmk = new GMarker(p1,{icon:nps,clickable:false});
	  map.addOverlay(npmk);				
      
      // Create the webcam marker and info window		
	  npmk = new GMarker(p1,{icon:np,title:"Weather Headquarters",clickable:true});
	  map.addOverlay(npmk);				
      GEvent.addListener(npmk, "click", function() {
       npmk.openExtInfoWindow(map, "snow_window", '<div id="wxwindow"><p class="infowindowtitle">Live weather on<br />Hudson Bay Mountain</p><iframe src="http://www.sandrah.biz/camerabtn/shcamwx.php" name="camerabtn" frameborder="0" scrolling="no" style="margin:0;padding:0;width:160px;height:132px;border:none;"></iframe></div>', {beakOffset: 3} ); 
      });
     
  } // End GBrowserIsCompatible()
} // initialize google map

