var userID	= 0;
$(document).ready(function(){
	
})

function closeMessageAlert()
{
	$.post(AJAXURL,{
		act			: 'close_message_alert'
	},function(rs) {
		$(document).trigger('close.facebox');
	},'json');
}

function delMessage(id)
{
	if ( confirm("Are you sure you want to remove this message?") )
	{
		$.post(AJAXURL,{
			act			: 'remove_message',
			id			: id
		},function(rs) {
			if ( rs.status == 1 ) {
				$('#pm_'+id).fadeOut();
			} else {
				alert(rs.resp);
			}
		},'json');
	}
}

function postMsg(el)
{
	$subject	= $('[name=pm_subject]').val();
	$message	= $('[name=pm_content]').val();
	if ( $subject == '' ) {
		alert('Please enter a subject for this message');
	} else {
		$(el).attr('disabled',true);
		if ( $('#post_msg').length ) {
			$("#post_msg").text('Saving message...').show();
		} else {
			$(el).after('<span id="post_msg">Saving message...</span>');
		}
		$.post(AJAXURL,{
			act			: 'post_message',
			subject		: $subject,
			message		: $message
		},function(rs) {
			if ( rs.status == 1 ) {
				var $html	= '<tr id="pm_'+rs.pm.id+'">';
				$html	+= '<td><strong>'+rs.pm.subject+'</strong><div id="content_pm_'+rs.pm.id+'" style="margin-top:10px;font-size:.9em;background:#FDFFC4;padding:10px 5px 1px;display:none;">'+rs.pm.message+'</div></td>';
				$html	+= '<td class="txtcenter" valign="top">'+rs.pm.posted_time+'</td>';
				$html	+= '<td class="txtcenter" valign="top"><a href="javascript:{}" onclick="$(\'#content_pm_'+rs.pm.id+'\').toggle()">view</a> | <a href="javascript:{}" onclick="delMessage('+rs.pm.id+')">delete</a></td>';
				$html	+= '</tr>';
				$('[name=pm_subject]').val('');
				$('[name=pm_content]').val('');
				$(el).attr('disabled',false);
				$('#post_msg').text("Message posted.");
				setTimeout('$("#post_msg").fadeOut()',500);
				$('#msglist').prepend($html);
			}
		},'json');
	}
}

function resetBorrowed(id,el)
{
	if ( confirm("Are you sure you want to reset borrowed credit of this player?") ) {
		$wrap	= $(el).parent();
		$wrap.html('loading...');
		$.post(AJAXURL,{
			act		: 'reset_borrowed',
			id		: id
		},function(rs) {
			if ( rs.status == 1 ) {
				$('#borrowed_credit_'+id).html("0");
			}
			$wrap.html('<a href="javascript:void(0)" onclick="resetBorrowed('+id+',this)">reset</a>');
		},'json');
	}
}

function updateMaxAtmCredit(el,id)
{
	$('#max_atm_credit_msg_'+id).html("saving...").show();
	$.post(AJAXURL,{
		act		: 'update_max_atm_credit',
		id		: id,
		val		: el.value
	},function(rs) {
		if ( rs.status == 1 ) {
			$('#max_atm_credit_msg_'+id).html("saved");
			$(el).val(rs.resp);
		} else {
			$('#max_atm_credit_msg_'+id).html(rs.resp);
		}
		setTimeout('$("#max_atm_credit_msg_'+id+'").fadeOut()',500);
	},'json');
}

function openCashoutWindow(bid)
{
	userID		= bid;
	$.facebox(function(){
		$.post(AJAXURL,{
			act		: 'get_my_player_data',
			bid		: bid
		},function(rs) {
			if ( rs.status == 1 ) {
				var html		= '<table class="playerinfor">';
				html			+= '<tr>';
				html			+= '	<td class="lb">Room:</td>';
				html			+= '	<td>'+rs.username+'\'s poker room</td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td rowspan="2" class="lb">Cash Out:</td>';
				html			+= '	<td class="nob"><label><input type="radio" checked="checked" onclick="changeCashoutOption()" name="co_type" value="all"/> Available amount: '+rs.onsite_credit_style+' credit(s)</label><input type="hidden" name="available_amount" value="'+rs.onsite_credit+'" /></td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td><label><input type="radio" name="co_type" onclick="changeCashoutOption()" value="no_all"/> Other amount:</label> <input type="text" name="amount" size="5" disabled="disabled" class="txtright" /> credit(s)</td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td class="nob"></td>';
				html			+= '	<td class="nob"><a href="javascript:void(0);" onclick="submitCashout()"><img src="'+BASEURL+'front/images/btn-submit.png" alt="Submit" /></a> <a href="javascript:void(0)" onclick="$(document).trigger(\'close.facebox\')"> <img src="'+BASEURL+'front/images/btn-close.png" title="close" /></a></td>';
				html			+= '</tr>';
				html			+= '</table>';
				$.facebox(html);
			} else {
				alert(rs.resp);
			}
		},'json')
	});
}

