function loginSubmit(login, uc)
{
var username = login.elements['username'];
var password = login.elements['password'];
var checkcodestr = login.elements['checkcodestr'];
if(!loginCheck(login)) return false;
//if(uc == 1) return true;
if(uc == 1) {				// 添加与 uc 同步登录时的验证码功能
$.post(login.action, 'action=ajaxCheckCode&checkcodestr=' + checkcodestr.value, function(data){
if(data == 2) {
alert('验证码错误');
$('#checkcodes').attr('src', 'checkcode.php?id=' + Math.random());
}else {
login.submit();
}
});
return false;
}
$.post(login.action, 'action=ajax&username='+username.value+'&password='+password.value+'&checkcodestr='+checkcodestr.value, function(data){
if(data == 2) {			//添加前台验证码
alert('验证码错误');
history.go(-2);
} else 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 ucenter = getcookie('ucenter');
if(auth != null)
{
//从论坛同步登录过来时 cookie 有问题，尚未查明原因。暂时用 php 读取 username，注掉下一行：
if (getcookie('username')) $('#logined_username').html(getcookie('username'));
$('#div_login').hide();
$('#div_logined').show();
if (ucenter != null)
{
$('#ucenter').show();
}
}
else
{
$('#div_logined').hide();
$('#div_login').show();
}
}
$(function(){
loginshow();
});