﻿$(document).ready(function(){

// Startup

	$("div.content").hide();
	var url = window.location.href;
	var startpage = "";
	if (url.lastIndexOf('.html') == -1) {
		startpage = "index";
	} else {
		startpage = url.substring(url.lastIndexOf('/')+1, url.lastIndexOf('.'));
   	};
   	$("a.nav_button[href='#"+startpage+"']").addClass("active");
   	window.location.hash = '#'+startpage;
   	
// Navigation

    var current_hash = "",
		pagename = "";
    setInterval(function() { 
        if(window.location.hash != current_hash) { 
            current_hash = window.location.hash;
            pagename = current_hash.substr(1);
			$("#content_placeholder").fadeOut(200, function(){
				$(this).load(pagename+".html .content", function(){
					contentBehaviours();
					$(this).fadeIn(200);
				});
			});
		$("a.nav_button").removeClass("active");
   		$("a.nav_button[href='#"+pagename+"']").addClass("active");
        };         
    }, 100);     

// Content

	var contentBehaviours = function() {

		$(".button_link").width(0);
		$("#next_concert, #members_box, .menubox").hover(function(){
			$(this).find("a.button_link").show().animate({"width": "40px"}, 400);
		}, function(){
			$(this).find("a.button_link").fadeOut(400, function(){$(this).width(0)});
		});
		$("#members_box, .menubox").hover(function(){
			$(this).find("a").addClass("highlighted");
		}, function(){
			$(this).find("a").removeClass("highlighted");
		});

	   	$("div.archive_content").hide();
	   	var firstpage = $("#archive_nav li:first a").attr("href");
	   	$(firstpage).show();
	   	$("#archive_nav li:first").addClass("active");

		$("li.archive_link").click(function(){
			$("#archive_nav li").removeClass("active");
			$(this).addClass("active");
			var pagename = $(this).find("a").attr("href");
			$("div.archive_content").hide();
			$(pagename).fadeIn(200);
			return false;
		});
	};
	
	contentBehaviours();
});