function changeCashoutOption()
{
	if ( $(':radio[name=co_type]:checked').val() == 'all' ) {
		$(':input[name=amount]').attr('disabled',true);
	} else if ( $(':radio[name=co_type]:checked').val() == 'no_all' ) {
		$(':input[name=amount]').attr('disabled',false).focus();
	}
}

function submitCashout()
{
	var amount		= 0;
	if ( $(':radio[name=co_type]:checked').val() == 'all' ) {
		amount			= $(':input[name=available_amount]').val();
	} else if ( $(':radio[name=co_type]:checked').val() == 'no_all' ) {
		if ( !isInt($(':input[name=amount]').val()) ) {
			alert('Please enter a valid number of cashout amount.');
			return;
		} else if ($(':input[name=amount]').val() > $(':input[name=available_amount]').val()) {
			alert('You do not have sufficient credits to make a cashout request.');
			return;
		} else {
			amount		= $(':input[name=amount]').val();
		}
	} else {
		alert('Please choose the cashout type.');
		return;
	}
	$('#facebox .body').children().hide().end().
  	append('<div class="loading"><img src="'+$.facebox.settings.loading_image+'"/></div>');
	$.post(AJAXURL,{
		act		: 'request_cashout',
		bid		: userID,
		amount	: amount
	},function(rs) {
		if ( rs.status == 1 ) {
			alert("Your request has been sent out to the room owner.");
			$(document).trigger('close.facebox');
//			$('#my_onsite_credit').html(rs.new_bookie_credit);
			$('#onsite_credit_'+userID).html(''+rs.new_onsite_credit);
		} else {
			$('#facebox .body').html('<div class="content"><div class="msg">'+rs.resp+'</div><div class="txtcenter"><a href="javascript:void(0)" onclick="$(document).trigger(\'close.facebox\')"><img src="'+BASEURL+'front/images/btn-close.png" title="close" /></a></div></div>');
		}
	},'json');
}

function processPlayerRequest(pid,type)
{
	if ( !$('#loading').length ) {
		$('body').append('<div class="ajaxloading" id="loading"></div>');
	}
	$('#loading').html('Updating...').css('top','0px').show();
	$.post(AJAXURL,{
		act			: 'process_player_request',
		pid			: pid,
		type		: type
	},function(rs){
		$('#loading').fadeOut('normal',function(){
			if ( rs.status == 1 ) {
				$('#total_pending').html(''+rs.total_pending+'');
				$('#total_approved').html(''+rs.total_approved+'');
				$('#total_refused').html(''+rs.total_refused+'');
				if ( type == 'accept' ) {
					$('#my_onsite_credit').html(rs.new_bookie_credit);
				}
				$('#player_'+pid).fadeOut();
			} else {
				alert(rs.resp);
			}
		});
	},'json')
}

function processCashout(id,type)
{
	if ( !$('#loading').length ) {
		$('body').append('<div class="ajaxloading" id="loading"></div>');
	}
	$('#loading').html('Processing...').css('top','0px').show();
	$.post(AJAXURL,{
		act			: 'process_cashout_request',
		rid			: id,
		type		: type
	},function(rs){
		$('#loading').fadeOut('normal',function(){
			if ( rs.status == 1 ) {
				$('#request_'+id+'').fadeOut();
				$('#cashout_requests').prepend(''+rs.resp);
			} else {
				alert(rs.resp);
			}
		});
	},'json')
}

