//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
//---------------------------------------------------------------------------------------------------------
//	Slideshow
//---------------------------------------------------------------------------------------------------------
var slideshows = [];

// This slideshow code requires the jQuery library. I was already using it for the thickbox, so I used some
// of the functions here.
function slideshow( container_div_name, div_array, rot_speed, height )
{
	this.container_div = $('#' + container_div_name);
	this.div_array = div_array;
	this.rot_speed = rot_speed * 1000;
	this.current_index = 0;
	this.slide_total = div_array.length;

	this.container_div.height(height + 'px');

	// Global register
	slideshows.push(this);
}

slideshow.prototype.rotateSlide  = function() {

	current_div_id = this.div_array[this.current_index];

	// Incr and start over if necessary
	this.current_index++;
	if(this.current_index == this.slide_total)
	{
		this.current_index = 0;
	}

	new_div_id 		= this.div_array[this.current_index];

	$('#' + current_div_id).hide();
	$('#' + new_div_id).show();
};

slideshow.prototype.startSlideshow = function() {

	if(this.slide_total == 0) return;

	// Retroactively set height of slideshow since we are using positioning

	var myself = this;
	function rotatefunc(){
		myself.rotateSlide();
	};

	setInterval(rotatefunc, this.rot_speed);
};
