jQuery.fn.fadeIn = function(speed, callback) { 
	return this.animate({opacity: 'show'}, speed, function() { 
		if (jQuery.browser.msie)  
			this.style.removeAttribute('filter');  
		if (jQuery.isFunction(callback)) 
			callback();  
	}); 
}; 
 
jQuery.fn.fadeOut = function(speed, callback) { 
	return this.animate({opacity: 'hide'}, speed, function() { 
		if (jQuery.browser.msie)  
			this.style.removeAttribute('filter');  
		if (jQuery.isFunction(callback)) 
			callback();  
	}); 
}; 
 
jQuery.fn.fadeTo = function(speed,to,callback) { 
	return this.animate({opacity: to}, speed, function() { 
		if (to == 1 && jQuery.browser.msie)  
			this.style.removeAttribute('filter');  
		if (jQuery.isFunction(callback)) 
			callback();  
	}); 
};

$( document ).ready( function()
{
	$( '#winnersFeed' ).css({ width: $( '#winnersFeed' ).width() });
	setTimeout( 'changeWinner()', 8000 );
	
	$( '#goToCasino' ).click
	(
		function()
		{
			$.ajax
			({
				type: 'GET',
				url: '/fup.php'
			})
		}
	);
});

function changeWinner()
{
	eval( $.ajax
		({
			type: 'GET',
			url: '/js/feed.php',
			async: false
		}).responseText );
	
	$( '#innerCon' ).fadeOut( 600, function()
		{
			$( '#winnersFeed' ).animate( { width: '100px' }, 1000, false, function()
				{
					updateWinnerHTML( newName, newGame, newWinnings, newUrl, newCasino )
				}
			);		
		}
	)
}

function updateWinnerHTML( newName, newGame, newWinnings, newUrl, newCasino )
{
	$( '#winnerName' ).html( newName );
	$( '#winnings' ).html( newWinnings );
	$( '#winnersGame' ).html( newGame );
	
	$( '#goToCasino' )
		.attr({ href : newUrl })
		.find( 'span' ).html( newCasino );
	
	$('#innerCon').css({ visiblity: 'hidden', display: 'block', position: 'absolute', opacity: 1 })
	newWidth = $( '#innerCon' ).width();
	newInnerWidth = Math.max( $( '#winCol1' ).width(), $( '#winCol1' ).width() );
	
	$( '#innerCon' ).css({ position: 'static', visibility: 'visible', display: 'none' });
	
	$( '#winnersFeed' ).animate( { width : ( newWidth + 110 ) + 'px' }, 1000, false, function()
		{
			$( '#innerCon' ).fadeIn( 600 );
		}
	)
	
	setTimeout( 'changeWinner()', 8000 );
}