function removePlayer(pid)
{
	if ( confirm("Are you sure you want to remove this player from the room?") ) {
		if ( !$('#loading').length ) {
			$('body').append('<div class="ajaxloading" id="loading"></div>');
		}
		$('#loading').html('Removing...').css('top','0px').show();
		$.post(AJAXURL,{
			act			: 'remove_player',
			pid			: pid
		},function(rs){
			$('#loading').fadeOut('normal',function(){
				if ( rs.status == 1 ) {
					$('#total_approved').html(''+rs.total_approved+'');
					$('#player_'+pid).fadeOut();
				} else {
					alert(rs.resp);
				}
			});
		},'json')
	}
}

function openCreditWindow(pid)
{
	userID		= pid;
	$.facebox(function(){
		$.post(AJAXURL,{
			act		: 'get_player_data',
			pid		: pid
		},function(rs) {
			if ( rs.status == 1 ) {
				var html		= '<table class="playerinfor">';
				html			+= '<tr>';
				html			+= '	<td rowspan="6" class="nob" width="48" valign="top"><img src="'+rs.avatar_url+'" /></td>';
				html			+= '	<td class="lb" width="110">Player:</td>';
				html			+= '	<td>'+rs.username+'</td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td class="lb">Bankroll:</td>';
				html			+= '	<td>'+rs.onsite_credit+'</td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td class="lb">Poker credit:</td>';
				html			+= '	<td>'+rs.ondesk_credit+'</td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td class="lb">Add or Substract:</td>';
				html			+= '	<td><label><input type="radio" checked="checked" name="add_or_substract" value="add" /> Add</label> <label><input type="radio" name="add_or_substract" value="substract" /> Substract</label></td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td class="lb">Amount of credits:</td>';
				html			+= '	<td><input type="text" name="no_credit" class="txt" size="5" /></td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td class="nob"></td>';
				html			+= '	<td class="nob"><a href="javascript:void(0);" onclick="submitCredit()"><img src="'+BASEURL+'front/images/btn-submit.png" alt="Submit" /></a> <a href="javascript:void(0)" onclick="$(document).trigger(\'close.facebox\')"><img src="'+BASEURL+'front/images/btn-close.png" title="close" /></a></td>';
				html			+= '</tr>';
				html			+= '</table>';
				$.facebox(html);
			} else {
				alert(rs.resp);
			}
		},'json')
	});
}

function isInt( strValue ) {
	var objRegExp  = /(^\d\d*$)/;
	return objRegExp.test(strValue);
}

function submitCredit()
{
	var nocredit	= $(':input[name=no_credit]').val();
	var type		= $(':radio[name=add_or_substract]:checked').val();
	if ( nocredit == '' ) {
		alert('Please enter Amount of credits.');
	} else if ( !isInt(nocredit) ) {
		alert('Invalid Amount of credits.');
	} else if ( type != 'add' && type != 'substract' ) {
		alert('Please chose Add or Substract.');
	} else {
		$('#facebox .body').children().hide().end().
      	append('<div class="loading"><img src="'+$.facebox.settings.loading_image+'"/></div>');
		$.post(AJAXURL,{
			act		: 'submit_credit',
			pid		: userID,
			type	: type,
			credit	: nocredit
		},function(rs) {
			if ( rs.status == 1 ) {
				$(document).trigger('close.facebox');
				$('#my_onsite_credit').html(rs.new_bookie_credit);
				$('#credit_player_'+userID).html(rs.new_player_credit);
			} else {
				$('#facebox .body').html('<div class="content"><div class="msg">'+rs.resp+'</div><div class="txtcenter"><a href="javascript:void(0)" onclick="$(document).trigger(\'close.facebox\')"><img src="'+BASEURL+'front/images/btn-close.png" title="close" /></a></div></div>');
			}
		},'json');
	}
}

