var iRotatorLink = 0;
var iRotatorSecs = 3;
var iRotatorElements = 11;

function rotator(i)
{ 
	if(i >= iRotatorElements )
		i = 0;
	
	jQuery('#photoRotator').fadeOut('medium', function(){rotatorChangeBg(i)});
	iRotatorLink = i;
	iRotatorSecs = 3;
}

function rotatorChangeBg(i)
{
	jQuery('#photoRotator').css('background-position','0 ' + (i*200*-1) + 'px');
	jQuery('#photoRotator').fadeIn('slow');
	
	jQuery('#rotatorMenu').find('a').css('background-position','0 -15px');
	jQuery('#rotatorMenuAnchor_' + i).css('background-position','0 1px');
}

function rotate()
{
	--iRotatorSecs;
	
	if( iRotatorSecs < 0 )
	{
		rotator(iRotatorLink+1);
	}
	
	setTimeout("rotate()",1000);
}

jQuery(document).ready(function(){
	
	jQuery('#prizesContainer a').lightBox();
	
	var iRotatorImage = new Image();
	jQuery( iRotatorImage ).load( function() {
		jQuery('#photoRotator').css('background-position', '0 0');
		jQuery('#photoRotator').css('background-image', 'url('+jQuery( iRotatorImage ).attr('src')+')' );
		
		jQuery('#rotatorMenu').find('a').each( function(){
			
			eval('jQuery(this).click( function() {rotator('+i+')});jQuery(this).attr("id","rotatorMenuAnchor_'+i+'");i++;');
		});
		jQuery('#rotatorMenuAnchor_0').css('background-position','0 1px');
		setTimeout("rotate()",1000);
	});
	jQuery( iRotatorImage ).attr( 'src', '/media/rotator.jpg' );
	
	var i = 0;

	
});