/**
 * Rotating banner
 * 
 * Simple fade effect is applied to all children.
 * Script assumes that first child is displayed initially
 * and progresses in order of existance in DOM.
 * 
 * @author Brendan Markham
 */
$(function()
{
	/** Configurable options */
	var delay = 9000;
	var speed = 1000;	
	var parent = "#rotate";
	var child = "li";
	
	var call = parent + " " + child;
	var total = $( call ).length;
	
	/** Main program */
	function rotate()
	{
		$( call )
			.eq( 1 )
			.css( "z-index" , "1" );
		$( call )
			.eq( 0 )
			.css( "z-index" , "2" )
			.delay( delay )
			.animate({ "opacity" : "0"} , speed , function()
			{
				$( this )
					.appendTo( parent )
					.css({
						"opacity" : "1" ,
						"z-index" : "0"
					});
				rotate();
			});
	}
	
	/** Autoload */
	if ( total > 1 )
	{
		$( call ).css( "z-index" , "0" );
		rotate();
	}
});
