 $(document).ready(function(){
	// Hide the div temporarily...
    $("#rotatorpanel").hide();
	manageContent('rotatorpanel');

// Some event driven rotator on a timer goes here?
// Starts at 1, goes through to the last one, then starts again. Fades in/out, based on vars I guess. Must start hidden...
function manageContent(targetID)
{    	
	var timeVal = 10000;
	
	var iLen = 1; // <-- must pre-initialise, otherwise js returnds undefined, as it ignores an ordinal of zero for arrays of 1 item
	
	if(document.forms[0].elements['rp'].length != undefined)
	{
	    iLen = parseInt(document.forms[0].elements['rp'].length);
	}
	
	var x = parseInt(document.getElementById('rv').value);
	
	document.getElementById('rv').value = x + 1
	document.getElementById('rv').value = parseInt(document.getElementById('rv').value) < iLen ? document.getElementById('rv').value : 0;
	getRotatorContent(targetID, eval("document.forms[0].elements['rp[" + x + "]'].value"), timeVal);

	// Set a delay before calling the whole manager again...
	var cTimer = {};
	
	cTimer = $.timer(timeVal, function(){
		manageContent(targetID);
	});
}

function getRotatorContent(targetID, contentID, fadeDuration)
{
    // Call the AJAX content. Usual fayre.
	var url = contentID;
	
	$('#rotatorpanel').load(contentID);

	//Show this content...
	showFade();
	
	fadeDuration = fadeDuration - 500;
	
	var fTimer = {};
	
	fTimer = $.timer(fadeDuration, function(){
		hideFade();
	}); 
}

function showFade()
{
	$('#rotatorpanel').fadeTo("slow", 1.0); 
}

function hideFade()
{
	$('#rotatorpanel').fadeTo("Slow", 0.01);
}

});
