$(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
});



$('#deposit_calculator_panel').flash({
    src: '/content/flash/deposit-calculator.swf',
    width: 260,
    height: 360,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#redeposit_calculator_panel').flash({
    src: '/content/flash/funded-deposit-calculator.swf',
    width: 260,
    height: 360,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#members_deposit_calculator_panel').flash({
    src: '/content/flash/member-deposit-calculator.swf',
    width: 687,
    height: 160,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});
$('#new_members_deposit_calculator_panel').flash({
    src: '/content/flash/new-member-deposit-calculator.swf',
    width: 655,
    height: 160,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});
$('#win_ghds').flash({
    src: '/content/flash/ghd_membersbanner.swf',
    width: 655,
    height: 130,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#upcoming_games_panel').flash({
    src: '/content/flash/upcoming-jackpots.swf',
    width: 372,
    height: 204,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});


$('#free_games_panel').flash({
    src: '/content/flash/homepageFreeGamesTable.swf',
    width: 650,
    height: 350,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#next_big_jackpot_panel').flash({
    src: '/content/flash/next-big-jackpot.swf',
    width: 297,
    height: 212,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#main_banner_panel').flash({
    src: '/content/flash/new_homepage_movie.swf',
    width: 670,
    height: 353,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#main_banner_panelv2').flash({
    src: '/content/flash/670x353_MainBanner.swf',
    width: 670,
    height: 353,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#jackpot_thermometers_panel').flash({
    src: '/content/flash/jackpotThermometers.swf',
    width: 270,
    height: 280,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#new_winners_panel').flash({
    src: '/content/flash/260x240_new_winners.swf',
    width: 260,
    height: 240,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#new_15_bonus').flash({
    src: '/content/flash/Affiliate-nextjackpot.swf',
    width: 270,
    height: 280,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#new_homepage_aff').flash({
    src: '/content/flash/670x353_Homepage2011.swf',
    width: 670,
    height: 353,
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#comic_relief_tally').flash({
    src: '/content/flash/comic_relief_tally.swf',
    width: 250,
    height: 500,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#referafriendanim').flash({
    src: '/content/flash/205x100_referafriend.swf',
    width: 205,
    height: 100,
	wmode: 'transparent'
});

/////// New Homepage Flash
$('#hp-banner-main').flash({
    src: '/content/flash/mainBanner/mainmoviebanner.swf',
    width: 624,
    height: 355,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#hp-jackpots-panel').flash({
    src: '/content/flash/hp-jackpots/hp-next-jp.swf',
    width: 316,
    height: 166,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#hpTickerMovie').flash({
    src: '/content/flash/bulletBanner.swf',
    width: 624,
    height: 100,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});
$('#hp-winners-panel').flash({
    src: '/content/flash/hp-costacrazy-winnersfeed.swf',
    width: 316,
    height: 166,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#promotions-menu-panel').flash({
    src: '/content/flash/promotion-menu.swf',
    width: 685,
    height: 190,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});

$('#feedTab1').flash({
    src: '/content/flash/tab-feed-payout.swf',
    width: 134,
    height: 84,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});
$('#feedTab2').flash({
    src: '/content/flash/tab-feed-players.swf',
    width: 134,
    height: 84,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});
$('#costaDiary').flash({
    src: '/content/flash/CostaDiary.swf',
    width: 950,
    height: 490,
	wmode: 'transparent',
	flashvars: {dataUrl: "http://services.costabingo.com/diary/xml/get"}
});
$('#100kwinner').flash({
    src: '/content/flash/100kwinner.swf',
    width: 624,
    height: 100,
	wmode: 'transparent',
	flashvars: {isActive: sessionID, whereAt:geolocation}
});



////////////////////////////////////////////////////////////////////////////////////////
// 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");
}

