/*
 * Emaxed Simple Content Slide Show
 * Version: 1.0.0 (01/12/2011)
 * Copyright (c) 2011 Emaxed
 * Licensed under the MIT License: http://en.wikipedia.org/wiki/MIT_License
 * Requires: jQuery v1.3+
*/
var timer = new Array();
var intervalArray = new Array();

function setUpSlides(slideContent,theButtons,singleButtonClass,slideUID,theInterval){
		intervalArray[slideUID] = theInterval; //need to store timer intervals in an array, so that different slideshows on same page can have different durations
		$(slideContent).hide(); //Hide all content
		$(theButtons + " div:first").addClass("active").show(); //Activate first button
		$(slideContent + ":first").show(); //Show first slide content
		var nextSlide = $(theButtons + " div:first").next();
		
		//start the timer
		timer[slideUID] = setInterval(function () {chgSlide(nextSlide,slideContent,theButtons,singleButtonClass,slideUID);}, intervalArray[slideUID]);
		
		//On Click Event for the buttons
		$(singleButtonClass).click(function() {
			chgSlide(this,slideContent,theButtons,singleButtonClass,slideUID);
			return false;
		});
		
}
function chgSlide(cSlide,slideContent,theButtons,singleButtonClass,slideUID){
	
	var nextSlide = $(cSlide).next();
	//if we have reached the end of the buttons, start back at the first
	if(nextSlide.length > 0){
	}else{
		nextSlide = $(theButtons + " div:first");
	}
	$(theButtons + " div").removeClass("active"); //Remove any "active" class
	$(cSlide).addClass("active"); //Add "active" class to selected tab
	$(slideContent).hide(); //Hide all tab content
	var nSlide = $(cSlide).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
	$(nSlide).fadeIn(); //Fade in the active ID content
	clearInterval( timer[slideUID] ); //remove the timer, then next line start a new timer
	timer[slideUID] = setInterval(function () {chgSlide(nextSlide,slideContent,theButtons,singleButtonClass,slideUID);}, intervalArray[slideUID]);
}
