function photoFade(el) {
	var $active = $(el + ' a.active');			
	if ( $active.length == 0 ) $active = $(el + ' a:last');
	var $next =  $active.next().length ? $active.next() : $(el + ' a:first');						
	$active.addClass('last-active');
	var ah = $next.height();
	var ph = $next.parent().height();
	var mh = (ph - ah) / 2;
	$active.animate({opacity: 0.0}, 1000, function() {
		$active.removeClass('active last-active');
		$active.css({display: 'none'});
		$next.css({opacity: 0.0, display: '', 'margin-top': mh})
		.addClass('active')
		.animate({opacity: 1.0}, 1000);
	});
}

function listingTabs() {
	setTimeout ('$("#listing_gallery, #listing_video, #listing_location").hide();', 2000);
	$('#listing_nav a').click(function(){
		$('#listing_about, #listing_gallery, #listing_video, #listing_location').hide();
		$('#listing_nav li').removeClass('selected');
		$(this).parent().addClass('selected');
		$('#' + $(this).attr('class')).show();
		return false;
	});
}

function upgradeTabs() {
	$("#basic_listing_6, #basic_listing_12, #featured_listing, #latest_statistics").hide();
	$('#listing_nav a').click(function(){
		$('#basic_listing, #basic_listing_6, #basic_listing_12, #featured_listing, #latest_statistics').hide();
		$('#listing_nav li').removeClass('selected');
		$(this).parent().addClass('selected');
		$('#' + $(this).attr('class')).show();
		return false;
	});
}
	
function load(title, address, type) {
	if (GBrowserIsCompatible()) {
		var map;
		var geocoder;
		map_id = document.getElementById("map");
		map = new GMap2(map_id);
		map.addControl(new GSmallMapControl());
		map.setCenter(new GLatLng(24, 0), 17);
		map.enableDoubleClickZoom();
		if (type == 'sat') {
			map.setMapType(G_SATELLITE_MAP);
			map.addControl(new GHierarchicalMapTypeControl());
		} else {
			map.setMapType(G_NORMAL_MAP);
		}
		geocoder = new GClientGeocoder();
		geocoder.getLocations(address, function (response) {
			map.clearOverlays();
			if (!response || response.Status.code != 200) {
				//map_id.innerHTML('Could not find address on Google Maps');
			} else {
				place = response.Placemark[0];
				point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
				
				map.setCenter(point, 17);
				
				// Create our "tiny" marker icon
			    var icon = new GIcon();
			    icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
			    icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
			    icon.iconSize = new GSize(12, 20);
			    icon.shadowSize = new GSize(22, 20);
			    icon.iconAnchor = new GPoint(6, 20);
			    icon.infoWindowAnchor = new GPoint(5, 1);
			
			    // Creates one of our tiny markers at the given point
			    function createMarker(point, index) {
			      var marker = new GMarker(point, icon);
			      var myMarkerContent = "<div style=\"width:200px; overflow:auto;\"><strong>" + title + "</strong><br />" + address + "</div>";
			      map.addOverlay(marker);
			      marker.openInfoWindowHtml(myMarkerContent);
			      GEvent.addListener(marker,"click",function() {
			         marker.openInfoWindowHtml(myMarkerContent);
			       });
			    }
			    createMarker(point);
			}
		});
	}
}

function loadLatLon(title, address, lat, lon, type) {
	if (GBrowserIsCompatible()) {
		var map;
		var geocoder;
		map_id = document.getElementById("map");
		map = new GMap2(map_id);
		map.addControl(new GSmallMapControl());
		map.setCenter(new GLatLng(24, 0), 17);
		map.enableDoubleClickZoom();
		if (type == 'sat') {
			map.setMapType(G_SATELLITE_MAP);
			map.addControl(new GHierarchicalMapTypeControl());
		} else {
			map.setMapType(G_NORMAL_MAP);
		}
		
		var point = new GLatLng(lat, lon);
		
		map.setCenter(point, 17);
		
		// Create our "tiny" marker icon
		var icon = new GIcon();
		icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(12, 20);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);
	
		// Creates one of our tiny markers at the given point
		function createMarker(point, index) {
		  var marker = new GMarker(point, icon);
		  var myMarkerContent = "<div style=\"width:200px; overflow:auto;\"><strong>" + title + "</strong><br />" + address + "</div>";
		  map.addOverlay(marker);
		  marker.openInfoWindowHtml(myMarkerContent);
		  GEvent.addListener(marker,"click",function() {
			 marker.openInfoWindowHtml(myMarkerContent);
		   });
		}
		createMarker(point);

	}
}
