
//PokerListings.modules.ExclusiveBonuses =
//{
//	run: function()
//	{
//		$('#eb-ebo td:last-child a, #eb-sef td:last-child a').toolTip({
//			ajax: function(elm)
//			{
//				return '/modules/ajax-tool-tip.php?room=' +elm.attr('href').replace(/\//, '');
//			}, 
//			on: 'click'
//		});
//	}
//};
PokerListings.modules.TableFinder =
{
	run: function()
	{
		PokerListings.modules.TableFinder.hijaxForm();
		PokerListings.modules.TableFinder.hijaxLinks();
	}, 

	hijaxForm: function()
	{
		var form = $('#tf-rttf form');

		form.submit(function()
		{
			var	room = $('select[name="room"]', form).val(), 
				game = $('select[name="game"]', form).val(), 
				type = $('select[name="type"]', form).val(), 
				num_players = $('select[name="num_players"]', form).val(), 
				you_what = $('select[name="you_what"]', form).val(), 
				sort = $('input[name="sort"]', form).val();

			$.post(
				'/modules/table-finder-mod.php', 
				{
					room: room, 
					game: game, 
					type: type, 
					num_players: num_players, 
					you_what: you_what, 
					sort: sort
				}, 
				function(data)
				{
			 		$('#tf-rttf').html(data);
					PokerListings.modules.TableFinder.run();
				}
			);

			return false;
		});
	}, 

	hijaxLinks: function()
	{
		$('#tf-rttf a[href^="?sort"]').click(function()
		{
			$.get('/modules/table-finder-mod.php' +$(this).attr('href'), function(data)
			{
		 		$('#tf-rttf').html(data);
				PokerListings.modules.TableFinder.run();
			});

			return false;
		});
	}
};var TOPLcurrent_tab = 1;
PokerListings.modules.TodayOnPL =
{
	run: function()
	{
		if ( $('#today-on-pl').length ) {
			PokerListings.modules.TodayOnPL.Carousel.init();
		}
	},
	Carousel:
	{
		running: true, 

		init: function()
		{
			//PokerListings.modules.TodayOnPL.Carousel.update();
			setInterval('PokerListings.modules.TodayOnPL.Carousel.update()', 5000);
			$('#today-on-pl .today-on-pl-tabs a').mouseover(function(){
				PokerListings.modules.TodayOnPL.Carousel.running = false;
				$('#stop-play').removeClass('stop');
				$('#stop-play').addClass('play');
			}),

			$('#player_control #stop-play').click(function()
			{
				if(PokerListings.modules.TodayOnPL.Carousel.running){
					PokerListings.modules.TodayOnPL.Carousel.running = false;
					$('#stop-play').removeClass('stop');
					$('#stop-play').addClass('play');
				} else {
					PokerListings.modules.TodayOnPL.Carousel.running = true;
					$('#stop-play').removeClass('play');
					$('#stop-play').addClass('stop');
				}
			}),
			
			$('#player_control .previous').click(function()
			{
				PokerListings.modules.TodayOnPL.Carousel.running = false;
				$('#stop-play').removeClass('stop');
				$('#stop-play').addClass('play');
				if (TOPLcurrent_tab==1) {
					TOPLcurrent_tab=$('#today-on-pl .today-on-pl-tabs li').length+1;
				} else {
					TOPLcurrent_tab -=1;
					$('#today-on-pl .today-on-pl-tabs').tabsClick(TOPLcurrent_tab);
				}
			}),
			$('#player_control .next').click(function()
			{
				PokerListings.modules.TodayOnPL.Carousel.running = false;
				$('#stop-play').removeClass('stop');
				$('#stop-play').addClass('play');
				if (TOPLcurrent_tab==$('#today-on-pl .today-on-pl-tabs li').length)
					TOPLcurrent_tab=1;
				else 
					TOPLcurrent_tab +=1;
					
				$('#today-on-pl .today-on-pl-tabs').tabsClick(TOPLcurrent_tab);
			})

			
		}, 

		update: function()
		{
			if(PokerListings.modules.TodayOnPL.Carousel.running)
			{
				$('#today-on-pl .today-on-pl-tabs').tabsClick(TOPLcurrent_tab);
				toggleTab(TOPLcurrent_tab);
				TOPLcurrent_tab +=1;
				if (TOPLcurrent_tab==$('#today-on-pl .today-on-pl-tabs li').length+1){TOPLcurrent_tab=1}
			}
		}
	}
};var dynWs = false;

