$(document).ready(function() {

	///// Functions
/*
	function setNavLinks() {
		$("ul.nav_1 > li > a").each(function(i) {
			$(this).attr("href", "#/" + $(this).attr("name") + "/");
		});
	
		$("ul.nav_2 > li > a").each(function(i) {
			$(this).attr("href", "#/" + $(this).attr("name").split("|")[0] + "/" + $(this).attr("name").split("|")[1].replace("_", " ") + "/");
		});
		
		$("li.nav_1 a").click(function() {
			$(".selected").removeClass("selected");
			$(this).parent().addClass("selected");
			$(this).parent().parent().addClass("selected");
			setNavSelectionIndicator();
		});
	}

	function setNavSelectionIndicator() {
		$("a:contains('>')").each(function() {
			$(this).html($(this).html().substr(0, $(this).html().length - 5));
		});
		if ( $("ul.nav_1.selected li.selected ul").hasClass("nav_2") ) {
			$("ul.nav_1.selected li.selected ul.nav_2.selected li.selected a").append(' &gt;');
		}
		else {
			$("ul.nav_1.selected > li.selected a").append(' &gt;');
		}
	}
	
	function handleHash(hash) {
		var section = hash.replace('/', '');
		$("[name='" + section + "']").parent().addClass("selected").parent().addClass("selected");
		setNavSelectionIndicator();
		
//		getContent(section);
	}
*/	
	function clearNoScriptElements() {
		$("div#image").empty();	
		$("span.title, span.info").remove();
	}
	
	function setArrows() {
		$("a.prev").attr("href", "");
		$("a.next").attr("href", "");
	}

	///// END Functions
	
	clearNoScriptElements();
	setArrows();

	$('ul.gallery').galleria({ insert: '#image', history: true, clickNext: true, onImage: function(image,caption,thumb) {image.css('display','none').fadeIn();} });

	if ( window.location.hash == '' ) {
		$("ul.gallery li:first").addClass('active');
		//alert($("#image_viewer img.replaced").attr("src"));
		//$.galleria.activate($("#image_viewer img.replaced").attr("src"));
	}

});