function openPlayerTransferCreditWindow(bid)
{
	userID			= bid;
	var html		= '<table class="playerinfor">';
	html			+= '<tr>';
	html			+= '	<td class="lb" width="160">Amount of credits:</td>';
	html			+= '	<td><input type="text" name="no_credit" class="txt" size="5" /></td>';
	html			+= '</tr>';
	html			+= '<tr>';
	html			+= '	<td colspan="2"><label><input type="radio" checked="checked" name="direction" value="todesk" /> From the site to the poker room</label></td>';
	html			+= '</tr>';
	html			+= '<tr>';
	html			+= '	<td colspan="2"><label><input type="radio" name="direction" value="fromdesk" /> From the poker room to the site</label></td>';
	html			+= '</tr>';
	html			+= '<tr>';
	html			+= '	<td class="nob" align="center" colspan="2"><a href="javascript:void(0);" onclick="transferCredit()"><img src="'+BASEURL+'front/images/btn-submit.png" alt="Submit" /></a> <a href="javascript:void(0)" onclick="$(document).trigger(\'close.facebox\')"><img src="'+BASEURL+'front/images/btn-close.png" title="close" /></a></td>';
	html			+= '</tr>';
	html			+= '</table>';
	$.facebox(html);
}

function transferCreditViaFacebookWindow()
{
	var nocredit	= $(':input[name=no_credit]').val();
	var direction	= $(':radio[name=direction]:checked').val();
	if ( nocredit == '' ) {
		alert('Please enter Amount of credits.');
	} else if ( !isInt(nocredit) ) {
		alert('Invalid Amount of credits.');
	} else if ( direction != 'todesk' && direction != 'fromdesk' ) {
		alert('Please chose transfer direction.');
	} else {
		$('#facebox .body').children().hide().end().
      	append('<div class="loading"><img src="'+$.facebox.settings.loading_image+'"/></div>');
		$.post(AJAXURL,{
			act		: 'transfer_credit',
			bid		: userID,
			dir		: direction,
			credit	: nocredit
		},function(rs) {
			if ( rs.status == 1 ) {
				$(document).trigger('close.facebox');
				$('#onsite_credit_'+userID).html(''+rs.onsite_credit);
				$('#ondesk_credit_'+userID).html(''+rs.ondesk_credit);
			} else {
				$('#facebox .body').html('<div class="content"><div class="msg">'+rs.resp+'</div><div class="txtcenter"><a href="javascript:void(0)" onclick="$(document).trigger(\'close.facebox\')"><img src="'+BASEURL+'front/images/btn-close.png" title="close" /></a></div></div>');
			}
		},'json');
	}
}

function transferCredit()
{
	var nocredit	= $(':input[name=no_credit]').val();
	var direction	= $(':radio[name=direction]:checked').val();
	if ( nocredit == '' ) {
		alert('Please enter Amount of credits.');
	} else if ( !isInt(nocredit) ) {
		alert('Invalid Amount of credits.');
	} else if ( direction != 'todesk' && direction != 'fromdesk' ) {
		alert('Please chose transfer direction.');
	} else {
		if ( !$('#loading').length ) {
			$('body').append('<div class="ajaxloading" id="loading"></div>');
		}
		$('#loading').html('Transferring...').css('top','0px').show();
		$.post(AJAXURL,{
			act		: 'transfer_credit',
			bid		: $(':input[name=uid]').val(),
			dir		: direction,
			credit	: nocredit
		},function(rs) {
			if ( rs.status == 1 ) {
				window.opener.updateTransferCredit($(':input[name=uid]').val(),rs);
				window.close();
			} else {
				$('#loading').fadeOut();
				alert(rs.resp);
			}
		},'json');
	}
}

function borrowCredit()
{
	var nocredit	= $(':input[name=no_credit]').val();
	if ( nocredit == '' ) {
		alert('Please enter Amount of credits to borrow.');
	} else if ( !isInt(nocredit) ) {
		alert('Invalid Amount of credits to borrow.');
	} else {
		if ( !$('#loading').length ) {
			$('body').append('<div class="ajaxloading" id="loading"></div>');
		}
		$('#loading').html('Borrowing...').css('top','0px').show();
		$.post(AJAXURL,{
			act		: 'borrow_credit',
			bid		: $(':input[name=uid]').val(),
			credit	: nocredit
		},function(rs) {
			if ( rs.status == 1 ) {
				window.opener.updateBorrowCredit($(':input[name=uid]').val(),rs);
				window.close();
			} else {
				$('#loading').fadeOut();
				alert(rs.resp);
			}
		},'json');
	}
}

