// JavaScript Document
				
		var geocoder = new GClientGeocoder();
		function displayPoint(map, markers, marker, index){
			if ($('#map_message').is(':hidden')) {//Allow toggling of markers
				$('#map_message').fadeIn();
			}
			else{//Remove all .active classes and hide markers
				$('#map_message').hide();
				$(".active").removeClass();
			}
			//$("#map_message").hide();//Default behaviour, doesn't allow toggling
			
			var moveEnd = GEvent.addListener(map, "moveend", function(){
				var markerOffset = map.fromLatLngToDivPixel(marker.getLatLng());
				$("#map_message")
					.html('<div class="xbtn"></div>' + markers[index][0])//Use information from array
					.fadeIn()
					.css({ top:markerOffset.y, left:markerOffset.x });
			GEvent.removeListener(moveEnd);
			});
			map.panTo(marker.getLatLng());
		}	
		
		function setActive(el){
			$(".active").removeClass();//Remove all .active classes
			$("#map_list").find('li').eq(el).addClass('active');//Find list element equal to index number and set active
			$(el).addClass('active');//Set active if list element clicked directly
		}
		
		function configureOverlays($this, map, markers, mark, i, delayTime)
		{
			//setTimeout(function(){ 
				map.addOverlay(mark);
		/*==========================================================
						configureOverlays-List Setup
		==========================================================*/
		
				//Declared variables of the array. Label:property name, Statelabel:State
				var label = markers[i][1];
				var stateLabel = markers[i][3];
				
				//var orderingByState = typeof(markers[i][2]);
					
					//if(orderingByState == "object")
					//{
						// Populate state using variable
						
						// hide blank entrie function
						if(stateLabel == ""){
							$("<li />")
							.html(stateLabel)//Use list item label from array
							.css({'display' : 'none'})
							.appendTo("#map_list");
						}
						else
						{
							$("<li />")
								.html(stateLabel)//Use list item label from array
								.css({ 'color' : '#3b73a9', 'background' : '#f5f5f5', 'font-weight' : 'bold', 'cursor' : 'default', 'display' : 'block', 'width' : '510px'})
								.appendTo("#map_list");	
						}
						
						// Populate property using variables
						$("<li />")
							.html(label)//Use list item label from array
							.css({ 'width' : '162px', 'padding-bottom' : '10px' , 'padding-top' : '10px'})
							.click(function(){
								displayPoint(map, markers, mark, i);
								setActive(this);//Show active state
								
							})
						.appendTo("#map_list");
					//}
					//else
					//{
						//alert('The city of ');
											 
					//}
				
						
											 
					
					
		/* ======================================================== 
					//configureOverlays-Overlay Events
		   ========================================================	*/		
			
				GEvent.addListener(mark, "click", function(){
					displayPoint(map, markers, mark, i);
					setActive(i);//Show active location
				});
				
				displayPoint(map, markers, mark, i);
				setActive(i);//Show active location
				if (i == (markers.length - 1)) {//If last item in array
					//setTimeout(function(){//Remove active class and fade marker after delay
					$("#map_message").fadeOut(3500);
						//setActive();
					//}, 3500);
				}
			//}, delayTime); 		
		}
		$(document).ready(function(){ //Start script when ready
				   
			if (document.getElementById("map_canvas")) {//Checks to see that the page element exists and to prevent conflict with other maps
				
				//Default map center location
				var defaultLat = 39.57182223734374;
				var defaultLon = -100.01953125;
				
				
				
				var markers = new Array();
markers[0] = ["<strong>Secrets Inn</strong><br/>930 Park Avenue South Lake Tahoe, CA 96150 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/SecretsInn.aspx\">View Property</a>", "Secrets Inn", (new GMarker(new GLatLng(38.9563,-119.947364))),"California"];
markers[1] = ["<strong>Heavenly Inn</strong><br/>924 Park Avenue South Lake Tahoe, CA 96150 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/HeavenlyInn.aspx\">View Property</a>", "Heavenly Inn", (new GMarker(new GLatLng(38.956462,-119.947734))),""];
markers[2] = [/*"<strong>The Lodge at Stillwater</strong><br/>912 N Summit Blvd, Frisco, Colorado, United States, 80443 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/TheLodgeatStillwater.aspx\">View Property</a>", "The Lodge at Stillwater", (new GMarker(new GLatLng(39.590029,-106.095093))),"Colorado"*/];
markers[3] = [];
markers[4] = ["<strong>Kicking Horse</strong><br/>150 Village Road, Granby, Colorado, United States, 80446 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/kickinghorse.aspx\">View Property</a>", "Kicking Horse", (new GMarker(new GLatLng(40.0592,-105.917))),"Colorado"];
markers[5] = [];
markers[6] = [/*"<strong>The Pines at Meadowridge</strong><br/>51 Meadow Ln., Winter Park, CO 80482 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/thepinesatmeadowridge.aspx\">View Property</a>", "The Pines at Meadowridge", (new GMarker(new GLatLng(39.945211,-105.802337))),""*/];

markers[7] = [];

markers[8] = ["<strong>Teton Creek Resort</strong><br/>274 Teton Creek Drive, Driggs, Idaho, United States, 83422 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/TetonCreekResort.aspx\">View Property</a>", "Teton Creek Resort", (new GMarker(new GLatLng(43.7482571,-111.0483065))),"Idaho"];
markers[9] = [/*"<strong>Shawnee Village</strong><br/>472 Needle Peak Rd., Stateline, Nevada, 89449 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/ShawneeVillage.aspx\">View Property</a>", "Shawnee Village", (new GMarker(new GLatLng(38.9596418,-119.8900465))),"Nevada"*/];

markers[10] = [/*"<strong>Colorado Rocky Mtn Resorts</strong><br/>750 Wells Fargo Lane, Stateline, Nevada, United States, 89449 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/ColoradoRockyMtnResorts.aspx\">View Property</a>", "Colorado Rocky Mtn Resorts", (new GMarker(new GLatLng(38.9624079,-119.9399029))),""*/];

markers[11] = ["<strong>Tahoe Village</strong><br/>472 Needle Peak Rd., Stateline, Nevada, United States, 89449 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/TahoeVillage.aspx\">View Property</a>", "Tahoe Village", (new GMarker(new GLatLng(38.9596418,-119.8900465))),"Nevada"];

markers[12] = [/*"<strong>Ten Mile Creek</strong><br/>Bush Rd., Swiftwater, Pennsylvania, United States, 18326 <br/><a href=\"/Properties/PropertiesbyRegion/MidAtlanticUS/TenMileCreek.aspx\">View Property</a>", "Ten Mile Creek", (new GMarker(new GLatLng(41.1039775,-75.2820275))),"Pennsylvania"*/];

markers[13] = [/*"<strong>Beaver Village</strong><br/>5905 Highway 17 South, Jack Frost Mountain, Blakeslee, Pennsylvania, United States, 18610 <br/><a href=\"/Properties/PropertiesbyRegion/MidAtlanticUS/BeaverVillage.aspx\">View Property</a>", "Beaver Village", (new GMarker(new GLatLng(41.102221,-75.6091696))),""*/];

/*markers[14] = ["<strong>The Pines at Meadowridge</strong><br/>55 Mountainview Circle, Shawnee on Delaware, Pennsylvania, United States, 18301 <br/><a href=\"/Properties/PropertiesbyRegion/MidAtlanticUS/ThePinesatMeadowridge.aspx\">View Property</a>", "The Pines at Meadowridge", (new GMarker(new GLatLng(41.0443005,-75.1127457))),""];*/

markers[14] = ["<strong>Tahoe Summit Village</strong><br/>750 Wells Fargo Lane, Stateline, Nevada, United States, 89449<br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/TahoeSummitVillage.aspx\">View Property</a>", "Tahoe Summit Village", (new GMarker(new GLatLng(38.9624079,-119.9399029))),""];

markers[15] = ["<strong>Eagles's Nest</strong><br/>472 Needle Peak Rd., Stateline, Nevada, 89449<br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/EaglesNest.aspx\">View Property</a>", "Eagles's Nest", (new GMarker(new GLatLng(38.9596422,-119.8900412))),""];

markers[16] = ["<strong>The Lodge at Stillwater</strong><br/>1364 West Stillwater Drive, Heber City, Utah, United States, 84098 <br/><a href=\"/Properties/PropertiesbyRegion/WesternUS/TheLodgeatStillwater.aspx\">View Property</a>", "The Lodge at Stillwater", (new GMarker(new GLatLng(40.6281,-111.437))),"Utah"];
markers[17] = ["<strong>Home Farm Cottages</strong><br/>1386 Pucker Street, Stowe, Vermont, United States, 05672 <br/><a href=\"/Properties/PropertiesbyRegion/NortheastUS/HomeFarmCottages.aspx\">View Property</a>", "Home Farm Cottages", (new GMarker(new GLatLng(44.478035,-72.665527))),"Vermont"];
markers[18] = ["<strong>Lakeview Villas</strong><br/>419 King St, Basye, Virginia, United States, 22810 <br/><a href=\"/Properties/PropertiesbyRegion/MidAtlanticUS/LakeviewVillas.aspx\">View Property</a>", "Lakeview Villas", (new GMarker(new GLatLng(38.799725,-78.7961441))),"Virginia"];



				var map = new google.maps.Map2($("#map_canvas").get(0));//Initialise google maps
				//map.setCenter(new GLatLng(defaultLat, defaultLon), 4);//Set location to the default and zoom level to x
				//map.disableDoubleClickZoom();//Disable zooming
				
				//=============================
					//Zoom Functionality
				//=============================
				var customUI = map.getDefaultUI();
        		customUI.maptypes.hybrid = false; // Remove MapType.G_HYBRID_MAP
        		map.setUI(customUI);
				map.setMapType(G_PHYSICAL_MAP);
				
				

				//=============================
				      //Functions Called
				//=============================
				$.each(markers,function(i,marker){
					var delayTime = ((i * 0) / (0.5 * markers.length));//Delay time decreases as number of markers increases
					var mark;
					
					var location = typeof(marker[2]);
					
					if(location == "object") //Only for Get Lat String
					{
						var mark = marker[2];
						configureOverlays(this, map, markers, mark, i, delayTime);
					}
					else
					{
						
						//geocoder.getLatLng(
						//	 marker[0]
						//	,function(point) {
						//		mark = new GMarker(point);
						//		configureOverlays(this, map, markers, mark, i, delayTime);
						//	}
						//);							 
					}
					
					
				});
				
				map.setCenter(new GLatLng(defaultLat, defaultLon), 3);//Resets location of the default and zoom level to x again
				$("#map_list").css("opacity","0.2").animate({opacity: 1}, 1100);//Fade in menu
				$("#map_message").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE));
			}//End if map_canvas exists
			
			
			/* 
			================================
			  X hide #map_message config 
			================================
			*/	
			$("#map_message").click(function () { 
				$("#map_message").hide(); 
			});	
			
			
		}); //End onReady
