
jQuery.fx.interval = 40;
try {
Cufon.replace('h1.pgheader, #content h1, #content h2, #fullpagelp_content h1, #fullpagelp_content h2, #content .title, #content h3, #content .subtitle, .subtitle2, #content h4');
Cufon.replace('table.fancycashier th');
} catch(e) {}
	
// create array of ticker images.
var tickerNum = new Array();
for (i = 0; i <= 9; i++) {
	tickerNum[i] = new Image();
	tickerNum[i].src = '/images-v3/jackpotTicker-'+i+'.gif';
}

$(document).ready(function(){
	updateJackpotTicker(true);
	
	// handle hover states of primary buttons
	$('.fancybutton').hover(
		function() { $('.hover', this).stop().addClass('mouseover').animate({opacity:1},100); },
		function() { $('.hover', this).stop().removeClass('mouseover').animate({opacity:0},200); }
	);
	
	// handle show/hide of language select
	$('#language_current').click(function(){
		if ($('#language_picker').hasClass('show')) {
			$('#language_picker').animate({top:'-114px'}, 200).removeClass('show');
			$('#language_arrow').attr('src', '/images-v3/language_arrow_open.png');
		} else {
			$('#language_picker').animate({top:'0px'}, 200).addClass('show');
			$('#language_arrow').attr('src', '/images-v3/language_arrow_close.png');
		}
		
	});
	
	// Set up currency flipping
	if (window.disableProblemAnim == undefined) {
		$('#welcome_bonus_currency li').css({opacity: 0});
		$('#welcome_bonus_currency li:first').css({opacity: 1}).addClass('show');
	} else {
		$('#welcome_bonus_currency li').hide();
		$('#welcome_bonus_currency li:first').show().addClass('show');
	}
	
	// start animation loops
	if ($('#jackpot_ticker').length > 0) setInterval('updateJackpotTicker()', 1000);
	if ($('#welcome_bonus_currency li').length > 1) setInterval('animateCurrency()',2000);
	
});

$(window).scroll(function() {
	$('body').css({'background-position': 'center -'+ $(window).scrollTop() * .2 +'px'});
});

$(window).load(function() {
	$('.fancybutton .hover').animate({opacity:0},200);
	setInterval('animateButtons()', 2000);
	
	/*
	var total = $('#splash>#slider img').length;
	if (total > 1 && window.disableSlider != true) {
		var rand = Math.floor(Math.random()*total);
		$('#splash>#slider').nivoSlider({
			effect:'fade',
			animSpeed:1000,
			pauseTime:4000,
			startSlide:rand,
			directionNav:false,
			controlNav:false,
			keyboardNav:false,
			pauseOnHover:true,
			manualAdvance:false			
		});
	} else if (total == 1 && window.disableSlider != true) {
		$('#splash>#slider img').show();
	} else {
		$('#splash>#slider img:first').show();
	}
	*/
	$('#splash>#slider img:first').show();
});

function animateCurrency() {
	var current = ($('#welcome_bonus_currency li.show')?  $('#welcome_bonus_currency li.show') : $('#welcome_bonus_currency li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#welcome_bonus_currency li:first') :current.next()) : $('#welcome_bonus_currency li:first'));	
	
	if (window.disableProblemAnim == undefined) {
		next.css({opacity: 0}).addClass('show').animate({opacity: 1}, 1000);
		current.animate({opacity: 0}, 1000).removeClass('show');
	} else {
		next.show().addClass('show');
		current.hide().removeClass('show');
	}
}

function animateButtons() {
	if (window.disableProblemAnim == undefined) {
		$('.fancybutton .hover').not('.mouseover').animate({opacity:1},{duration:200, queue:false, complete:function(){ $('.fancybutton .hover').not('.mouseover').animate({opacity:0},{duration:600, queue:false}) }});
	} else {
		
	}
}