function updateBorrowCredit(uid,rs)
{
	$('#onsite_credit_'+uid).html(''+rs.onsite_credit);
	$('#my_onsite_credit').html(''+rs.onsite_credit);
}

function updateTransferCredit(uid,rs)
{
	$('#onsite_credit_'+uid).html(''+rs.onsite_credit);
	$('#ondesk_credit_'+uid).html(''+rs.ondesk_credit);
}

function updateCredit(bid)
{
	$.post(AJAXURL,{
		act		: 'get_ondesk_credit',
		bid		: bid
	},function(rs){
		if ( rs.status == 1 ) {
			$('#ondesk_credit_'+bid).html(rs.ondesk_credit);
			$('#online_players_'+bid).html(rs.online_players);
		}
	},'json');
	var to		= setTimeout('updateCredit('+bid+')',5000);
}

function saveAvatarSelectbox(bid)
{
	if ( !$('#loading').length ) {
		$('body').append('<div class="ajaxloading" id="loading"></div>');
	}
	$('#loading').html('Updating...').css('top','0px').show();
	$.post(AJAXURL,{
		act			: 'save_avatar',
		bid			: bid,
		aid			: $(':input[name=avatar_id]').val()
	},function(rs){
		if ( rs.status == 0 ) {
			alert(rs.resp);
		}
		$('#loading').fadeOut();
	},'json');
}

function saveAvatar(aid)
{
	if ( !$('#loading').length ) {
		$('body').append('<div class="ajaxloading" id="loading"></div>');
	}
	$('#loading').html('Updating...').css('top','0px').show();
	$.post(AJAXURL,{
		act			: 'save_avatar',
		bid			: $(':input[name=uid]').val(),
		aid			: aid
	},function(rs){
		if ( rs.status == 0 ) {
			alert(rs.resp);
			$('#loading').fadeOut();
		} else {
			window.opener.updateChangeAvatar(aid);
			window.close();
		}
	},'json');
}

function pagingHistory(pageno)
{
	if ( !$('#loading').length ) {
		$('body').append('<div class="ajaxloading" id="loading"></div>');
	}
	$('#loading').html('Loading...').css('top','0px').show();
	$.post(AJAXURL,{
		act			: 'paging_credit_history',
		pageno		: pageno
	},function(rs){
		if ( rs.status == 1 ) {
			$('#credit_history_table').replaceWith(rs.resp);
		} else {
			alert(rs.resp);
		}
		$('#loading').fadeOut();
	},'json');
}

function pagingCashoutRequest(pageno)
{
	if ( !$('#loading').length ) {
		$('body').append('<div class="ajaxloading" id="loading"></div>');
	}
	$('#loading').html('Loading...').css('top','0px').show();
	$.post(AJAXURL,{
		act			: 'paging_cashout_request',
		pageno		: pageno
	},function(rs){
		if ( rs.status == 1 ) {
			$('#cashout_requests').html(rs.resp);
		} else {
			alert(rs.resp);
		}
		$('#loading').fadeOut();
	},'json');
}

function buy( no ) {
	$(':input[name=hosted_button_id]').val(no);
	return true;
}
function openTransferCreditWindow(un)
{
	var URL			= SITEURL+"/"+un+"/transfer";
	var name		= "transferwindow";
	var features	= "status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,height=120,width=350";
	window.open(URL,name,features);
}
function openBorrowCreditWindow(un)
{
	var URL			= SITEURL+"/"+un+"/borrow";
	var name		= "borrowwindow";
	var features	= "status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,height=120,width=350";
	window.open(URL,name,features);
}
function openChangeAvatarWindow(un)
{
	var URL			= SITEURL+"/"+un+"/change_avatar";
	var name		= "changeavatarwindow";
	var features	= "status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,height=600,width=600";
	window.open(URL,name,features);
}
function getTournamentList(bid)
{
	$('#tournament_selectbox').next().remove();
	$('#tournament_selectbox').remove();
	if ( !$('#loading').length ) {
		$('body').append('<div class="ajaxloading" id="loading"></div>');
	}
	$('#loading').html('Loading...').css('top','0px').show();
	$.post(AJAXURL,{
		act			: 'get_tournament_list',
		bid		: bid
	},function(rs){
		if ( rs.status == 1 ) {
			
			$('#tournament_selector').append(rs.resp);
		} else {
			alert(rs.resp);
		}
		$('#loading').fadeOut();
	},'json');
}
function getTournamentResult()
{
	var tournamentext	= $(':input[name=tourney]').val();
	if ( tournamentext == '' ) {
		alert('Please select a tournament.');
	} else {
		if ( !$('#loading').length ) {
			$('body').append('<div class="ajaxloading" id="loading"></div>');
		}
		$('#loading').html('Loading...').css('top','0px').show();
		$.post(AJAXURL,{
			act		: 'get_tournament_result',
			bid		: $(':input[name=bookie_id]').val(),
			tourney	: tournamentext
		},function(rs){
			if ( rs.status == 1 ) {
				if ( $('#tournament_result').length ) {
					$('#tournament_result').replaceWith(rs.resp);
				} else {
					$('#tournament_result_table').after(rs.resp);
				}
			} else {
				alert(rs.resp);
			}
			$('#loading').fadeOut();
		},'json');
	}
}

