

function pageload(hash) {
		// hash doesn't contain the first # character.
		
	}

function makeBookmarkableUrl(rel, href) {
	
	var albumName = rel.substring(rel.indexOf("[")+1, rel.indexOf("]"));
	var imgName = href.substring(href.lastIndexOf("/") + 1);
	
	var hash = albumName + "|||" + imgName;
	
	hash = hash.replace(/^.*#/, '');
	$.historyLoad(hash);
	return false;
}

	
$(document).ready(function(){
	
	
	// set onlick event for buttons
	$("a").click(function(){
		makeBookmarkableUrl(this.rel, this.href);
	});

	
	
	$("a[rel^='prettyOverlay'],a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 37, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: false, /* true/false */
		allowresize: false, /* true/false */
		counter_separator_label: '/'
	});

	
	var t = setTimeout('$("#titleandmenu").fadeTo("slow", 0.4);',4000);
	
	$("#title").click( function() {
		$("#startPhoto").click();
	});
	
	
	$("#titleandmenu").hover(
		function() { clearTimeout(t); $(this).fadeTo("slow", 1.0); },
		function() { $(this).fadeTo("slow", 0.4);}
	);
	
	$(".menuLink").click( function() {
		//$(".submenu").hide();
		$("~ .submenu", this).slideToggle("slow");
	});
	
	
	$("#titleandmenu a").click( function() {
		
		$("#menu a").css("color", "#FF34B3");
		$(this).css("color", "white");
		
	});
	

	$("a[rel^='prettyOverlay'],a[rel^='prettyPhoto']").click( function() {
		//$("#prettyPhotoOverlay").click();
    });
	

	/*  This only works with latest jQuery. Latest jQuery does not support prettyPhoto very well. This code is for fading in and out the slideshow numbers on hover
	$(".pictureHolder").live("mouseenter", function(event){
		$(".nav").fadeTo("slow", 0.8);
	});

	$(".pictureHolder").live("mouseleave", function(event){
		$(".nav").fadeTo("slow", 0.3);
	});
	*/
	

	
	
	
	
	
	$.historyInit(pageload);
	
	if(location.href.indexOf("#") > 0) {
		// restore ajax loaded state
		//$("#load").load(hash + ".html");
		//alert("restore");
		var hash = location.href.split("#")[1];
		
		var albumNameAndImgName = hash.split("|||");
		var albumName = albumNameAndImgName[0];
		var imgName = albumNameAndImgName[1];
		
		$("[rel^='prettyPhoto[" + albumName + "]']").css("color", "white");
		$("[rel^='prettyPhoto[" + albumName + "]'][href=images/slideshow/" + imgName + "]").click();
		
		if($("[rel^='prettyPhoto[" + albumName + "]'][href=images/slideshow/" + imgName + "]").length == 0) {
			$("#startPhoto").click();
		}
		
			
	} else {
		// start page
		//alert("start");
		$("#startPhoto").click();
	}
	
	
	/*if($.url.param("img")) {
		
		//var album = $.url.param("album");
		//var img = $.url.param("img");
		
		//$("[rel^='prettyPhoto[events]'][href=images/slideshow/Control.jpg]").click();
		
		$("[rel^='prettyPhoto[" + album + "]'][href=images/slideshow/" + img + "]").click();
		
		//$("a[rel^='prettyPhoto[people]']").click();
		//$("[rel='prettyPhoto[people]'] [href=images/slideshow/ChildrenOfMen.jpg]").click();
		//$("[rel^='prettyPhoto[events]' href=images/slideshow/Control.jpg]").click();
		//$("[rel^='prettyPhoto[events]'").find("~ [href=images/slideshow/Control.jpg]").click();
		//$("#bookmarkPhoto").click();	 
		//prettyPhoto[people]
		
	} else {
		$("#startPhoto").click();	
	}*/
	
});
