$(window).load(function(){

function runpanel(){
	$('#raf_modal').fadeIn("slow", function() {
     	if($.browser.msie){
        	this.style.removeAttribute('filter');
	 	};
	});
}

setTimeout(runpanel, 1500);

$(document).pngFix();

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

//////////////////////////////////////////////////////////////////////////////////////

var loggedin = get_cookie("sessionID");
//alert(loggedin);
if(loggedin==null){
	sessionID="false";
}else if(loggedin!=null){
	sessionID="true";	
}
//alert(sessionID);

var alias = get_cookie("Alias");

//////////////////////////////////////////////////////////////////////////////////////

var geolocation = get_cookie("currency");
if(!geolocation){
	//alert("no curr cookie set");
	var geolocation = get_cookie("location");
	if(!geolocation){
		geolocation="GBP"	
	}
}

//////////////////////////////////////////////////////////////////////////////////////

var isFunded = get_cookie("funded");

//////////////////////////////////////////////////////////////////////////////////////


function changeCurr(where){
	if(where=="USD"){
		var sign = "$";
		var minCost = "5c";
		var maxCost = "10c";
	}else if(where=="EUR"){
		var sign = "&euro;";
		var minCost = "5c";
		var maxCost = "10c";	
	}
	var pageStr = $('#inner_content').html();
	var result  = pageStr.replace(/\u00A3/g, sign);
	$('#inner_content').html(result);
	
	var pageStr = $('#inner_content').html();
	var result  = pageStr.replace(/5p/g, minCost);
	$('#inner_content').html(result);
	
	var pageStr = $('#inner_content').html();
	var result  = pageStr.replace(/10p/g, maxCost);
	$('#inner_content').html(result);
}

var hnedit = window.location.toString();

// Removed Currency switching, was causing problems with FB panel. Use $currencyLarge and $currencySmall instead
//alert(hnedit);
/*if(hnedit.match("refer-a-friend.php")==null && hnedit.match("register.php")==null && hnedit.match("members.php")==null && hnedit.match("main.php")==null){
	if(geolocation!="GBP"){
	//alert("location cookie set to "+geolocation);	
		changeCurr(geolocation);
	}
}
*/

$('#popup_close').click(function(){
		$(document).trigger('close.facebox');
	});

// Members page text //
	$('.text').css({'height':'125px', 'overflow':'hidden'});
	// Show / hide the text panel
	$('#morelink').click(function(){
		var textHeight = $('.text').css('height');
		if(textHeight=="125px"){
			$('.text').css({'height':'auto'});
			$('#morelink').html("Read Less");
		}else{
			$('.text').css({'height':'125px'});
			$('#morelink').html("Read More");
		}
		return false;
	});	

///////////////////////////////////////////////////////////////////////////////////////

$('#giveawaysTest').flash({
    src: '/content/flash/homepage_movie.swf',
    width: 670,
    height: 350,
	flashvars: {isActive: sessionID, geolocation:geolocation} 
});

$('#gamesTable').flash({
    src: '/content/flash/games_table_container_v2.swf',
    width: 660,
    height: 430,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#demo-holder-roulette').flash({
    src: '/content/flash/demo-holder-roulette.swf',
    width: 428,
    height: 240,
	wmode: 'transparent'
});

$('#ignite_banner').flash({
    src: '/content/flash/ignite-affiliates-650x90.swf',
    width: 650,
    height: 90
});

$('#referafriendanim').flash({
    src: '/content/flash/raf-small.swf',
    width: 195,
    height: 200
});

$('#cta-banner-dev').flash({
    src: '/content/flash/homepage-cta-banner.swf',
    width: 945,
    height: 300,
	flashvars: {isActive: sessionID, geolocation:geolocation, isFunded:isFunded}
});

$('#debut').flash({
    src: '/content/flash/homepage-banners/305x186home-makeyourdebut.swf',
    width: 305,
    height: 186,
	wmode: 'transparent',
	flashvars: {isActive: sessionID}
});

$('#reload').flash({
    src: '/content/flash/homepage-banners/305x186home-reloadtour.swf',
    width: 305,
    height: 186,
	wmode: 'transparent'
});

$('#reload-promo').flash({
    src: '/content/flash/305x186_reloadpromo.swf?r=' + Math.random(),
    width: 305,
    height: 186,
	wmode: 'transparent'
});

$('#freeBingo').flash({
    src: '/content/flash/homepage-banners/305x186home-freebingo.swf',
    width: 305,
    height: 186,
	wmode: 'transparent'
});

$('#memorabilia').flash({
    src: '/content/flash/homepage-banners/305x186home-memorabilia.swf',
    width: 305,
    height: 186,
	wmode: 'transparent'
});

$('#gamesList').flash({
    src: '/content/flash/currentgames-jukebox.swf',
    width: 305,
    height: 431,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, geolocation:geolocation}
});

$('#vipstatus').flash({
    src: '/content/flash/213x100members-class.swf',
    width: 213,
    height: 120,
	wmode: 'transparent'
});

$('#HomepageJukebox').flash({
    src: '/content/flash/currentgames-jukebox-new.swf',
    width: 305,
    height: 431,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, geolocation:geolocation}
});

$('#HomepageFlashBanner').flash({
    src: '/content/flash/homepage-cta-banner-new.swf',
    width: 932,
    height: 249,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, geolocation:geolocation}
});

$('#members-sidebar-vip').flash({
    src: '/content/flash/248x119-members-class.swf',
    width: 248,
    height: 119,
	wmode: 'transparent'
});

$('#members-sidebar-vip-test').flash({
    src: '/content/flash/248x119-members-class-test.swf',
    width: 248,
    height: 119,
	wmode: 'transparent'
});

////////////////////////////////////////////////////////////////////////////////////////
// T's & C's 

$('.terms > ol').hide();

$('a.termslink').toggle(function() {
  $(this).parent().parent().find('ol').show();
  $(this).parent().contents().html("Terms &amp; Conditions (Click To Hide)");
}, function() {
  $(this).parent().parent().find('ol').hide();
  $(this).parent().contents().html("Terms &amp; Conditions (Click To Show)");
});

////////////////////////////////////////////////////////////////////////////////////////

});

function playRoom(iRoomID){
	playWin = window.open("/skin/play.php?room=" + iRoomID, "playWin", "height="+screen.height-2+",width="+screen.width-2+",screenY=1,screenX=1,resizable");
}

////////////////////////////////////////////////////////////////////////////////////////

$(document).ready(function(){
	
	$('#Username').watermark('Username');
	$('#Password').watermark('Password');

});