function clt(obj,type,product) {
	var tt = new Array();
	tt[0] = 'Other Site Click';
	tt[1] = 'Poker Room Click';
	tt[2] = 'Download Click';
	tt[3] = 'Direct Play Click';

	var ws= new Array()	
	ws["24hpoker"]="0";
	ws["action-poker"]="1.25";
	ws["bet365poker"]="0";
	ws["betfair-poker"]="1.4";
	ws["bodog-poker"]="1.06";
	ws["bugsys-club"]="0";
	ws["bwin-poker"]="0.93";
	ws["carbon-poker"]="1.89";
	ws["cd-poker"]="2.63";
	ws["chilipoker"]="0";
	ws["doyles-room"]="0.39";
	ws["dreampoker"]="0";
	ws["duplicate-poker"] = "0";
	ws["empire-poker"]="0";
	ws["everest-poker"]="2.45";
	ws["fair-poker"]="5.65";
	ws["full-tilt-poker"]="1.67";
	ws["gnuf-poker"]="1.44";
	ws["hollywoodpoker.com"]="0.84";
	ws["inter-poker"]="0";
	ws["kspoker"]="1.13";
	ws["ladbrokes-poker"]="3.36";
	ws["mansion-poker"]="1.03";
	ws["noble-poker"]="2.62";
	ws["nuts-poker"]="0.89";
	ws["pacific-poker"]="1.31";
	ws["paddy-power-poker"]="2.34";
	ws["paradise-poker"]="0.20";
	ws["party-poker"]="2.52";
	ws["pkr"]="2.29";
	ws["playersonly-poker"]="2.32";
	ws["poker-nordica"]="0";
	ws["poker-ocean"]="0";
	ws["pokerroom"]="2.10";
	ws["poker-stars"]="2.08";
	ws["prime-poker"]="1.25";
	ws["purple-lounge"]="0.41";
	ws["red-kings-poker"]="1.01";
	ws["sportsbook-poker"]="1.26";
	ws["titan-poker"]="1.94";
	ws["unibet"]="1.22";
	ws["william-hill-poker"]="0";
	ws["wingows"]="0";
	ws["absolute-poker"] = "0";
	ws["betfred-poker"] = "0";
	ws["betholdem-poker"] = "0";
	ws["betway-poker"] = "0";
	ws["bowmans-poker"] = "0";
	ws["celebpoker"] = "0";
	ws["euro-poker"] = "0";
	ws["golden-palace-poker"] = "0";
	ws["holdem-poker"] = "0";
	ws["kiwi-casino-poker"] = "0";
	ws["nine.com"] = "0";
	ws["poker.com"] = "0";
	ws["poker770.com"] = "0";
	ws["pokerhost.com"] = "0";
	ws["pokeronclub"] = "0";
	ws["pokerplex"] = "0";
	ws["pokershare"] = "0";
	ws["pokertime"] = "0";
	ws["royal-vegas-poker"] = "0";
	ws["sun-poker"] = "0";
	ws["tigergaming.com"] = "0";
	ws["ultimate-bet"] = "0";
	ws["usa-poker"] = "0";
	ws["victor-chandler-poker"] = "0";
	ws["vip-poker"] = "0";

	/* If values are loaded from db, replace static array */
	if( dynWs !== false )
	{
		ws = dynWs;
	}
	
	//us allowed rooms
	var us= new Array()
	us["bodog-poker"] = 1;
	us["duplicate-poker"] = 1;
	us["ultimate-bet"] = 1;
	us["poker-stars"] = 1;
	us["absolute-poker"] = 1;
	us["full-tilt-poker"] = 1;
	us["wingows"] = 1;
	us["bugsys-club"] = 1;
	us["sportsbook-poker"] = 1;
	us["playersonly-poker"] = 1;
	us["carbon-poker"] = 1;
	us["poker-nordica"] = 1;
	us["doyles-room"] = 1;

	//us and canada only rooms
	var usCanOnly= new Array()
	usCanOnly["sportsbook-poker"] = 1;
	usCanOnly["playersonly-poker"] = 1;

	//canadian banned rooms
    var noCanadian= new Array()
    noCanadian["bodog-poker"] = 1;

	//german banned rooms
	var noGermans= new Array();
	noGermans["ladbrokes-poker"] = 1;

	var score = "0.00";

	if( ws[product] )
	{
		score = ws[product];
		category_type = tt[type];
	}
	else
	{
		if( tt[type] )
		{
			category_type = tt[0];
		}
		else
		{
			category_type = type;
		}
		type = 0;
	}

	//deal with banned rooms based on ip address
	var goToSite = true;
	if( isUsIp == 'yes' && ! us[product] && ws[product] )
	{
		goToSite = confirm('This poker room does not accept US players.\nAre you sure you want to continue?');
	}
	else if( isUsIp == 'no' && isCanadianIp == 'no' && usCanOnly[product] )
	{
		/*
		if( document.getElementById( product + 'Hidden' ) )
		{
			tb_show('','#TB_inline?height=440&width=630&inlineId=' + product + 'Hidden','');
			goToSite = false;
		}
		else
		{
		*/
			goToSite = confirm( '*ONLY OPEN TO U.S. AND Canadian PLAYERS!*\nIf you want to play against Americans click on POKER STARS or FULL TILT POKER.\nAre you sure you want to continue?' );
			//goToSite = confirm('This poker room is open to US players only.\nPlayers outside of the US will not be accepted.\nAre you sure you want to continue?');	
		//}
	}
	else if( isCanadianIp == 'yes' && noCanadian[product] && ws[product] )
	{
		if( product == 'bodog-poker' && document.getElementById( product + 'Hidden' ) )
		{
			tb_show('','#TB_inline?height=440&width=630&inlineId=' + product + 'Hidden','');
			goToSite = false;
		}
	}
	
	//Site Catalyst Tracking
	var s=s_gi(s_account);
	setTimeout("s.trackDownloadLinks="+s.trackDownloadLinks,600);
	s.trackDownloadLinks=false;
	
	s.linkTrackVars="eVar1,eVar2,events,products";
	setTimeout("s.trackExternalLinks="+s.trackExternalLinks,600);
	s.trackExternalLinks=false;

	if( goToSite == true )
	{
		/**
		  * Used to swap in offermatica tracking URL
		  * Deprecated, we are not using tracker mbox internally anymore
		  * sc purchase event is used instead
		  * if( obj.holder ) { obj.href = obj.holder;}
		  */
		s.eVar1 =_rootLevel;
		s.eVar2 = category_type;

		if( type > 0 )
		{
			/* Transition page name */
			s.pageName = "landing-page/" + product;
			
			/* event1 = Purchase Event */
			s.linkTrackEvents="purchase,event1";
			s.events="purchase,event1"
			s.products="" + category_type + ";" + product + ";1;" + score;
			
			/* Track Custom Link */
			s.tl(obj,'e',product);
			
			/* Track mbox click */
			if ( mboxFactoryDefault.getCookieManager().getCookie('PC') != null )
			{ 
				trackScEvent( s );
			}
			
			/* Reset purchase variables */
			s.linkTrackEvents = '';
			s.events = '';
			s.products= '';
			
			/* Track transition page */
			void(s.t());
			
			return true;
		}
		else
		{
			/* event7 = Non Commerce Exit Link */
			s.linkTrackEvents="event7";
			s.events="event7"
			s.products="" + category_type + ";" + product;
			
			/* Track Custom Link */
			s.tl(obj,'e',product);
			
			return true;
		}
	}
	else if( isUsIp == 'yes' )
	{
		document.location.href= '/US-poker-rooms';
		return false;
	}
	else
	{
		return false;
	}
}

