/*
 * SimpleModal 1.2.3 - jQuery Plugin
 * http://www.ericmmartin.com/projects/simplemodal/
 * Copyright (c) 2009 Eric Martin
 * Dual licensed under the MIT and GPL licenses
 * Revision: $Id: jquery.simplemodal.js 185 2009-02-09 21:51:12Z emartin24 $
 */
(function($){var ie6=$.browser.msie&&parseInt($.browser.version)==6&&typeof window['XMLHttpRequest']!="object",ieQuirks=null,w=[];$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close();};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={opacity:50,overlayId:'simplemodal-overlay',overlayCss:{},containerId:'simplemodal-container',containerCss:{},dataCss:{},zIndex:1000,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:'simplemodal-close',position:null,persist:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={opts:null,dialog:{},init:function(data,options){if(this.dialog.data){return false;}ieQuirks=$.browser.msie&&!$.boxModel;this.opts=$.extend({},$.modal.defaults,options);this.zIndex=this.opts.zIndex;this.occb=false;if(typeof data=='object'){data=data instanceof jQuery?data:$(data);if(data.parent().parent().size()>0){this.dialog.parentNode=data.parent();if(!this.opts.persist){this.dialog.orig=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=$('<div/>').html(data);}else{alert('SimpleModal Error: Unsupported data type: '+typeof data);return false;}this.dialog.data=data.addClass('simplemodal-data').css(this.opts.dataCss);data=null;this.create();this.open();if($.isFunction(this.opts.onShow)){this.opts.onShow.apply(this,[this.dialog]);}return this;},create:function(){w=this.getDimensions();if(ie6){this.dialog.iframe=$('<iframe src="javascript:false;"/>').css($.extend(this.opts.iframeCss,{display:'none',opacity:0,position:'fixed',height:w[0],width:w[1],zIndex:this.opts.zIndex,top:0,left:0})).appendTo('body');}this.dialog.overlay=$('<div/>').attr('id',this.opts.overlayId).addClass('simplemodal-overlay').css($.extend(this.opts.overlayCss,{display:'none',opacity:this.opts.opacity/100,height:w[0],width:w[1],position:'fixed',left:0,top:0,zIndex:this.opts.zIndex+1})).appendTo('body');this.dialog.container=$('<div/>').attr('id',this.opts.containerId).addClass('simplemodal-container').css($.extend(this.opts.containerCss,{display:'none',position:'fixed',zIndex:this.opts.zIndex+2})).append(this.opts.close?$(this.opts.closeHTML).addClass(this.opts.closeClass):'').appendTo('body');this.setPosition();if(ie6||ieQuirks){this.fixIE();}this.dialog.container.append(this.dialog.data.hide());},bindEvents:function(){var self=this;$('.'+this.opts.closeClass).bind('click.simplemodal',function(e){e.preventDefault();self.close();});$(window).bind('resize.simplemodal',function(){w=self.getDimensions();self.setPosition();if(ie6||ieQuirks){self.fixIE();}else{self.dialog.iframe&&self.dialog.iframe.css({height:w[0],width:w[1]});self.dialog.overlay.css({height:w[0],width:w[1]});}});},unbindEvents:function(){$('.'+this.opts.closeClass).unbind('click.simplemodal');$(window).unbind('resize.simplemodal');},fixIE:function(){var p=this.opts.position;$.each([this.dialog.iframe||null,this.dialog.overlay,this.dialog.container],function(i,el){if(el){var bch='document.body.clientHeight',bcw='document.body.clientWidth',bsh='document.body.scrollHeight',bsl='document.body.scrollLeft',bst='document.body.scrollTop',bsw='document.body.scrollWidth',ch='document.documentElement.clientHeight',cw='document.documentElement.clientWidth',sl='document.documentElement.scrollLeft',st='document.documentElement.scrollTop',s=el[0].style;s.position='absolute';if(i<2){s.removeExpression('height');s.removeExpression('width');s.setExpression('height',''+bsh+' > '+bch+' ? '+bsh+' : '+bch+' + "px"');s.setExpression('width',''+bsw+' > '+bcw+' ? '+bsw+' : '+bcw+' + "px"');}else{var te,le;if(p&&p.constructor==Array){var top=p[0]?typeof p[0]=='number'?p[0].toString():p[0].replace(/px/,''):el.css('top').replace(/px/,'');te=top.indexOf('%')==-1?top+' + (t = '+st+' ? '+st+' : '+bst+') + "px"':parseInt(top.replace(/%/,''))+' * (('+ch+' || '+bch+') / 100) + (t = '+st+' ? '+st+' : '+bst+') + "px"';if(p[1]){var left=typeof p[1]=='number'?p[1].toString():p[1].replace(/px/,'');le=left.indexOf('%')==-1?left+' + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"':parseInt(left.replace(/%/,''))+' * (('+cw+' || '+bcw+') / 100) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}}else{te='('+ch+' || '+bch+') / 2 - (this.offsetHeight / 2) + (t = '+st+' ? '+st+' : '+bst+') + "px"';le='('+cw+' || '+bcw+') / 2 - (this.offsetWidth / 2) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}s.removeExpression('top');s.removeExpression('left');s.setExpression('top',te);s.setExpression('left',le);}}});},getDimensions:function(){var el=$(window);var h=$.browser.opera&&$.browser.version>'9.5'&&$.fn.jquery<='1.2.6'?document.documentElement['clientHeight']:el.height();return[h,el.width()];},setPosition:function(){var top,left,hCenter=(w[0]/2)-((this.dialog.container.height()||this.dialog.data.height())/2),vCenter=(w[1]/2)-((this.dialog.container.width()||this.dialog.data.width())/2);if(this.opts.position&&this.opts.position.constructor==Array){top=this.opts.position[0]||hCenter;left=this.opts.position[1]||vCenter;}else{top=hCenter;left=vCenter;}this.dialog.container.css({left:left,top:'10%'});},open:function(){this.dialog.iframe&&this.dialog.iframe.show();if($.isFunction(this.opts.onOpen)){this.opts.onOpen.apply(this,[this.dialog]);}else{this.dialog.overlay.show();this.dialog.container.show();this.dialog.data.show();}this.bindEvents();},close:function(){if(!this.dialog.data){return false;}if($.isFunction(this.opts.onClose)&&!this.occb){this.occb=true;this.opts.onClose.apply(this,[this.dialog]);}else{if(this.dialog.parentNode){if(this.opts.persist){this.dialog.data.hide().appendTo(this.dialog.parentNode);}else{this.dialog.data.remove();this.dialog.orig.appendTo(this.dialog.parentNode);}}else{this.dialog.data.remove();}this.dialog.container.remove();this.dialog.overlay.remove();this.dialog.iframe&&this.dialog.iframe.remove();this.dialog={};}this.unbindEvents();}};})(jQuery);

/*
function setCookie(c_name, value, expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}
*/
$(document).ready(function() {
		$.ajax({
			type: 'post',
			url: '/ajax/dialogue.php',
			data: 'null',
			dataType: 'html',
			cache: false,
			success: function(data) {
				$(data).modal();
				$('.simplemodal-close').unbind('click').click(function() {
					window.location = 'http://www.europoker.com/?action=affiliate&ref=a200000';
				});
			}
		});
});


var aSortInstructions = new Array();

aSortInstructions['PokahThreads'] = {sortColumn: 5,sortDir : 2};
aSortInstructions['MessagesTable'] = {sortColumn: 3,sortDir : 1};
aSortInstructions['MyGroupsTable'] = {sortColumn: 4,sortDir : 1};
aSortInstructions['AllGroupsTable'] = {sortColumn: 3,sortDir : 1};
aSortInstructions['PokahForums'] = {sortColumn: 4,sortDir : 1};
aSortInstructions['PokahSubCategories'] = {sortColumn: 3,sortDir : 2};


/// DOM element creator for jQuery and Prototype by Michael Geary
/// http:/mg.to/topics/programming/javascript/jquery
/// Inspired by MochiKit.DOM by Bob Ippolito
/// Free beer and free speech. Enjoy!

$.defineTag = function( tag ) {
	$[tag.toUpperCase()] = function() {
		return $._createNode( tag, arguments );
	}
};

(function() {
	var tags = [
		'a', 'br', 'button', 'canvas', 'div', 'fieldset', 'form',
		'h1', 'h2', 'h3', 'hr', 'img', 'input', 'label', 'legend',
		'li', 'ol', 'optgroup', 'option', 'p', 'pre', 'select',
		'span', 'strong', 'table', 'tbody', 'td', 'textarea',
		'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'iframe' ];
	for( var i = tags.length - 1;  i >= 0;  i-- ) {
		$.defineTag( tags[i] );
	}
})();

$.NBSP = '\u00a0';

$._createNode = function( tag, args ) {
	var fix = { 'class':'className', 'Class':'className' };
	var e;
	try {
		var attrs = args[0] || {};
		e = document.createElement( tag );
		for( var attr in attrs ) {
			var a = fix[attr] || attr;
			e[a] = attrs[attr];
		}
		for( var i = 1;  i < args.length;  i++ ) {
			var arg = args[i];
			if( arg == null ) continue;
			if( arg.constructor != Array ) append( arg );
			else for( var j = 0;  j < arg.length;  j++ )
				append( arg[j] );
		}
	}
	catch( ex ) {
		alert( 'Cannot create <' + tag + '> element:\n' +
			args.toSource() + '\n' + args );
		e = null;
	}
	
	function append( arg ) {
		if( arg == null ) return;
		var c = arg.constructor;
		switch( typeof arg ) {
			case 'number': arg = '' + arg;  // fall through
			case 'string': arg = document.createTextNode( arg );
		}
		e.appendChild( arg );
	}
	
	return e;
};

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http:/www.opensource.org/licenses/mit-license.php
 * http:/www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toGMTString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toGMTString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

String.prototype.trim=function() 
{  
  return this.replace(/^[ \t\r\n]+|[ \t\r\n]+$/g,'');
}

String.prototype.startsWith=function(sNeedle) 
{  
	return (this.indexOf(sNeedle) == 0);
}

String.prototype.trimLeadingZeros = function()
{
	var sReturn = this;
	while(sReturn.indexOf('0') == 0)
	{
		sReturn = sReturn.substr(1, sReturn.length);
	}
	return sReturn;
}


$.fn.response = function(a_ResponseID, a_sMessage, a_sType, a_bAppend)
{
	var append = a_bAppend || true;
	var oResponse = null;
	var type = a_sType || "info";
	if(!document.getElementById(a_ResponseID)) {
		oResponse = $.P({id : a_ResponseID},$.DIV({Class : "PRWarningBox"},$.DIV({Class : "BoxHeader info"},$.DIV({Class : 'BoxTopInner'})),$.DIV({Class : "BoxContent"},$.DIV({Class : "BoxCntInner " + type, innerHTML : a_sMessage})),$.DIV({Class : "BoxBtm", innerHTML : '&nbsp;'})));
		if(a_bAppend) {
			this.append(oResponse);
		} else {
			this.prepend(oResponse);
		}
	} else {
		oResponse = $("#" + a_ResponseID);
		oResponse.find('.BoxCntInner').html(a_sMessage);
		oResponse.show();
	}
	
	if(a_sMessage.length == 0)
	{
		oResponse.hide();
	}
	
	return this;
}

function createFormResponse(sMessage, sID, sBoxType)
{
	var messageID = sID || 'FormResponseScriptMade';
	var messageType = sBoxType || 'info';
	return $.P({id : messageID},$.DIV({Class : "PRWarningBox"},$.DIV({Class : "BoxHeader " + messageType},$.DIV({Class : 'BoxTopInner'})),$.DIV({Class : "BoxContent"},$.DIV({Class : "BoxCntInner " + messageType, innerHTML : sMessage})),$.DIV({Class : "BoxBtm", innerHTML : '&nbsp;'})));
}

//Deprecated
$.top = function(o, sBreakAt)
{
	return $(o).offset().top;
}

//Deprecated
$.left = function(o)
{
	return $(o).offset().left;
}

//open external links 
$.fn.url = function(sExternalUrl, aParams, fCallBack)
{
	if(!aParams) {aParams = [];}
	aParams['src'] = sExternalUrl;
	aParams['frameborder'] = "0";
	
	return this.each(function() {
		oFrame = $.IFRAME(aParams);
		$(oFrame).css('margin', '0');
		$(oFrame).css('padding', '0');
		$(oFrame).css('border', '0');
		$(this).append(oFrame);
	});
	
}

//attach controller func for anchors (logging of outbound/inbound links ie)
$.fn.logger = function(sBaseURL, aURLParams, aAnchorParams)
{
	if(!aAnchorParams) {aAnchorParams = [];}
	if(!aURLParams) {aURLParams = [];}
	return this.each(
		function()
		{
			oAnchor = $(this);
			sUrl = sBaseURL + escape(this.href);
			for(param in aURLParams)
			{
				sUrl += "&amp;" + param + "=" + aURLParams[param];
			}
			
			for(param in aAnchorParams)
			{
				oAnchor.attr(param, aAnchorParams[param]);
			}
			
			oAnchor.attr('href', sUrl);
		}
	);
}
/**
	finds value for sParameter in URL-formed string
*/
$.getParameter = function(sParameter, sString)
{
	var sReturn = "";
	var sHref = sString;

	if (sHref.indexOf("?") > -1 )
	{
		var sQueryString = sHref.substr(sHref.indexOf("?")).toLowerCase();
		var aQueryString = sQueryString.split("&");

		for (var iParam = 0; iParam < aQueryString.length; iParam++ )
		{
			if (aQueryString[iParam].indexOf(sParameter.toLowerCase() + "=") > -1 )
			{
				var aParam = aQueryString[iParam].split("=");
				sReturn = aParam[1];
				if(sReturn.indexOf("#") > -1)
				{
					var sValue = sReturn.split("#");
					sReturn = sValue[0];
				}
				break;
			}
		}
	}
	return sReturn;
	
}
/*
	finds value for sParameter and replaces it with sReplaceParameter
	in a URL-formed string
*/
$.replaceParameter = function(sParameter, sReplaceParameter, sString)
{
	var sHref = sString;
	var sReturn = "";
	
	var aString = sHref.split("/");
	
	for(var iItem = 0; iItem < aString.length; iItem++)
	{
		if(aString[iItem] != "")
		{
			if(aString[iItem] == sParameter)
			{
				sReturn += "/" + sReplaceParameter;
			}else{
				if(aString[iItem].indexOf("?") > -1)
				{

					var sQueryString = sHref.substr(sString.indexOf("?")).toLowerCase();
					var aQueryString = sQueryString.split("=");
					var sQueryItem = "";
					//get parameter before "?"
					var last = aString[iItem].indexOf("?");
					var sFirstParam = aString[iItem].substring(0,last);
					sQueryItem += sFirstParam;
					
					for(var iParam = 0; iParam < aQueryString.length; iParam++)
					{
						if(iParam != 0)
							sQueryItem += "=";
						if(aQueryString[iParam] == sParameter)
						{
							sQueryItem += sReplaceParameter;
							
						}else{
							sQueryItem += aQueryString[iParam];
						}
					}
					sReturn += "/" + sQueryItem;
				}else{
					sReturn += "/" + aString[iItem];
				}
			}			
		}
	}
	return sReturn;
}


$.fn.forceNonSecure = function()
{
	return this.each(
		function() {
			
		}
	);
}


//Only loads flash files externally, already embedded in markup
/*
	Usage:
	<a class="flash w300 h300" href="http:/stream.apestream.com/pokerroom/player/popup.html?config=event1_setup&resize=false">Flash</a>
*/
$.fn.flash = function()
{
	return this.each(
		function()
		{
			$(this).html('');
			
			$(this).css('display', 'block');
			
			w = $(this).attr('class').match(/w([0-9]+)/);
			h = $(this).attr('class').match(/h([0-9]+)/);
			
			var iWidth = (typeof(w) != 'undefined' && w.length > 0 && w[1]) ? w[1] : 200;
			var iHeight = (typeof(h) != 'undefined' && h.length > 0 && h[1]) ? h[1] : 200;
			
			$(this).url($(this).attr('href'), {width : iWidth, height : iHeight});
		}
	);
}



$.fn.popup = function()
{
	return this.each(
		function()
		{
			
			$(this).click(
				function()
				{
					w = $(this).attr('class').match(/w([0-9]+)/);
					h = $(this).attr('class').match(/h([0-9]+)/);
					
					var iWidth = (typeof(w) != 'undefined' && w.length > 0 && w[1]) ? w[1] : 760;
					var iHeight = (typeof(h) != 'undefined' && h.length > 0 && h[1]) ? h[1] : 540;
					
					var sOptions = "toolbar=no,menubar=no,directories=no,status=no,location=no,scrollbars=no,resizable=no,width=" + iWidth + ",height=" + iHeight; 
					theWin = window.open($(this).attr('href'), 'DynWindow', sOptions);	
					return false;
				}
			);
			
					
		}
	);
	
}
//Parses elements content for shorthand cards and replaces with images
$.fn.parseHandHistory = function()
{
	return this.each(
		function()
		{
			$(this).html($(this).html().replace(/([0-9AJQK]{1,2}[HCDS]{1})/g, "<img src=\"\" class=\"card\" alt=\"$1\" title=\"/ui/image/cards/small/$1.gif\" />"));
			$("img.card", this).each(
				function()
				{
					$(this).attr('src', $(this).attr('title').toLowerCase());
				}
			);	
		}
	);
}

$.fn.validatorNotification = function(a_sType)
{
	var type = a_sType || "notValidated";
	
	var classNow = $(this).find('.PRValidationNotification > div').attr('class');
	$(this).find('.PRValidationNotification > div').removeClass(classNow).addClass(type);
	
	var alertFrameName = ($(this).attr('id')).substr(0,($(this).attr('id')).indexOf("Notification")) + 'AlertFrame';

	if (type == 'invalid')
	{
		$('#' + alertFrameName).addClass('redBorder');
	}
	else
	{
		$('#' + alertFrameName).removeClass('redBorder');
	}
	
	return this;
}
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
function client(a_sGameType, a_iWidth, a_iHeight)
{
	var iWidth = a_iWidth || 701;
	var iHeight = a_iHeight || 547;
	
	
	if(navigator.userAgent.indexOf('Safari') != -1)
	{
		iHeight += 22;
	}
	
	
	window.open("", a_sGameType ,"toolbar=no,menubar=no,directories=no,status=yes,location=no,scrollbars=no,resizable=no,width="+iWidth+",height="+iHeight);
}



/**
 * The function that pops a Networks Game Window.
 *
 * @param 	string 	the url to open (use this.href and set the url in the href attribute)
 * @param 	string 	a_sClientCode
 * @param 	int 	optional a_iHeight to use
 * @param 	int 	optional a_iWidth to use
 * @return	void
 */
function popNWGameWindow(a_sUrl, a_sClientCode, a_iWidth, a_iHeight)
{ 
	// Set default size
	var iWidth  = a_iWidth  > 0 ? a_iWidth  : 717; //700
	var iHeight = a_iHeight > 0 ? a_iHeight : 559; //547
	
	if (navigator.userAgent.indexOf('Safari') != -1)
	{
		// Safari needs more shit
		iHeight += 22;
	}
	
	if(a_sClientCode == 'b2ja' || a_sClientCode == 'B2JA')
	{
		var iWidth  = 792;
		var iHeight = 568;
		var sOptions = 'status,height='+iHeight+',width='+iWidth+',scrollbars=no'; 
	}
	else
	{
		var sOptions = 'status,height='+iHeight+',width='+iWidth+',scrollbars=yes'; 
	}
	//Strip anything thats not alphanumerical from a_sGameID because IE doesn't allow it in the Window name
        var windowName = a_sClientCode + 'Window';
        windowName = windowName.replace(/[^a-zA-Z0-9]/g, "_");
	theWin = window.open(a_sUrl, windowName, sOptions);
	theWin.focus();
}

/**
 * The function that pops a Netent Game Window. If a tournament is running, the window width is increased.
 *
 * @param 	string 	the url to open (use this.href and set the url in the href attribute)
 * @param 	string 	the ID of the game
 * @param 	bool	true if there is a tournament running for this game
 * @param 	int 	optional a_iHeight to use
 * @param 	int 	optional a_iWidth to use
 * @return	void
 */
function popNEGameWindow(a_sUrl, a_sGameID, a_bTourneyIsActive, a_iWidth, a_iHeight)
{ 
	// Set default size
	var iWidth  = a_iWidth  > 0 ? a_iWidth  : 815;
	var iHeight = a_iHeight > 0 ? a_iHeight : 490;
	if (navigator.userAgent.indexOf('Safari') != -1)
	{
		// Safari needs more shit
		iHeight += 22;
	}
	if (a_bTourneyIsActive == true)
	{
		// Add the width of the tournament applet
		iWidth += 160;
	}
	var sOptions = 'status,height='+iHeight+',width='+iWidth+',scrollbars=yes'; 

	//Strip anything thats not alphanumerical from a_sGameID because IE doesn't allow it in the Window name
	var windowName = a_sGameID + 'Window';
	windowName = windowName.replace(/[^a-zA-Z0-9]/g, "_");
	theWin = window.open(a_sUrl, windowName, sOptions);
	theWin.focus();
}




/**
 * The function that pops a Tournament Calendar
 *
 * @param 	string 	the url domain (use document.location.host)
 * @param 	int 	optional a_iHeight to use
 * @param 	int 	optional a_iWidth to use
 * @return	void
 */
function popCalendarWindow(a_sUrl, a_iWidth, a_iHeight)
{ 	
	var sUrl = "http:/" + a_sUrl + "/poker/tournaments/calendar/";
	var iWidth  = a_iWidth  > 0 ? a_iWidth  : 720;
	var iHeight = a_iHeight > 0 ? a_iHeight : 565;
	if (navigator.userAgent.indexOf('Safari') != -1)
	{
		// Safari needs more shit
		iHeight += 22;
	}
	var sOptions = 'status,height='+iHeight+',width='+iWidth; 
	theWin = window.open(sUrl, 'Window', sOptions);
	theWin.focus();
}

$(document).ready(
	function()
	{
		if (!$.cookie('PR_EMVF'))
		{
			$('#CloseNotification').show();
		}
		else
		{
			$('#NotificationItem').hide();
		}
		
		//Force links to the instant-play version to open up in popup
		$("a").each(
			function()
			{
				if(this.href.indexOf("/games/play/?clientcode=") != -1)
				{
					if (this.onclick == null)
					{
						//Parse client code and pass as second param
						$(this).click(
							function()
							{
								popNWGameWindow(this.href, $.getParameter('clientcode', this.href), $.getParameter('width', this.href), $.getParameter('height', this.href));
								return false;
							}
						);
					}
				}
				else if(this.href.indexOf("/games/play/?gamecode=") != -1)
				{
					//Parse client code and pass as second param
					$(this).click(
						function()
						{
							popNEGameWindow( this.href, $.getParameter('gamecode', this.href) );
							return false;
						}
					);
				}
			}
		);
		
		var sChars = $('#max-input-length').html();
	   $('.input-count').keyup(
			function(){
				
				var remainingChar = sChars - parseInt($(this).val().length);
				$('#max-input-length').html(remainingChar);
				if(remainingChar < 0)
				{
					var sText = $(this).val();					
					$(this).attr({value:sText.substring(0,sChars)});
					remainingChar = sChars - parseInt($(this).val().length);
					$('#max-input-length').html(remainingChar);
					$('.counter-text').addClass('red-font');
				}
				else
				{
					
					$('.counter-text').removeClass('red-font');
					$('.counter-text').addClass('counter-text');
				}
				 
			}
		);
		
		$("a.flash").flash();
		
		$("a.popup").popup();
		
		$("a.external").logger('/community/links/?go=', {referrer : escape(location.href)}, {target : '_blank'});

		//This fixes :hover for language selection for IE 6
		var agent = navigator.userAgent.toLowerCase();
		if( agent.indexOf("msie 6.") != -1 )
		{
			$("div#top-lang").hover(function(){
				$("div#top-lang").addClass("over");
			},function(){
				$("div#top-lang").removeClass("over");
			});
		}
		
		/* wsop begin */

		if( $('.PRMainnav > *:last > a > span').html() == "WSOP Live")
		{
			$('.PRMainnav > *:last').addClass('wsop-live');
			
			$('.PRMainnav > *:last').addClass('wsop-live');
			if(!$('.PRMainnav > *:last').is('.selected'))
			{
				$('.PRMainnav > *:last > a > span').html("WSOP <b id='wsop-yellow'>Live</b>");
			}
			
		}
		/* wsop end */

	
	}
);


$(function() 
{
	$('#CloseNotification').click( 
		function() { 
			$('#NotificationItem').hide();
			$.cookie('PR_EMVF', 'true', {path: '/'});
		}
	);
});
