$(document).ready(function() {
	//isIE = (navigator.appName == "Microsoft Internet Explorer");
	//isOpera = (navigator.appName == "Opera");
	
	var rotater = new Rotater(slides, slideTime, transitionTime, rotaterDiv, true);
	
});

function Rotater(p_slides, p_slideTime, p_transitionTime, p_div, p_random){
	
	this.slides = p_slides;
	this.slideTime = p_slideTime;
	this.transitionTime = p_transitionTime;
	this.holder = p_div;
	this.timer = null;
	this.currentIndex = 0;
	this.imgID = "slideImg";
	this.randomize = p_random;
	
	this.init = function(){
		if(this.randomize){ this.slides = randomizeArray(this.slides); }
		this.showCurrentSlide();
		this.start();
		$("#"+this.holder).append("<img id='"+this.imgID+"' src='"+this.slides[this.currentIndex]+"'></img>");
	}
	
	this.start = function(){
		thisObj = this;
		this.timer = setInterval(function() { thisObj.slideAction(); }, this.slideTime);
	}
	
	this.stopShow = function(){
		clearInterval(this.timer);
	}
	
	this.slideAction = function(){
		this.currentIndex++;
		if(this.currentIndex >= this.slides.length){ this.currentIndex = 0; }
		this.hideCurrentSlide();
	}
	
	this.showCurrentSlide = function(){
		$("#"+this.imgID).replaceWith("<img id='"+this.imgID+"' src='"+this.slides[this.currentIndex]+"'></img>");
		$("#"+this.imgID).hide();
		$("#"+this.imgID).fadeIn(this.transitionTime);
	}
	
	this.hideCurrentSlide = function(){
		var thisObj = this;
		$("#"+this.imgID).fadeOut(this.transitionTime, function(){ thisObj.showCurrentSlide(); });
	}
	
	this.init();
}
