function loginSubmit(login, uc)
{
	var username = login.elements['username'];
	var password = login.elements['password'];
    if(!loginCheck(login)) return false;
	if(uc == 1) return true;
	$.post(login.action, 'action=ajax&username='+username.value+'&password='+password.value, function(data){
		if(data == 1)
		{
			$('#logined_username').html(username.value);
			$('#div_login').hide();
			$('#div_logined').show();
		}
		else
		{
			alert('登录失败');
			redirect(login.action);
		}
		username.value = password.value = '';
	});
	return false;
}

function logout(url)
{
	$.get(url+'&id='+Math.random()*5, function(data){
		if(data != 1) alert(data);
	});
	$('#div_logined').hide();
	$('#div_login').show();
}

function loginshow()
{

	var auth = getCookie('auth');
	var username = getCookie('username');

	if(auth != null && username != null && username !='')
	{
		$('#logined_username').html(unescape(getCookie('username')));
		$('#div_login').hide();
		$('#div_logined').show();
	}
	else
	{
		$('#div_logined').hide();
		$('#div_login').show();
	}
}
function loginshowa()
{

	var auth = getCookie('auth');
	var username = getCookie('username');

	if(auth != null && username != null && username !='')
	{
		$('#logined_username').html(unescape(getCookie('username')));
		$('#div_logina').hide();
		$('#div_logineda').show();
	}
	else
	{
		$('#div_logineda').hide();
		$('#div_logina').show();
	}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return null;
}