// NEW HOME FUNCTIONS START
// CUFON REPLACE FOR HOME PAGE
Cufon.replace('#frontLeftTabs') ('#bingoPromos li') ('#bingoPromos2 li') ('#bingoPromos li span.promoTitle p') ('#bingoPromos2 li span.promoTitle p') ('#rightSubNav') ('#ball75') ('#ball90') ('.viewWinners');
// IG GAMES SLIDESHOW FUNCTION
function igSlideSwitch() {
var $active = $('#igBanners IMG.active');
if ( $active.length == 0 ) $active = $('#igBanners IMG:last');
var $next =  $active.next().length ? $active.next()
    : $('#igBanners IMG:first');
$active.addClass('last-active');
$next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1000, function() {
        $active.removeClass('active last-active');
    });
}
// JACKPOTS SLIDESHOW FUNCTION
function jackpotsSlideSwitch() {
var $active = $('#jackpots div.active');
if ( $active.length == 0 ) $active = $('#jackpots div:last');
var $next =  $active.next().length ? $active.next()
    : $('#jackpots div:first');
$active.addClass('last-active');
$next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1000, function() {
        $active.removeClass('active last-active');
    });
}
// NEW HOME FUNCTIONS END

$(document).ready(function() {
 
	// box slider function
	$('.boxgrid.slidedown').hover(function(){
		$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	});
	
	//start vertical tabs
	$(function() {
		$("#tabs").tabs().addClass('ui-tabs-vertical ui-helper-clearfix');
		//$("#tabs li").removeClass('ui-corner-top').addClass('ui-corner-left');
	});
	
	//window.setInterval(function(){alert('Hello!');},5000); 
	
	//Main slider banner
	//Set Default State of each piece
	
	// Launch Party 
	$.ajax({
			type: "GET",
			url: "http://www.tastybingo.com/launchParty.xml",
			dataType: "xml",
			success: function(xml) {
			
				var $count = 0;
			
				$(xml).find('image').each(function(){
					$count++;
					var $thumbImg = $(this).attr('small');
					var $largebImg = $(this).attr('large'); 
					var $info = $(this).attr('info'); 
					$('<li id="launchImg'+$count+'"></li>').html('<img src="images/launchParty/'+$thumbImg+'" />').appendTo('#launchGaller')
						.click(function(){
							var $docHeight = $(document).height();
							$('<div id="launchGallerBg"></div>').appendTo('body')
								.css({
									width: '100%',
									height: $docHeight,
									background: '#000',
									position: 'absolute',
									top: '0px',
									left: '0px',
									zIndex: '5000',
									opacity: '0.4',
									filter: 'alpha(opacity=40)'
								})
								.click(function(){$(this).remove();$('#launchGallerImg').remove();});
							$('<div id="launchGallerImg"><h3>'+$info+'</h3><img src="images/launchParty/'+$largebImg+'" /></div>').appendTo('body')
								.css({
									width: '450px',
									height: '299px',
									position: 'absolute',
									top: '800px',
									left: '50%',
									marginLeft: '-100px',
									zIndex: '6000',
									border: 'solid 5px #FFF'
								})
								.click(function(){$(this).remove();$('#launchGallerBg').remove();});
							Cufon.refresh();
							$('<span class="galleryClose"></span>').appendTo('#launchGallerImg');
						});
				});	
			}
	});
	

	
	//jackpotSwitch();
	var $timerCount = 0;
	$('#jackpotWraper li:first').hide();
	function jackpots(){
		setInterval(function(){
			if($timerCount == 20){
				$('#jackpotWraper li:last').fadeOut(500);
				$('#jackpotWraper li:first').fadeIn(500);
			} else if($timerCount == 40){
				$('#jackpotWraper li:last').fadeIn(500);
				$('#jackpotWraper li:first').fadeOut(500);
				$timerCount = 0;
			}
			$timerCount++;
		},1000);
	}
	
	jackpots();


// NEW HOME START
	$('#frontLeftTabs li').click(function(){
		$(this).addClass('currentTab');
		$(this).siblings('li').removeClass('currentTab');
		Cufon.refresh();
		$('div.tabInfo').hide();
		$('#'+$(this).attr('id')+'Content').show();
	});
	$('#bingoPromos li:odd').css({marginRight: '0px'});
	$('#bingoPromos2 li:odd').css({marginRight: '0px'});
	$('#bingoPromos li').hover(
		function(){
			$(this).find('img').stop().animate({top: -240}, 200);
	},	function(){
			$(this).find('img').stop().animate({top: 30}, 200);
	});
	$('#bingoPromos2 li').hover(
		function(){
			$(this).find('img').stop().animate({top: -240}, 200);
	},	function(){
			$(this).find('img').stop().animate({top: 30}, 200);
	});
	$('#bingoPromos li').click(function(){
		var link = $(this).attr('link');
		document.location.href = link;
	});
	$('#bingoPromos2 li').click(function(){
		var link = $(this).attr('link');
		document.location.href = link;
	});
	// CALL IG GAMES SLIDESHOW FUNCTION
	setInterval( 'igSlideSwitch()', 2000 );
	// CALL JACKPOTS SLIDESHOW FUNCTION
	setInterval( 'jackpotsSlideSwitch()', 5000 );
	// SUB NAVIGATION LINKS	
	$('li.jamesPlace').click(function(){
		document.location.href = '../bigchef/';
	});
	$('li.tastyRecipes').popupWindow({ 
		windowURL:'../recipes/recipes.html', 
		height:640, 
		width:645, 
		top:100, 
		left:50
	}); 
	$('li.tastyTV').popupWindow({ 
		windowURL:'http://www.tastybingo.com/skin/tv-adverts.html', 
		height:640, 
		width:525, 
		top:100, 
		left:50
	});
// NEW HOME END
		
});
