function display(div)
{
  var display	=	 $('#'+div).css('display');
 // alert(display);
  if(display=="none")
	$('#moregamesDiv').show('slow');
  else
  {  
	$("#moregamesDiv").hide("slow");
  }	
}function ajaxLogin(baseUrl)
{
	$j('#loginBox').hide();
	$j('#loginLoader').show();
	$j.ajax({
			type	 : 'POST',
			url		 : baseUrl+"login.php",
			data	 : ({userName :$j('#userName').val(),password :$j('#userPassword').val()}),
			success  : function(response)
			{
				$j('#loginBox').show();
				$j('#loginLoader').hide();
				if(response==0)
				{
					response="Invalid Login"	;
					$j('#msg').html(response);
				}	
				else
				{
					$j('#loginBox').hide();
					window.location.reload();
				}
			}
		});
}
function toggleDisplay(divId)
{
$j('#'+divId).slideToggle("slow");	
}

function toggleDiv(divId)
{
	if(document.getElementById(divId).style.display=="none")
	{
		$j('#'+divId).show("slow");	
	}
	else
	{
		$j('#'+divId).hide().fadeOut();	
	}	
}
function gameSearch(baseUrl)
{
	$searchKey	= $j('#searchKey').val();
	//alert($searchKey);
	$j.ajax({
			type	 : 'POST',
			url		 : baseUrl+"gamesearch.php",
			data	 : ({searchKey :$searchKey}),
			success  : function(response)
			{
				//alert($j('#searchResult'));
				$j('#searchResult').html(response);
				$j('#searchResult').show("slow");	
			}
		});
	
}
function hideDisplay(divId)
{
	$j('#'+divId).hide("slow");	
}
/*admin side js*/
function listGame(baseUrl,page)
{
	var categoryId	=	$j('#selCategory').val();
	var searchKey	=	$j('#adminGameSearch').val();
	var gameActive	=	$j('#selGameActive').val();
	$j('#hid_page').val(page);
	$j.ajax({
		type: "GET",
		url: baseUrl+"/admin/loadgame.php?offset="+page+"&searchKey="+searchKey+"&categoryId="+categoryId+"&gameActive="+gameActive,
		success: function(response)
			{
			//alert(response);	
			$j("#div_game").html(response);
			}
		});

	return false;
}
function listUsers(baseUrl,page,user)
{
	//	alert(baseUrl);
	$j('#hid_page').val(page);
	$j('#hid_user').val(user);
	var sort_field	=	$j('#hid_field').val();
	var sort_order	=	$j('#hid_order').val();
	var search_key	=	$j('#search_key').val();
	var search_date	=	$j('#datepicker').val();
	$j("#div_users").html("Loading..............");
	$j.ajax({
	type: "GET",
	url: baseUrl+"admin/loadusers.php?offset="+page+"&user="+user+"&usertype=normaluser&search_key="+search_key+"&search_date="+search_date+"&sort_field="+sort_field+"&sort_order="+sort_order,
	success: function(response)
		{
			//alert(response);
			$j("#div_users").html(response);
		}
	});
		return false;
}
function listBetaUsers(baseUrl,page)
{
	
	$j('#hid_page').val(page);
	$j("#div_users").html("Loading..............");
	var search_key	=	$j('#search_key').val();
	var search_date	=	$j('#datepicker').val();
	$j.ajax({
		type: "GET",
		url: baseUrl+"admin/loadbetausers.php?offset="+page+"&search_key="+search_key+"&search_date="+search_date,
		success: function(response)
			{				
				$j("#div_users").html(response);
			}
		});
	return false;
}

function deleteBetaUser(baseUrl,id)
{
	$j.ajax({
		type: "GET",
		url: baseUrl+"admin/deletebetauser.php?betaid="+id,
		success: function(response)
			{
				 listBetaUsers(baseUrl,$j('#hid_page').val());
			}
		});
	return false;
}

function addBetaUsers(baseUrl,page)
{
	$j('#hid_page').val(page);
	/*$j('#hid_user').val(user);*/
	var search_key	=	$j('#search_key').val();
	var search_date	=	$j('#datepicker').val();
	$j("#div_users").html("Loading..............");
	//alert(baseUrl+"admin/loadallusers.php?offset="+page+"&usertype=betauser&search_key="+search_key+"&search_date="+search_date);
	$j.ajax({
		type: "GET",
		url: baseUrl+"admin/loadallusers.php?offset="+page+"&usertype=betauser&search_key="+search_key+"&search_date="+search_date,
		success: function(response)
			{
				$j("#div_users").html(response);
			}
		});
	return false;
}
function gameDelete(gameId,baseUrl)
{
	if(confirm("Do you realy wants to delete ?"))
		{
		$j.ajax({
		type: "GET",
		url: "/admin/deletegame.php?gameId="+gameId,
		success: function(response)
			{
					alert("Game Deleted");
					listGame(baseUrl,$j('#hid_page').val());
			}
		});
	}
	return false;
}
function gameAction(baseUrl,gameId,gameStatus)
{
		$j.ajax({
		type: "GET",
		url: "/admin/updategamestatus.php?gameId="+gameId+"&gameStatus="+gameStatus,
		success: function(response)
			{
					alert("Game Status Changed");
					listGame(baseUrl,$j('#hid_page').val());
			}
		});
	return false;
}
/*admin side js ends*/

