var $j = jQuery.noConflict();
 
// Use jQuery via $j(...)
$j(document).ready(function() {

/* Set up carousel */
$j("ul.slides li").css({display: 'none'});
var listLength = $j("ul.slides li").length; // get the number of items in the list
var intervalID; 
var i = 0; // set the counter

function playCarousel(){
intervalID = setInterval(stepThrough, 3000); //triggers the stepThrough function every x seconds (divide the number by 1,000)
}

$j("ul.slides li").eq(i).addClass("selected");
$j("ul.slides li").eq(i).fadeIn('slow');

function stepThrough(){ 
$j("ul.slides li").removeClass("selected");
$j("ul.slides li").css({display: 'none'});
previousi = i;
if((Math.abs(i))<(listLength-1)){ // if the counter is less than the total # in list (ie not yet at the end)...
i++; // ... add 1 to i...
} else {
i=0; // ...otherwise set i to 0 (which will make it go back to the start)
} 
//alert(i);
$j("ul.slides li").eq(i).addClass("selected");
$j("ul.slides li").eq(i).fadeIn('slow');
}

$j("ul.slides li").mouseover(function(event) {
clearInterval(intervalID);
});

$j("ul.slides li").mouseout(function(event) {									   
playCarousel();
});

playCarousel();

});
