var J=jQuery.noConflict();
var slideshowTimer = null;
J(document).ready(function(){
    setTimeout('initRotator()', 5000);

});
function isVisible(obj) { return (obj.css('display') == 'block'); } 

function initRotator(){
    	doSlideshow('rotator', true, 5000);
	
}

function doSlideshow(objid, start, time){
	if(!J('#' + objid) || !isVisible(J('#' + objid))){
		if(slideshowTimer != null){
			clearTimeout(slideshowTimer);
			slideshowTimer = null;
		}
		return;
	}
	
	if(start){
		clearTimeout(slideshowTimer);
		slideshowTimer = null;
	}
	
	var currObj = J('#' + objid + ' li.current');
	var nextObj = currObj.next();
	if(J('#' + objid + ' li:last').hasClass('current')){ 
		nextObj = J('#' + objid + ' li:first');
	}

	nextObj.addClass('current');
	nextObj.css('opacity', 0);
	nextObj.css('display', 'block');
	currObj.fadeOut('normal', function(){ J(this).removeClass('current'); });
	nextObj.animate({opacity:1}, 'fast');
	
	slideshowTimer = setTimeout('doSlideshow("' + objid + '", false, ' + time + ');', time);
}