function trackScEvent( sc ) {
   var s = sc;
   var tc = s.events && s.events.indexOf('purchase') != -1;
   var T = 'SiteCatalyst: ' + (tc ? 'purchase' : 'event');
   var pb = document.createElement('DIV');
   Q = mboxFactoryDefault.create(T, new Array(), pb );
   Q.setFetcher( new mboxAjaxScPluginFetcher('function', s ) );
   Q.load();
}

$(document).ready(function() {
	$.getJSON("/ajax/stat/click", function( data ){
		dynWs = data;
	})
})
/* used to display table finder results */

function showPage( page, urlStr, onFirstPage, design )
{

	$("div#extra-info").hide();	
	
	$("div#loader").show();
	
	if( ! urlStr )
	{
		urlStr = '';
				
		$("#table-finder select").each(function() {
			if( $(this).val() )
			{
				urlStr += '&' + $(this).attr('name') + '=' + $(this).val().replace( '+', '%2b' );
			}
		});
		
		if( ! page )
			page =  $("input[@name=page]").val();
		
		urlStr += '&page' + '=' +  page;
		
		urlStr += '&sort' + '=' +  $("input[@name=sort]").val();
		
		urlStr += '&advanced' + '=' +  $("input[@name=advanced]").val();
	}

	urlStr += '&design=' + design;

	//$("div#table-finder-content").fadeTo("slow", 0.01);

	
	ajaxUrl = '/ajax/table-finder/search';
	
	if ( onFirstPage == 'tool')
	{
		ajaxUrl += '-tool';
	}
	else if( onFirstPage )
	{
		ajaxUrl += '-fp';
	}
	
	$.get( ajaxUrl + "?" + urlStr, function( data ){
		$("div#table-finder-content").html( data );
		//$("div#table-finder-content").fadeIn("slow");
		$("div#loader").hide();
		
		$("th").mouseover(function() {
			
			oldTitle = '';
			
			if( $(this).attr('title') )
			{
				
				$('<div id="extra-info"></div>').appendTo('body').hide();
				
				$("div#extra-info").css( "min-height", "30px" );
				$("div#extra-info").css( "height", "30px" );
				$("div#extra-info").css( "top", (mouseY + 5) + "px" );
				$("div#extra-info").css( "left", (mouseX - 5) + "px" );
				$("div#extra-info").show();
				$("div#extra-info").html(  $(this).attr('title') );
				
				oldTitle =  $(this).attr('title');
				
				$(this).attr('title', '' );
			}
			
		});
		
		$("th").mouseout(function() {
			if( typeof(oldTitle) != 'undefined' && oldTitle )
			{
				$(this).attr( 'title', oldTitle );
				$("div#extra-info").hide();
			}
			
		});
		
		
		$("th").mousemove(function() {
			$("div#extra-info").css( "top", (mouseY + 5) + "px" );
			$("div#extra-info").css( "left", (mouseX + 15) + "px" );	
		});
		
	});
	
	return false;
}

