function jqTableResize(cls)
{
    var largest = 0;
    $('table.' + cls).each(function() {
        var width = $(this)[0].offsetWidth;
        if(width > largest) {
            largest = width;
        }
    }).width(largest);
};
function jqCheckAll(id, pid)
{
	$( "#" + pid + " :checkbox").attr('checked', $('#' + id).is(':checked'));
};

function jqUnCheck(id)
{
	$( "#" + id + "_all").attr('checked', false);
};


function jListedAction()
{	
    $('.xxP').each(function() {
		var $this = $(this);
		var n = $this.attr("id").slice(3);
		//alert(n);

		// show any actions - this is for back button otherwise stays on listed
		//if($("#xxP"+n).val()=="N")
		if ($this.val()=="N")
		{
			$("#zz"+n).html(" Action");
			$("#zz"+n).attr("title","Click to switch this team from action to listed pitcher required.");
			//alert("#zz"+n + "=" + $("#zz"+n).html());
		}

    });

	$(".listed_action").click(function(){

	var $this = $(this);
	var n = $this.attr("id").slice(2);
	//alert(n);

	if($("#xxP"+n).val()=="Y")
	{
		$this.html(" Action");
		$this.attr("title","Click to switch this team from action to listed pitcher required.");
		$("#xxP"+n).val("N");
		//alert($("#P"+n).attr("name"));
	}
	else 
	{
		$this.html(" Listed");
		$this.attr("title","Click to switch this pitcher from required to action.");
		$("#xxP"+n).val("Y");
	}
	//var x = $this.attr("id");
	//$("#hdn" + x).val(0);
	//alert('fuck=' + $this.attr("name"));
	return false;

	});
};

function jMenuTips()
{
	$('body').click(function() { $(document).trigger('hideCluetip');});

  $('a.mnuCasinoTip').cluetip({
    cluetipClass: 'jtip', 
  	width: '180px', 
    sticky: true,
	activation: 'click',
  	showTitle: false,
	local:true, 
	hideLocal:true,
	positionBy:       'fixed',   // Sets the type of positioning. more info below [2]
    topOffset:        25,       // Number of px to offset clueTip from top of invoking element. more info below [3]
    leftOffset:       -50,       // Number of px to offset clueTip from left of invoking element. more info below [4]
    closePosition: 'bottom',
	closeText: '',
	cursor: 'hand'

  });
  $('a.mnuPokerTip').cluetip({
    cluetipClass: 'jtip', 
  	width: '105px', 
    sticky: true,
	activation: 'click',
  	showTitle: false,
	local:true, 
	hideLocal:true,
	positionBy:       'fixed',   // Sets the type of positioning. more info below [2]
    topOffset:        25,       // Number of px to offset clueTip from top of invoking element. more info below [3]
    leftOffset:       -45,       // Number of px to offset clueTip from left of invoking element. more info below [4]
    closePosition: 'bottom',
	closeText: '',
	cursor: 'hand'

  });

  $('a.mnuAccountTip').cluetip({
    cluetipClass: 'jtip', 
  	width: '120px', 
    sticky: true,
	activation: 'click',
  	showTitle: false,
	local:true, 
	hideLocal:true,
	positionBy:       'fixed',   // Sets the type of positioning. more info below [2]
    topOffset:        25,       // Number of px to offset clueTip from top of invoking element. more info below [3]
    leftOffset:       -55,       // Number of px to offset clueTip from left of invoking element. more info below [4]
    closePosition: 'bottom',
	closeText: '' ,
	cursor: 'hand'

  });

  $('a.BalanceTip').cluetip({
    cluetipClass: 'jtip', 
  	width: '230px',sticky: true, 
	local: true, hideLocal: true,
	hideLocal:true,
	closePosition:    'bottom',    // location of close text for sticky cluetips; can be 'top' or 'bottom' or 'title'
//    closeText:        '<img src="jq/cross.png" alt="" />',  
    closeText:        '',  
	positionBy:       'fixed',   // Sets the type of positioning. more info below [2]
    topOffset:        30,       // Number of px to offset clueTip from top of invoking element. more info below [3]
    leftOffset:       -230,       // Number of px to offset clueTip from left of invoking element. more info below [4]
	showTitle: false,
  	hoverIntent: true,
  	activation: 'click',
	titleAttribute: '',
	cursor: 'hand'
  });

  $('a.mnuHelpTip').cluetip({
    cluetipClass: 'jtip', 
  	width: '100px', 
    sticky: true,
	activation: 'click',
  	showTitle: false,
	local:true, 
	hideLocal:true,
	positionBy:       'fixed',   // Sets the type of positioning. more info below [2]
    topOffset:        30,       // Number of px to offset clueTip from top of invoking element. more info below [3]
    leftOffset:       -105,       // Number of px to offset clueTip from left of invoking element. more info below [4]
    closePosition: 'bottom',
	closeText: '',
	cursor: 'hand'

  });
  $('a.mnuLineTypeTip').cluetip({
    cluetipClass: 'jtip', 
  	width: '100px', 
    sticky: true,
	activation: 'click',
  	showTitle: false,
	local:true, 
	hideLocal:true,
	positionBy:       'fixed',   // Sets the type of positioning. more info below [2]
    topOffset:        30,       // Number of px to offset clueTip from top of invoking element. more info below [3]
    leftOffset:       -100,       // Number of px to offset clueTip from left of invoking element. more info below [4]
	titleAttribute: '',
    closePosition: 'bottom',
	closeText: '',
	cursor: 'hand'

  });
  $('a.mnuAltLinesTip').cluetip({
    cluetipClass: 'jtip', 
  	width: '100px', 
    sticky: true,
	activation: 'click',
  	showTitle: false,
	local:true, 
	hideLocal:true,
	positionBy:       'fixed',   // Sets the type of positioning. more info below [2]
    topOffset:        30,       // Number of px to offset clueTip from top of invoking element. more info below [3]
    leftOffset:       -70,       // Number of px to offset clueTip from left of invoking element. more info below [4]
	titleAttribute: '',
    closePosition: 'bottom',
	closeText: '',
	cursor: 'hand'

  });
  $('a.mnuCashierTip').cluetip({
    cluetipClass: 'jtip', 
  	width: '160px', 
    sticky: true,
	activation: 'click',
  	showTitle: false,
	local:true, 
	hideLocal:true,
	positionBy:       'fixed',   // Sets the type of positioning. more info below [2]
    topOffset:        25,       // Number of px to offset clueTip from top of invoking element. more info below [3]
    leftOffset:       -50,       // Number of px to offset clueTip from left of invoking element. more info below [4]
    closePosition: 'bottom',
	closeText: '',
	cursor: 'hand'
  });
};


