
jQuery(function() {
	
	/*
	// content header slideshow
	jQuery(".content-header").gstSlideshow({
		zIndexForTopSlide: 700
	});
	*/
	
	jQuery(".strip-inner>ul").gstSlideshow({
		zIndexForTopSlide: 700,
		viewDuration: 6000
	});
	
	jQuery("#quote-fader").gstSlideshow({
		zIndexForTopSlide: 700,
		viewDuration: 4000
	});
	
	jQuery("#content .locations-map").each(function() {
		var theMap = this;
		
		if (GBrowserIsCompatible()) {
			
			// Gather the locations we'll be displaying
			var locations = jQuery("#content .location");
			if (locations.length <= 0) {
				//alert("No locations found");
			} else {
				jQuery(theMap).css("display", "block");
				
				// Create the map (don't forget to setCenter and add controls)
				var map = new GMap2(theMap);
				
				var zoom_level = 7;
				
				// Initialize the map, centered on Knoxville, TN
				map.setCenter(new GLatLng(35.868673,-84.207716), zoom_level);
				
				// Add a zoom/pan control
				map.addControl(new GLargeMapControl());
				
				//alert("Found " + locations.length + " locations.");
				
				var bounds = new GLatLngBounds();
				
				// Add each location
				locations.each(function() {
					var theLocation = this;
					
					// The location's title
					var locationTitle = jQuery(theLocation).find(".title").text();
					
					// The location's address
					var address = jQuery(theLocation).find(".address").text();
					
					//alert("Location: " + locationTitle + " @ " + address);
					
					if (address) {
						// Start a geocode request for the address
						var geocoder = new GClientGeocoder();
						geocoder.getLocations(address, function(response) {
							// Retrieve the object
							var place = response.Placemark[0];
							
							// Retrieve the latitude and longitude
							var point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
							
							// Center the map on this point
							//this.setCenter(point, zoom_level);
							
							// Create a marker
							var marker = new GMarker(point);
							
							var marker_html = "<h2 style='background-image: none'>" + locationTitle + "</h2><p>" + address + "</p>";
							
							// Give it click behavior
							GEvent.addListener(marker, "click", function() {
								this.openInfoWindowHtml(marker_html);
							});
							
							// Add the marker to map
							map.addOverlay(marker);
							
							// Start with the info window open
							//marker.openInfoWindowHtml(marker_html);
							
							// Smart zoom & center
							bounds.extend(point);
							map.setCenter(bounds.getCenter(), Math.min(12, map.getBoundsZoomLevel(bounds)));
							
						});
					}
				});
			}
		} else {
			//alert("GBrowserIsCompatible failed");
		}
	});
});