function tableInfo( contentId, tableData, isTool )
{
	if($.browser.msie)
	{
		$('#tablefinder-page #content select').hide();
	}

	if(document.getElementById('table-finder-info'))
	{
		$('#table-finder-info').remove();
	}
	
	$('<div id="table-finder-info" class="stone-box">Loading...</div>').appendTo('body').hide();
	
	$("div#loader").show();
	
	ajaxUrl = '/ajax/table-finder/info';
	
	if( isTool )
	{
		ajaxUrl += '-tool';
	}
	
	$.get(ajaxUrl + "?content_id=" + contentId + "&table_data=" + tableData, function( data ){
		
	if( isTool )
	{	
		$("#table-finder-info").html( data ).fadeIn("slow");
	}
	else
	{
		$("#table-finder-info").html( data ).show().center();
	}

		$('div#loader').hide();

		$('a.table-finder-info-close').click(function()
		{
			$("#table-finder-info").remove();
			
			if($.browser.msie)
			{
				$('#tablefinder-page #content select').show();
			}

			return false;
		});
	});
	
	return false;
}

function nextPage()
{
	page = parseInt( $("input[@name=page]").val() );
	return showPage( page + 1 );
}

function prevPage()
{
	page = parseInt( $("input[@name=page]").val() );
	return showPage( page - 1 );	
}

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY;

// Variables to hold mouse x-y pos.s
var mouseX = 0
var mouseY = 0
document.onmousemove = getMouseXY;
// Main function to retrieve mouse x-y pos.s

function getMouseXY(e)
{
  if( IE && document.documentElement && document.documentElement.scrollTop ) // Explorer 6 Strict
  {
    mouseX = event.clientX + document.documentElement.scrollLeft;
    mouseY = event.clientY + document.documentElement.scrollTop;
  }
  else if( IE ) // grab the x-y pos.s if browser is IE
  {
    mouseX = event.clientX + document.body.scrollLeft;
    mouseY = event.clientY + document.body.scrollTop;
  }
  else  // grab the x-y pos.s if browser is NS
  {
  	mouseX = e.pageX;
    mouseY = e.pageY;
  }
  // catch possible negative values in NS4
  if (mouseX < 0){mouseX = 0;}
  if (mouseY < 0){mouseY = 0;}

  return true;
}function calcage(secs, num1, num2)
{
	s = ((Math.floor(secs/num1))%num2).toString();
	
	if(s.length < 2)
	{
		s = "0" + s;
	}

	return s;
}

