$(function(){
	
	// ***** INSTANT GAMES NAVIGATION ***** 
	Cufon.replace('#gamesNavigation3 li');
	$('#gamesNavigation3 li').hover(
		function(){
			$(this).find('img').stop().animate({
				top: 0
			},400,'easeOutElastic');
	},	function(){
			$(this).find('img').stop().animate({
				top: +20
			},400,'easeOutElastic');
	});
	$('#gamesNavigation3 li').click(function(){document.location.href = 'bingo-games.php'});
	
	// ***** JOYPOT ***** 
	// LOAD USER JOY POINTS TABLE
	email =  $('#hiddenEmail').html();
	$.ajax({
		type: "GET",
		url: "/proxy.php?email="+email,
		dataType: "xml",
		success: function(xml) {
			$(xml).find('joy').each(function(){
				var alias = $(this).attr('alias');
				var name = $(this).attr('name');
				var points = $(this).attr('points');
				// ADD TABLE CONTENT TO TABLE
				$('<tr><td class="name">'+name+'</td><td class="alias">'+alias+'</td><td class="points">'+points+'</td></tr>').appendTo('#joyPotPointsTable');
			});
			// ADD THE POINTS FOR THE SPECIFIC BRAND INTO BANNER
				// *WINK nth-child(2)
				// *POSH nth-child(3)
				// *TASTY nth-child(4)
				// *REDBUS nth-child(5)
			var brandPoints = $('#joyPotPointsTable tr:nth-child(5) td:nth-child(3)').text();
			$('#brandPoints').html(brandPoints);
			// HIDE LAST ROW OF TABLE/JOYPOT CARDS
			$('#joyPotPointsTable tr:last').hide();
		} 
	});
	// VIEW ALL POINTS BUTTON
	$('#showJoyPotPoints').click(function(){
		// ADD BACKGROUND TO BODY
		$('<div id="joyPotBlackBg"></div>').appendTo('body');
		$('#joyPotBlackBg').animate({opacity: 0.4},300);
		// ADD TABLE TO BODY
		$('#joyPotPointsTable').appendTo('body').css('display','block');
		// ADD CLOSE BTN TO BODY
		$('<div id="joyPotPointsTableClose"></div>').appendTo('body');
		// REMOVE POINTS TABLE/BACKGROUND/CLOSE BTN
		$('#joyPotPointsTableClose').click(function(){$(this).remove();$('#joyPotBlackBg').remove();$('#joyPotPointsTable').hide();});	
		// RESIZE BACKGROUND  TO DOCUMENT HEIGHT
		$('#joyPotBlackBg').height($(document).height())
			// REMOVE POINTS TABLE/BACKGROUND/CLOSE BTN
			.click(function(){$(this).remove();$('#joyPotPointsTableClose').remove();$('#joyPotPointsTable').hide();});			
	});
	// LINK INFO BUTTON
	$('#linkJoyPotPage').click(function(){window.location.href = 'promotions/joypot.php';});
});

