/*
RSG Sidebar Faded Slide Show
Created By: Mitch Gohman
Date: 2010-02-27
With much love to JQuery - the javaScript browser equalizer
*/
//preferences


function oFadedSlides(whichSideElement) {
	this.sLiID = whichSideElement;
	this.nCurrSlide = 0;
	this.nTotImages = 0;
	this.nFadeSpeed = 1000;
	this.nSlidePersistance = 6000; //how long an image persists
	this.nKickStartDelay = 0; //how long an image persists
	this.showDesc = true;
	this.aSlides =  $("#" + this.sLiID + " li");
	this.aSlideLnks =  $("#" + this.sLiID + " li a");
	this.aSlideImgs =  $("#" + this.sLiID + " li img");
}

oFadedSlides.prototype.stackSlides = function() {
	var thisObj = this;//To keep a reference to the object - we assign it to a local var = scope
	$("#" + this.sLiID).css("position","relative");
	$("#" + this.sLiID).css("height","305px");
	$("#" + this.sLiID + " li").css("display","block");
	$("#" + this.sLiID + " li").css("position","absolute");
	$("#" + this.sLiID + " li").css("left","0px");
	$("#" + this.sLiID + " li").css("top","0px");
	$("#" + this.sLiID + " li").css("opacity",1);
	$("#" + this.sLiID + " li").css("height","305px");
	$("#" + this.sLiID + " a").css("color","#ffffff");
	$("#" + this.sLiID + " a").css("text-decoration","none");
	$("#" + this.sLiID + " img").css("border","none 0px");
}

oFadedSlides.prototype.kickStart = function() {
	var thisObj = this;//To keep a reference to the object - we assign it to a local var = scope
	this.stackSlides(); //set em up
	
	this.nTotImages = this.aSlides.length;
	
	var zIndexRev = this.nTotImages;
	for (i=0; i < this.nTotImages; i++)
		{
		var oThisSlide = this.aSlides[i];
		$(this.aSlides[i]).css("z-index",zIndexRev + "0");
		zIndexRev--;
		}
	setTimeout(function() { thisObj.fadeSlides(); },this.nKickStartDelay);
}


oFadedSlides.prototype.fadeSlides = function() {
	var thisObj = this;//To keep a reference to the object - we assign it to a local var = scope
	var thisSlide = $(this.aSlides[this.nCurrSlide]);
	if (this.nCurrSlide == (this.nTotImages - 1))
		{
		this.nCurrSlide = 0;
		$(thisSlide).css("display","block");
		$(thisSlide).fadeTo(this.nFadeSpeed,1);
		setTimeout(function() { thisObj.stackSlides(thisObj.sLiID); },thisObj.nFadeSpeed);//reset them
		}
		else
		{
		$(thisSlide).fadeTo(this.nFadeSpeed,0,function() { $(thisSlide).css("display","none") });
		this.nCurrSlide++;
		}
	
	setTimeout(function() { thisObj.fadeSlides(); },thisObj.nSlidePersistance);
}

function setUpSlides() {
	oSlide1 = new oFadedSlides('slideshow1');
	oSlide1.nKickStartDelay = 1000;
	oSlide1.kickStart();
	
	oSlide2 = new oFadedSlides('slideshow2');
	oSlide2.nKickStartDelay = 3000;
	oSlide2.kickStart();
	
	oSlide3 = new oFadedSlides('slideshow3');
	oSlide3.nKickStartDelay = 5000;
	oSlide3.kickStart();
	
	oSlide4 = new oFadedSlides('slideshow11');
	oSlide4.nKickStartDelay = 1000;
	oSlide4.kickStart();
	
	oSlide5 = new oFadedSlides('slideshow12');
	oSlide5.nKickStartDelay = 3000;
	oSlide5.kickStart();
	
	oSlide6 = new oFadedSlides('slideshow13');
	oSlide6.nKickStartDelay = 5000;
	oSlide6.kickStart();
}

$('document').ready(setUpSlides);