// Count down timers in "Live" Top-Lists
function countDown()
{
	var clock_time = new Date();
	var clock_hours = clock_time.getHours();
	var clock_minutes = clock_time.getMinutes();
	var clock_seconds = clock_time.getSeconds();

	var secs = parseInt(clock_hours, 10)*3600 + parseInt(clock_minutes, 10)*60 + parseInt(clock_seconds, 10);

	var hours = calcage(secs, 3600, 365);
	var minutes = calcage(secs, 60, 60);
	var seconds = calcage(secs, 1, 60);

	$(countDownWhere).html(hours +':' +minutes +':' +seconds);
	
	setTimeout("countDown()", 1000);
}var next = 0;
var changer;
var targetBox;

var nextPromo = function(i,obj) {
	
	targetBox = $("#fp-whats-hot").find('p');

	$("#fp-whats-hot").find('ol>li').each(function(j) {

		if ( this == obj )
		{
			next = j;
			i = j;
		} 
		
		if ( i == j ){
			$(this).addClass('sel');
			targetBox.html( $(this).html() );
			targetBox.find('img').show();
		} else {
			$(this).removeClass('sel');
		}
		
		var getId = function() {
			return j;
		}
	})
	
	next++;
	
	if( next > 6 ){
		next = 0;
	}
}

$(document).ready(function() {
	changer = setInterval( 'nextPromo(next)', 2000);
	
	$("#fp-whats-hot").find('p').mouseover(function(i) {
		clearInterval( changer );
    }).mouseout(function(i) {
		changer = setInterval( 'nextPromo(next)', 2000);
	})

	$("#fp-whats-hot").find('ol>li').mouseover(function(i) {
		clearInterval( changer );
		nextPromo( -1, this );
    }).mouseout(function(i) {
		changer = setInterval( 'nextPromo(next)', 2000);
	})
});$(document).ready(function() {
	
	var re = /([_\-\w]+$)/i;
	
	// Choose all .flaps exept the one with id #review-flaps
	$('ul.flaps').not('#review-flaps').each(function() {
		
		var container = this;

		var activateTab = function(clear,targetTab) {

			$(container).find('li a').each(function(i) {

				thisTab = re.exec(this.href)[1];

				var contentDiv = $('#' + thisTab );
			
				if( thisTab == targetTab || ( i==0 && clear == false ) ){
					firstParent = this.parentNode;
					$(firstParent.parentNode).addClass('sel');
					contentDiv.removeClass('hideContent');
				}else{
					firstParent = this.parentNode;
					$(firstParent.parentNode).removeClass('sel');
					contentDiv.addClass('hideContent');
				}
			
	        });
		}
		
		activateTab(false,false);
		
		$(this).find('li a').click(function(i) {
			
			activateTab(true,re.exec(this.href)[1]);

			return false;
			
		})
	})
});


$(document).ready(function() {
	toggleSpecificTabs('ul.n-flaps, ul.arrow-flaps, ul.n-s-flaps, ul.il-flaps')
});



function toggleSpecificTabs(tabString) {
	var re = /([_\-\w]+$)/i;
	
	$(tabString).each(function() {
		
		var container = this;

		var activateTab = function(clear,targetTab) {

			$(container).find('li a').each(function(i) {

				thisTab = re.exec(this.href)[1];
				
				var contentDiv = $('#' + thisTab );
			
				if( thisTab == targetTab || ( i==0 && clear == false ) ){
					firstParent = this.parentNode;
					$(firstParent).addClass('tabs-selected');
					contentDiv.removeClass('tabs-hide');
				}else{
					firstParent = this.parentNode;
					$(firstParent).removeClass('tabs-selected');
					contentDiv.addClass('tabs-hide');
				}
			
	        });
		}
		
		activateTab(false,false);
		
		$(this).find('li a').click(function(i) {
			
			activateTab(true,re.exec(this.href)[1]);

			return false;
			
		})
	})

}


// feature to toggle to a specific tab vi aa url call
// http://www.pokerlsitings/market-pulse/biggest-pots#tab_2
function evaluateTabRequest()
{
	var url = location.href;
	var fragment = url.split('#');
	if (fragment[1])
	{
		if (fragment[1].indexOf('tab_') != -1)
		{
			var tabIndex = fragment[1].replace('tab_', '');
			return parseInt(tabIndex);
		}
	}
	return false;
}

function displaySelectedTab ( selectedTab )
{
	$('.n-s-flaps > li').each(function(){ 
		$(this).removeClass();
	});
	$( "#" + selectedTab ).addClass("tabs-selected");
	
}



