$(document).ready(function() { 
	
	$.metadata.setType("attr", "validate");
	$("#tournamentForm").validate({
  		rules: {
    			form_no_players: {
      			required: true,
   			max: 1000
    			}
  		}
	});
	


	$(".floatingFooter").addClass("fixedFloat");
	$("#main").addClass("margin");


	$("img[src$='.png']").ifixpng();						   
	
	$(".floatingFootercontent").toggle();
	
	$(".revealFooter").click(function () { 
      		$(".floatingFootercontent").toggle();
    	});
		
	// Set up the live person listener
	inviteTimer = setInterval ( "checkInvite()", 5000 ); 
	
	// hide the live chat of a button
	$('#live_chat_close').live('click', function() {
		hideChatAlert();
	});
	
	$('#live_chat_accept').live('click', function() {
		hideChatAlert();
	}); 
});


function showChatAlert() {
	// show live chat
	$('body').prepend("<div id='live_chat'><div id='live_chat_container'><h1>&pound;1,000<br />Welcome Bonus</h1><p>Claim up to &pound;1,000 in casino bonuses when you deposit now!</p><a href='#' id='live_chat_accept''>Chat Now</a></div><div id='live_chat_close'>close</div></div>");
	var lpAccept = $('.chatInvite').attr('ia');
	var lpReject = $('.chatInvite').attr('ir');

	$('#live_chat_accept').attr('onClick', lpAccept);
	$('#live_chat_close').attr('onClick', lpReject);

	$('#live_chat').slideDown();
}

function hideChatAlert() {
	// hide live chat
	$('#live_chat').slideUp(function () {
		$(this).remove();
	});
}

function checkInvite ( )
{
	if ($('.chatInvite').length)
	{
		showChatAlert();
		clearInterval(inviteTimer);
	}
	else
	{
		// do nothing
	}
} 
