// remap jQuery to $
(function($){})(window.jQuery);


/* trigger when page is ready */
$(document).ready(function (){
	
	if ($(".staff-featured").length > 0){
		classify_staff();
	}

});

var num_of_staff;
	
function classify_staff() {

	$(".staff-featured").each(function(index) {
		$(this).addClass("staff_" + (index+1));
		num_of_staff = index+1;
	});

	advance_staff_slideshow(1);

}

slide_rate_staff = 6500;
fade_rate_staff = 1000;

function advance_staff_slideshow(current_staff_num) {

	if( current_staff_num == 1 ) {
		$(".staff_1").fadeIn(fade_rate_staff);
		$(".staff_" + num_of_staff).fadeOut(fade_rate_staff);
	}
	else {
		$(".staff_" + current_staff_num).fadeIn(fade_rate_staff);
		$(".staff_" + (current_staff_num-1) ).fadeOut(fade_rate_staff);
	}
	
	if ( current_staff_num != num_of_staff ) current_staff_num++; else current_staff_num = 1; // Increment image counter
	setTimeout("advance_staff_slideshow('" + current_staff_num + "')", slide_rate_staff);
	
}

function rotate_staff() {

	alert('start');
	
	num_of_items = 0;
	timer = 2000;

	$(".staff-featured").each(function(index) { 

		$(this).delay(((timer) * index)).fadeIn();
		$(this).delay(timer).fadeOut();
		//$(this).delay(((timer+600) * index)).fadeIn('slow');
		//$(this).delay( timer ).fadeOut('slow');

		//alert( (timer * index) + " - " + timer );
		
		num_of_items = index;
	
	});

	$('.firstObj').delay(timer * (num_of_items + 1 )).fadeIn();
	rotate_staff();
	
}

function load_work(page) {

	$('.work-page').hide();
	$('.work-page-' + page).show();
	
	$('.other-work a').removeClass('selected');
	$('#other-work-' + page).addClass('selected');

}

/* optional triggers

$(window).load(function() {
	
});

$(window).resize(function() {
	
});

*/
