$(document).ready(function(){

		// accordian
		$("#nav li ul").hide();
		$("#nav .head").click(function(){
			$("#nav li ul:visible").slideUp("slow");
			$(this).next().slideDown("slow");
			return false;
		});

		// open current section
		if (section && $("#nav_" + section)) {
			$("#nav_" + section).next().show();
		}

	// add subnav listner
	$("#subnav a, #people ul li ul li a").click(function() {
		var theDiv = $(this).attr("href").substring(1);
		showSubpage(theDiv);
	});

	
		// people accordian
		$("#people li ul").hide();
		$("#people .head").click(function(){
			$("#people li ul:visible").slideUp("slow");
			$(this).next().slideDown("slow");
			return false;
		});

		// open current people accordian
		var showPerson;
		if (people_category && $("#people_category_" + people_category)) {
			$("#people_category_" + people_category).next().show();
			$(".subpage").hide();
			showPerson =  $("#people_category_" + people_category).next().children(":first-child").children(":first-child").attr("href").substring(1);
		}
		
		
	// hide all subpages
	$(".subpage").hide();

	if (showPerson) {	
		// show the first person in the people selected if parameter is passed
		showSubpage(showPerson);
	} else {
		// show the first or appropriate subpage
		initSubpage();
	}

	// photo swap
	$("#picThumbs a").click(function() {
		$("#picThumbs a img").css("border", "2px solid #000");
		$(this).children(":first-child").css("border", "2px solid #fff");
		var id = $(this).children(":first-child").attr("src").match(/\d+/);
		$("#bigPics div:visible").hide();
		$("#bigPics #pic" + id).fadeIn("slow");
	});	
	
		
});


//window.onload = function() {
//	$('#content').jScrollPane({scrollbarWidth:5, scrollbarMargin:1});
//};

function getQueryVariable(variable) {
	var query = window.location.search.substr(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 
}


function showSubpage(theDiv) {
	$("#subpages .subpage:visible").hide();
	$("#subpage_" + theDiv).fadeIn("slow");
}
										
function initSubpage() {

	var hashClean = location.hash.substr(1);
	var query = getQueryVariable("subbpage");

	if (hashClean && $("#" + hashClean)) {
		showSubpage(hashClean);
	} else if (query && $("#" + query)) {
		showSubpage(query);		
	} else {
		$("#subpages").children(":first-child").show();
	}
	
}

