var currentPerson = null;
var currentScroll = null;
function scroll(e, ui){
	if( scrollContent.width() > scrollPane.width() ){ 
		scrollContent.css('margin-left', Math.round( ui.value / 100 * ( scrollPane.width() - scrollContent.width() )) + 'px'); 
	}
	else { 
		scrollContent.css('margin-left', 0); 
	}
}

function loadTroupePage(){
	
}

function showSingersTab(){
	$('.troupeDetail').hide();
	$('#defaultDetail').show();
	$('#singersScroll div.scrollPane').jScrollPaneRemove();
	$('#singersScroll').show();
	$('#singersPic').show();
	$('#singersScroll div.scrollPane').jScrollPane();
	hideBandTab();
	hideTechTab();
	hideNonTab();
	hideProfTab();
	$('.s').show();
}

function hideSingersTab(){
	$('#singersScroll').hide();
	$('#singersPic').hide();
	$('.s').hide();
}

function showBandTab(){
	$('.troupeDetail').hide();
	$('#defaultDetail').show();
	$('#bandScroll div.scrollPane').jScrollPaneRemove();
	$('#bandScroll').show();
	$('#bandPic').show();	
	$('#bandScroll div.scrollPane').jScrollPane();
	currentScroll = $('#bandScroll div.scrollPane');
	hideSingersTab();
	hideTechTab();
	hideNonTab();
	hideProfTab();
	$('.b').show();
}

function hideBandTab(){
	$('#bandScroll').hide();
	$('#bandPic').hide();
	$('.b').hide();
}

function showTechTab(){
	$('.troupeDetail').hide();
	$('#defaultDetail').show();
	$('#techScroll div.scrollPane').jScrollPaneRemove();
	$('#techScroll').show();
	$('#techPic').show();
	$('#techScroll div.scrollPane').jScrollPane();
	currentScroll = $('#techScroll div.scrollPane');
	hideSingersTab();
	hideBandTab();	
	hideNonTab();
	hideProfTab();
	$('.t').show();
}

function hideTechTab(){
	$('#techScroll').hide();
	$('#techPic').hide();
	$('.t').hide();
}

function showNonTab(){
	$('.troupeDetail').hide();
	$('#defaultDetail').show();
	$('#studentScroll div.scrollPane').jScrollPaneRemove();
	$('#studentScroll').show();
	$('#studentPic').show();
	$('#studentScroll div.scrollPane').jScrollPane();
	currentScroll = $('#studentScroll div.scrollPane');
	hideSingersTab();
	hideBandTab();
	hideTechTab();	
	hideProfTab();
	$('.n').show();
}

function hideNonTab(){
	$('#studentScroll').hide();
	$('#studentPic').hide();
	$('.n').hide();
}

function showProfTab(){
	$('.troupeDetail').hide();
	$('#defaultDetail').show();
	$('#profScroll div.scrollPane').jScrollPaneRemove();
	$('#profScroll').show();
	$('#profPic').show();
	$('#profScroll div.scrollPane').jScrollPane();
	currentScroll = $('#profScroll div.scrollPane');
	hideSingersTab();
	hideBandTab();
	hideTechTab();
	hideNonTab();	
	$('.p').hide();
}

function hideProfTab(){
	$('#profScroll').hide();
	$('#profPic').hide();
	$('.p').hide();
}

function goToPerson(person){
	$(currentScroll)[0].scrollTo('#'+person+'Scroll');
	$('#'+person+'Scroll').effect("highlight", {color: '#C1272D'}, 500);
	showPerson(person);
}

function showPerson(person){
	if(currentPerson != null){
		currentPerson.hide();
	}
	else{
		$('#defaultDetail').hide();
	}
	currentPerson = $('#'+person+'Container');
	currentPerson.show();
}

function openAlumni(elem){
	$('.alumniyear').hide();
	var id = $(elem).attr('id');
	var str = id.replace('link', '');
	$('#' + str).show();
}

function focusOnId(elem){
	var year = $(elem).parents('div.alumniyear').attr('id');
	$('#id_year').val(year);
	$('#id_details').focus();
}

function focusOnPhoto(elem){
	var year = $(elem).parents('div.alumniyear').attr('id');
	$('#photo_year').val(year);
	$('#photo_pic').focus();
}

function focusOnLost(elem){
	var name = $(elem.target).text();
	$('#alumni_name').val(name);
	$('#alumni_email').focus();
}