function jqKeepAlive()
{
	$(document).timedLogout({
		     //inactivity:   5000, 
     		 //noconfirm:    20000, 
		     inactivity:   1020000, 
     		 noconfirm:     120000, 
			 sessionAlive: 600000,
			 alive_url:'olah.asp',
			 redirect_url: 'sessionexpired.asp'
		   });
};
function jqAutoLogout()
{
	$(document).timedLogout({
		     //inactivity:   5000, 
     		 //noconfirm:    20000, 
		     inactivity:   1020000, 
     		 noconfirm:     120000, 
     		 sessionAlive: false,
			 alive_url:'olah.asp',
			 redirect_url: 'sessionexpired.asp'
		   });
};

function rifRemove()
{
	$("#rifselection").html("").hide();
	$("#rifIdx").val("");
	$("#rifTik").val("");
	$("#fpSpan").show();
	$("#RoundRobinSelect").show();
	

};

function jqRifBox()

{

	var $loading = $('<img src="jq/images/loading.gif" alt="loading" class="loading">');




	$('#rifButton').each(function() 
	{
		var $link = $(this);	
		
		$("#rifselection").hide();

			var $dialog = $("#rifDialog");


			var dialogOpts = 
			{
					autoOpen: false,
					title: $link.attr('title'),
					width: 800,
					height: 300,
					modal:true,
					show:false,
					hide:true,
				
					close: function() 
					{
					  	 //alert('closing dialog');
					},

					open: function() 
					{
						$(this).empty();
						$(this).append($loading.clone());
						$(this).load('rifbox.asp'  + "?" + 1*new Date());	
						
						$(".rifRadio").live('click', function() 
						{
							$("#rifIdx").val($(this).val());
							$("#rifselection").html("");
							var rifName = $(this).val();

							$("#rifTik").val($("#" + rifName).val());
							if (rifName.substring(0,5)=="RifWP") 
								$("#rifselection").append( "Win or Push " + $("#" + rifName).val());
							else
								$("#rifselection").append( "Win Only " + $("#" + rifName).val());
							$("#rifselection").append('<a href="#"><img id="rifRemove" alt="Remove this Rolling If Bet." title="Remove this Rolling If Bet." src="jq/images/delete.png" border="0"></a>').show();
							$("#rifRemove").click(function() {
	                			rifRemove();
	            			});
							var rifAmt = $("#Amt" + rifName).val();
							if ($("#wagerAmt").val()=="" || Number($("#wagerAmt").val()) > rifAmt)
							{
								$("#wagerAmt").val(Number(rifAmt).toFixed(2));
								$("#rbRisk").attr('checked', true);
					  		}
							$("#fpCheckBox").attr('checked', false);
							$("#fpSpan").hide();
							$("#RoundRobinSelect").val(0).hide();
							
					  		$dialog.dialog("close");
							return false;
	        			});
					}

			};
			$dialog.dialog(dialogOpts);

			//for back button
			if ( $("#rifIdx").val() != "")
			{
				rifCellShow();
			}


			$link.click(function() {
				$dialog.dialog('open');
				return false;
			});


	});

};


function rifCellShow()
{
	var rifName = $("#rifIdx").val();
	if (rifName.substring(0,5)=="RifWP") 
		$("#rifselection").append( "Win or Push " + $("#rifTik").val());
	else
		$("#rifselection").append( "Win Only " + $("#rifTik").val());
	$("#rifselection").append('<a href="#"><img id="rifRemove" alt="Remove this Rolling If Bet." title="Remove this Rolling If Bet." src="jq/images/delete.png" border="0"></a>').show();
	$("#rifRemove").click(function() {
    	rifRemove();
    });
	$("#fpCheckBox").attr('checked', false);
	$("#fpSpan").hide();
	$("#RoundRobinSelect").val(0).hide();
}

function jqRifToggle()
{
	$(".rifChain").hide();
	$(".rifToggle").click(function(){
	var id = $(this).attr('href');
	$("#"+id).slideToggle(500);
	return false;
	});
};


function jErrorCheck()
{
	$("#errorBox").load("ErrorBox.asp" + "?" + 1*new Date());
	if ($("#errorBox").length > 0)
	{
		$("#errorBox").show();
		$("#readingPaneContainer").scrollTop(0); 
	}
	else
		$("#errorBox").hide();

};

