$(document).ready(	function(){
	$('#scrollcontent').jScrollPane({showArrows:true, scrollbarWidth:15});
	teamInit();
	deptInit();
});

function teamInit(){
	teamDivs = $('div.team');
	if(teamDivs.length == 0) return;
	
	teamLinks = $('#teamNav a');
	
	teamDivs.each(function(i){
  		if(i!=0) teamDivs.eq(i).hide();
	});
	
	teamLinks.each(function(i){
  		teamLinks.eq(i).click(function(event){
			teamDivs.each(function(j){
		  		teamDivs.eq(j).hide();
			});
			teamDivs.eq(i).show();
			teamLinks.each(function(k){
		  		teamLinks.eq(k).removeClass('thisPerson');
			});
			teamLinks.eq(i).addClass('thisPerson');
			event.preventDefault();
		});
	});
	
	lastParas = $('div.team p:last-child');
	lastParas.append(" <a class='next'></a>");
	
	lastLinks = $('div.team p a.next');
	lastLinks.each(function(i){
  		lastLinks.eq(i).click(function(event){
			j = i+1;
			if (j==lastLinks.length) j = 0;
		  	teamDivs.eq(i).hide();
			teamDivs.eq(j).show();
		  	teamLinks.eq(i).removeClass('thisPerson');
			teamLinks.eq(j).addClass('thisPerson');
			event.preventDefault();
		});
	});

	
}

function deptInit(){
	deptDivs = $('div.dept');
	if(deptDivs.length == 0) return;
	
	deptLinks = $('#departmentsNav a');
	
	deptDivs.each(function(i){
  		if(i!=0) deptDivs.eq(i).hide();
	});
	
	deptLinks.each(function(i){
  		deptLinks.eq(i).click(function(event){
			deptDivs.each(function(j){
		  		deptDivs.eq(j).hide();
			});
			deptDivs.eq(i).show();
			deptLinks.each(function(k){
		  		deptLinks.eq(k).removeClass('thisDept');
			});
			deptLinks.eq(i).addClass('thisDept');
			event.preventDefault();
		});
	});
	
	lastParas = $('div.dept p:last-child');
	lastParas.append(" <a class='next'></a>");

	lastLinks = $('div.dept p a.next');
	lastLinks.each(function(i){
  		lastLinks.eq(i).click(function(event){
			j = i+1;
			if (j==lastLinks.length) j = 0;
		  	deptDivs.eq(i).hide();
			deptDivs.eq(j).show();
		  	deptLinks.eq(i).removeClass('thisDept');
			deptLinks.eq(j).addClass('thisDept');
			event.preventDefault();
		});
	});
	
}