$(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"	
	}
}


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;
	});	

	
///////////////////////////////////////////////////////////////////////////////////////

$('#flashHeader').flash({
    src: '/content/flash/big_sun_bg.swf',
    width: 600,
    height: 200,
	wmode: 'transparent',
	flashvars: {username: alias, isActive: sessionID, geolocation:geolocation}
});

$('#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}
});

$('#refermember').flash({
    src: '/content/flash/428x160_referafriend.swf',
    width: 428,
    height: 160,
	wmode: 'transparent'
});

$('#refermembercta').flash({
    src: '/content/flash/428x210_referafriend.swf',
    width: 428,
    height: 210
});

$('#depositmovie').flash({
    src: '/content/flash/212x204px200deposit.swf',
    width: 212,
    height: 204,
	wmode: 'transparent'
});

$('#firstdeposit').flash({
    src: 'http://www.costabingo.com/skin/_jackpots/specialticketfirstdeposit_site.swf',
    width: 185,
    height: 215,
	flashvars: {geolocation:geolocation}
	
});

$('#reloadfreebie').flash({
    src: 'http://www.costabingo.com/skin/_jackpots/specialticketfreeroll_site.swf',
    width: 185,
    height: 215,
	flashvars: {geolocation:geolocation}
});

$('#vipstatus').flash({
    src: '/content/flash/vipStatus.swf',
    width: 212,
    height: 130,
	wmode: 'transparent'
});

$('#jackpots').flash({
    src: '/content/flash/jackpotsPanelSm.swf',
    width: 204,
    height: 196,
	wmode: 'transparent',
	flashvars: {whereAt:geolocation}
});

$('#tvadvert').flash({
    src: '/content/flash/tvadvert.swf',
    width: 619,
    height: 467,
	wmode: 'transparent'
});

$('#gamesTableSmall').flash({
	src: '/content/flash/games_table_container_small.swf',
	width: 371,
	height: 455,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});	

$('#jackpotsPanelInner').flash({
	src: '/content/flash/newJackpotsPanel.swf',
	width: 289,
	height: 477,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});	

$('#slotsmovie').flash({
    src: '/content/flash/212x204Xfactor.swf',
    width: 212,
    height: 204,
	wmode: 'transparent'
});

$('#demo-beehappy').flash({
    src: '/content/flash/demo-beehappy.swf',
    width: 428,
    height: 314
});

$('#demo-sands').flash({
    src: '/content/flash/demo-sands.swf',
    width: 428,
    height: 314
});

$('#demo-invasion').flash({
    src: '/content/flash/demo-invasion.swf',
    width: 428,
    height: 314
});

$('#demo-paradise').flash({
    src: '/content/flash/demo-paradise.swf',
    width: 428,
    height: 314
});

$('#demo-love').flash({
    src: '/content/flash/demo-love.swf',
    width: 428,
    height: 314
});

$('#demo-holder-pirates').flash({
    src: '/content/flash/demo-holder-pirates.swf',
    width: 428,
    height: 240,
	wmode: 'transparent'
});

$('#demo-holder-Xfactor').flash({
    src: '/content/flash/demo-holder-Xfactor.swf',
    width: 428,
    height: 240,
	wmode: 'transparent'
});

$('#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
});


////////////////////////////////////////////////////////////////////////////////////////
// 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)");
});

////////////////////////////////////////////////////////////////////////////////////////

});