function showPlayerDetail(un)
{
	$.facebox(function(){
		$.post(AJAXURL,{
			act		: 'get_player_data',
			un		: un,
			type	: 'username'
		},function(rs) {
			if ( rs.status == 1 ) {
				var html		= '<table class="playerinfor">';
				html			+= '<tr>';
				html			+= '	<td rowspan="6" class="nob" width="48" valign="top"><img src="'+rs.avatar_url+'" /></td>';
				html			+= '	<td class="lb" width="110">Player:</td>';
				html			+= '	<td>'+rs.username+'</td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td class="lb">Bankroll:</td>';
				html			+= '	<td>'+rs.onsite_credit+'</td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td class="lb">Poker credit:</td>';
				html			+= '	<td>'+rs.ondesk_credit+'</td>';
				html			+= '</tr>';
				html			+= '<tr>';
				html			+= '	<td class="nob"></td>';
				html			+= '	<td class="nob"><a href="javascript:void(0)" onclick="$(document).trigger(\'close.facebox\')"><img src="'+BASEURL+'front/images/btn-close.png" title="close" /></a></td>';
				html			+= '</tr>';
				html			+= '</table>';
				$.facebox(html);
			} else {
				alert(rs.resp);
				$(document).trigger('close.facebox');
			}
		},'json')
	});
}

function addGame()
{
	$(':input[name=act]').val('add');
	return true;
}
function editGame()
{
	var game	= $(':radio[name=name]:checked').val();
	if ( game == undefined ) {
		alert("No games selected.")
		return false;
	} else {
		$(':input[name=act]').val('edit');
		return true;
	}
}
function deleteGame()
{
	var game	= $(':radio[name=name]:checked').val();
	if ( game == undefined ) {
		alert("No games selected.")
		return false;
	} else {
		if ( confirm("Are you sure you want to delete game \""+game+"\"?") ) {
			$(':input[name=act]').val('delete');
			return true;
		} else {
			return false;
		}
	}
}
function putOnline()
{
	var game	= $(':radio[name=name]:checked').val();
	if ( game == undefined ) {
		alert("No games selected.")
		return false;
	} else {
		$(':input[name=act]').val('put_online');
		return true;
	}
}
function takeOfflineNow()
{
	var game	= $(':radio[name=name]:checked').val();
	if ( game == undefined ) {
		alert("No games selected.")
		return false;
	} else {
		$(':input[name=act]').val('take_offline_now');
		return true;
	}
}
function takeOfflineHand()
{
	var game	= $(':radio[name=name]:checked').val();
	if ( game == undefined ) {
		alert("No games selected.")
		return false;
	} else {
		$(':input[name=act]').val('take_offline_hand');
		return true;
	}
}
function pause()
{
	var game	= $(':radio[name=name]:checked').val();
	if ( game == undefined ) {
		alert("No games selected.")
		return false;
	} else {
		$(':input[name=act]').val('pause');
		return true;
	}
}
function resume()
{
	var game	= $(':radio[name=name]:checked').val();
	if ( game == undefined ) {
		alert("No games selected.")
		return false;
	} else {
		$(':input[name=act]').val('resume');
		return true;
	}
}

function setTip(txt)
{
	$('#tip').html('<div>'+txt+'</div>')
}