$(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;
	});	

///////////////////////////////////////////////////////////////////////////////////////

$('#hpFlashBanner').flash({
    src: '/content/flash/mainBanner/smart-banner.swf',
    width: 570,
    height: 217,
	wmode: 'transparent',
	flashvars: {isActive: sessionID}
});

$('#hpFlashBanner-dev').flash({
    src: '/content/flash/mainBanner/smart-banner-dev.swf',
    width: 570,
    height: 217,
	wmode: 'transparent',
	flashvars: {isActive: sessionID}
});

$('#left-tree-decor').flash({
    src: '/content/flash/border-left.swf',
    width: 229,
    height: 883,
	wmode: 'transparent',
	flashvars: {isActive: sessionID}
});

$('#right-tree-decor').flash({
    src: '/content/flash/border-right.swf',
    width: 229,
    height: 883,
	wmode: 'transparent',
	flashvars: {isActive: sessionID}
});

$('#glowing-flower').flash({
    src: '/content/flash/footerflower.swf',
    width: 283,
    height: 381,
	wmode: 'transparent',
	flashvars: {isActive: sessionID}
});
$('#hp-logo').flash({
    src: '/content/flash/hp-logo.swf',
    width: 626,
    height: 172,
	wmode: 'transparent',
	flashvars: {isActive: sessionID}
});
$('#winners-panel').flash({
    src: '/content/flash/260x240_new_winners.swf',
    width: 272,
    height: 200,
	wmode: 'transparent',
	flashvars: {isActive: sessionID}
});

////////////////////////////////////////////////////////////////////////////////////////
// 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");
}
