// 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>Treasure Cay</strong><br/>Treasure Cay Rd., P.O. Box AB-22183, Great Abaco Island, Bahamas <br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/treasurecay.aspx\">View Property</a>", "Treasure Cay ", (new GMarker(new GLatLng(26.6759951,-77.2738355))),"Bahamas"];
markers[1] = ["<strong>Lifestyle Tropical Beach Resort & Spa</strong><br/>Confresi Beach, Puerto Plata, P.O. Box 608, Dominican Republic <br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/LifeStyleTropicalBeachResortSpa.aspx\">View Property</a>", "Lifestyle Tropical Beach Resort & Spa", (new GMarker(new GLatLng(19.800949,-70.689957))),"Dominican Republic"];
markers[2] = ["<strong>Hotel Molokai</strong><br/>1020 Kamehameha V Highway, Kaunakakai, HI 96748 <br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/hotelmolokai.aspx\">View Property</a>", "Hotel Molokai", (new GMarker(new GLatLng(21.0550366,-156.8669158))),"Hawaii"];
markers[3] = ["<strong>Maui Banyan</strong><br/>2575 South Kihei Road, Kihei, Hawaii, United States, 96753 <br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/mauibanyan.aspx\">View Property</a>", "Maui Banyan", (new GMarker(new GLatLng(20.715647,-156.443976))),""];
markers[4] = ["<strong>Allegro Cozumel</strong><br/>Km. 16.5 Carretera Sur, San Francisco Palancar, Cozumel, Mexico <br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/allegrocozumel.aspx\">View Property</a>", "Allegro Cozumel", (new GMarker(new GLatLng(20.510071,-86.948914)))," Mexico"];
markers[5] = ["<strong>Allegro Playacar</strong><br/>Lote Hotelero No. 7 Desarrollo Playacar, Playa Del Carmen, Mexico <br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/allegroplayacar.aspx\">View Property</a>", "Allegro Playacar", (new GMarker(new GLatLng(20.6133752,-87.0898943))),""];
markers[6] = ["<strong>El Cid El Moro Beach</strong><br/>Av. Camaron Sabalo S/N B, Mazatlan 82110, Mexico<br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/elcidelmorobeach.aspx\">View Property</a>", "El Cid El Moro Beach", (new GMarker(new GLatLng(23.2525473,-106.4556439))),""];
markers[7] = ["<strong>Hotel Marina El Cid Spa and Beach Resort</strong><br/>Boulevard El Cid Unidad 15, Puerto Morelos, Quintana Roo, Mexico<br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/hotelmarinaelcidspaandbeachresort.aspx \">View Property</a>", "Hotel Marina El Cid Spa and Beach Resort", (new GMarker(new GLatLng(20.8398489,-86.8877871))),""];
markers[8] = ["<strong>Monkey Rock</strong><br/>River Path, Ginger Lands, Nevis <br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/monkeyrock.aspx\">View Property</a>", "Monkey Rock", (new GMarker(new GLatLng(17.147351748174774,-62.582244873046875))),"Nevis"];
markers[9] = ["<strong>Village Inn & Spa</strong><br/>Reduit Beach, Rodney Bay Village, Castries, St. Lucia, West Indies<br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/villageinn.aspx\">View Property</a>", "Village Inn & Spa", (new GMarker(new GLatLng(13.9994107,-60.9972847)))," St. Lucia"];

markers[10] = ["<strong>SeaPalace</strong><br/>147 Front St., Philipsburg, St. Maarten<br/><a href=\"/Properties/PropertiesbyRegion/HawaiiMXCaribbean/SeaPalace.aspx\">View Property</a>", "SeaPalace", (new GMarker(new GLatLng(18.0242566,-63.0475277))),"Virgin Islands"];

markers[11] = ["<strong>Luna Maya</strong><br/>Highway 307 Cancun-Tulum, Tulum, Quintana Roo, Mexico<br/><a href=\"/Properties/PropertiesbyRegion/NortheastUS/204east24thavenue.aspx\">View Property</a>", "Luna Maya", (new GMarker(new GLatLng(20.6312992,-87.0731251))),""];



				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 8
				//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 (not in use anymore)
					{
						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_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
		
		
