function get_check()
{
	return '<img src="'+static_url+'/images/check.gif" width="24" height="24" border="0" />';
}

function get_ajax_loader()
{
	return '<img src="'+static_url+'/images/ajax_loader.gif" width="24" height="24" border="0" />';	
}

function get_ajax_loader_big()
{
	return '<img src="'+static_url+'/images/ajax_loader_big.gif" width="66" height="66" border="0" />';	
}

function get_ajax_loader_small()
{
	return '<img src="'+static_url+'/images/ajax_loader_16x16.gif" width="16" height="16" border="0" />';	
}

function get_ajax_loader_bar()
{
	return '<img src="'+static_url+'/images/ajax_loader_bar.gif" width="220" height="19" border="0" />';	
}

function ob_e(d, n, m)
{
	var mt = '';
	if (m === true)
	{
		var s1 = 'i'; var s2 = 'o'; var s3 = 'a'; var s4 = 'm'; var s5 = 'l'; var s6 = 't';
		mt = s4+s3+s1+s5+s6+s2+':';
	}
	return(mt+n+'@'+d.replace(/%2A/g, '.'));
}

function populate(type, page, rpp)
{
	$('#ajax_loader_bar').remove();
	$('#'+type+'_games_outer').prepend('<div id="ajax_loader_bar">'+get_ajax_loader_bar()+'</div>');
	$('#'+type+'_games').fadeTo('fast', .5);

	var data = 'type='+type+'&page='+page+'&rpp='+rpp;
	if (typeof(owner_user_id) != 'undefined')
		data+= '&owner_user_id='+owner_user_id;

	$.ajax({
		url: '/api/post/games/get_games',
		type: 'POST',
		data: data,		
		dataType: 'json',
		cache: false,
		success: function (json) {
			if (json.html)
			{
				$('#'+type+'_games').html(json.html+'<div class="clear"></div>');
			}
			else if ((typeof(json.errors) == 'object') && (json.errors.length > 0))
			{
				var errors = '';
				for (var i = 0; i < json.errors.length; i++)
					errors+= json.errors[i]+"\n"; 
				alert(errors);
			}
			// no html and no errors, which means no results were 
			// returned for the requested parameters (page / rpp).
			else
			{
				eval('max_'+type+'_games_page = '+(page - 1));
				eval(type+'_games_page = '+(page - 1));
			}
		},
		// typically only one of textStatus or errorThrown will have info
		error: function (XMLHttpRequest, textStatus, errorThrown) {
			if (textStatus)
				alert(textStatus);
			if (errorThrown)
				alert(errorThrown);
			
			// ie 7 and 8 drop the windows Cleartype rendering when opacity is modified. so in 
			// order to avoid very ugly text, we have to remove the filter attribute entirely.
			if (!jQuery.browser.msie)
				$('#'+type+'_games').fadeTo('slow', 1);
			else
				$('#'+type+'_games').get(0).style.removeAttribute('filter');
			$('#ajax_loader_bar').fadeOut('fast');
			$('#ajax_loader_bar').remove();
		},
		complete: function (XMLHttpRequest, textStatus) {
			// ie 7 and 8 drop the windows Cleartype rendering when opacity is modified. so in 
			// order to avoid very ugly text, we have to remove the filter attribute entirely.
			if (!jQuery.browser.msie)
				$('#'+type+'_games').fadeTo('slow', 1);
			else
				$('#'+type+'_games').get(0).style.removeAttribute('filter');
			$('#ajax_loader_bar').fadeOut('fast');
			$('#ajax_loader_bar').remove();
		}
	});
}

$(document).ready(function() {

	$('#header-login-username-clear').show();
	$('#header-login-username').hide();
	
	$('#header-login-username-clear').focus(function() {
		$('#header-login-username-clear').hide();
		$('#header-login-username').show();
		$('#header-login-username').focus();
	});
	$('#header-login-username').blur(function() {
		if($('#header-login-username').val() == '') {
			$('#header-login-username-clear').show();
			$('#header-login-username').hide();
		}
	});

	$('#header-login-password-clear').show();
	$('#header-login-password').hide();
	
	$('#header-login-password-clear').focus(function() {
		$('#header-login-password-clear').hide();
		$('#header-login-password').show();
		$('#header-login-password').focus();
	});
	$('#header-login-password').blur(function() {
		if($('#header-login-password').val() == '') {
			$('#header-login-password-clear').show();
			$('#header-login-password').hide();
		}
	});

});
