 var pause = 0;
 var elementTimer;
 var carouselIds = ["#carousel"];
 var carouselData = [""];
 
 function storeCarouselData()
 {	
	for (var i=0; i<carouselIds.length; i++)
	{
		carouselData[i] = $(carouselIds[i]).html();
		$(carouselIds[i]).empty();
	}
 }
 
 function initCarousel(what, changeGap)
 {	
	//reset the element counter
	currentElement = -1; //0 to skip heading li
	
	//clear the current contents
	$("#carousel").empty();
		
	//copy the new contents into the container object
	$("#carousel").html(carouselData[what]);
	
	//Add the top level style to the first <ul>
	$("#carousel ul").addClass("backgroundHolder");
	$("#carousel .backgroundHolder li").fadeTo(10,0);
	
	
	//Make the li elements appear on top of eachother
	$("#carousel li").css("position","absolute");
	
	clearTimeout(elementTimer);
	changeElement(changeGap);
	$("#carousel").css("display","block");
 }
 
 function changeElement(nextChange)
 {	
	if (pause != 1)
	{
		var x = $("#carousel li");
		var spd = 1000;
		
		$(x[currentElement]).fadeTo(spd,0);
		
		currentElement ++;
		if (currentElement >= x.length)
		{
			currentElement = 0;
		}
		
		$(x[currentElement]).fadeTo(spd,1);
		
	}
	elementTimer = setTimeout("changeElement(" + nextChange + ")",nextChange);
 }