// JavaScript Document

image=null;
previousButton=null;
nextButton=null;

content=new Array("alberti_t","alberti_l","flores_a","lenches_j","pari_c");

currentImage=0;
totalImages=(content.length-1)

infoContainer=null;

	//METHOD:	ON PAGE LOAD
$(function(){

	img=new Image();

	initObjectFunctionality();

	loadImage(content[currentImage]);
});

	//METHOD:	INIT CONTAINER OBJECTS
function initObjectFunctionality(){

		//image container to manipulate
	image=$("#image");

		//setup previous button click functionality
	previousButton=$(".previous").click(function(){
			//hide container info before load
	 	$(infoContainer).hide();
		loadPrevious();
	});
	
		//setup next button click functionality
	nextButton=$(".next").click(function(){
			//hide container info before load
	 	$(infoContainer).hide();
		loadNext();
	});

		//container to place changing content
	infoContainer=$("#info-container");
}

	//METHOD:	LOAD IMAGE AND CORRESPONDING CONTENT
function loadImage(contentToLoad){
	
	$(img).hide();		//hide this item as it attempts to load
	$(image).addClass("loading");
	$("#info-container").hide();
		
		//load image as a function
	$(img).load(function(){
		$(image).removeClass("loading").append(img);	//remove the loading class
		$(this).fadeIn("slow");		//fade image in slowly			
	}).attr('src',"./images/staffImages/"+contentToLoad+".jpg");	//upon load add <IMG SRC="...'
	
	loadInformation(contentToLoad);
}

	//METHOD:	LOAD CONTENT INFORMATION
function loadInformation(contentToLoad){
		//load content via slidedown
	$(infoContainer).load("includes/staffInfo/"+contentToLoad+".html").fadeIn("fast");		
}


	//METHOD:	LOAD NEXT CONTENT
function loadNext(){
		//increate current image position
	currentImage=(currentImage<totalImages)?currentImage+1:0;	
	
		//load new image index	
	loadImage(content[currentImage]);
}

	//METHOD:	LOAD PREVIOUS CONTENT
function loadPrevious(){
		//decrease current image position
	currentImage=(currentImage>0)?currentImage-1:totalImages;

		//load new image index
	loadImage(content[currentImage]);
}