// JavaScript Document

function loadStaffBio(id){
	$('#staff_bio').load('/includes/staff/ajax.php', {'id':id}, function(){
		sIFR.replace(gothamLight, {
			selector : '#staff_bio h1',
			css : {'.sIFR-root' : {'color':'#333333','font-size':'28px','text-transform':'uppercase'}},
			wmode : 'transparent',
			fitExactly : true
		});
	});
}

/*-------------------------------------------------------------*/
/*	Non-flash sliding functionality
/*-------------------------------------------------------------*/

var ITEM_WIDTH = 0;
var CURRENT_POS = 0;
var MAX_POS = 0;

$(document).ready(function(){
	//if(!hasFlash) initSlider();
	initSlider();
});

function initSlider(){
	var totalItems = $("#staff_gallery_container .staff_member").length;
	ITEM_WIDTH = $("#staff_gallery_container .staff_member:first").outerWidth() + 20;
	var containerWidth = ITEM_WIDTH * totalItems;
	$("#staff_gallery_container").css("width", containerWidth);
	if(totalItems > 3){
		MAX_POS = totalItems - 3;
		$("#btn_next").click(function(){ doSlide("next"); });
	}else{
		$("#btn_prev").hide();	
		$("#btn_next").hide();
	}
	
	if(isIE(7)){
		$("#staff_gallery_container .staff_member").each(function(i,elem){
			$(this).hover(
				function(){
					$(this).attr('class', 'staff_member staff_member_hover');
				},
				function(){
					$(this).attr('class', 'staff_member');
				}
			);
		});
	}
}

function doSlide(direction){
	if(direction == "prev"){
		CURRENT_POS--;
		$("#staff_gallery_container").animate({"left": "+="+ITEM_WIDTH});
		$("#btn_next").unbind("click");
		$("#btn_next").click(function(){ doSlide("next"); });	
		$("#btn_next").attr("class", "");
		if(CURRENT_POS == 0){
			$("#btn_prev").unbind("click");	
			$("#btn_prev").attr("class", "disabled");
		}
	}else{
		CURRENT_POS++;
		$("#staff_gallery_container").animate({"left": "-="+ITEM_WIDTH});
		$("#btn_prev").unbind("click");
		$("#btn_prev").click(function(){ doSlide("prev"); });	
		$("#btn_prev").attr("class", "");
		if(CURRENT_POS == MAX_POS){
			$("#btn_next").unbind("click");
			$("#btn_next").attr("class", "disabled");
		}
	}
}

