$(function(){
	if(self!=top){window.top.location.href = './admin.php?m=login';}
	$('#admin_name').focus();
	$('#form_login').submit(function(){
		notice('正在登录中~','loading');
		if($('#admin_name').val()==''){
			notice('请输入帐号~','error');
			$('#admin_name').focus();
		}else if($('#admin_pwd').val()==''){
			notice('请输入密码~','error');
			$('#admin_pwd').focus();
		}else{
			$.post("./admin.php?m=login&a=check",$("#form_login").serialize(),function(data){
				var msg;
				var pic;
				if(data==1){
					msg = '登录成功,现在跳转~';
					pic = 'ok';
					window.parent.location = './admin.php';
				}else{
					pic = 'error';
					if(data==-1){$('#admin_name').focus();msg='帐号不存在！';}
					else if(data==-2){$('#admin_pwd').focus();msg='密码错误！';}
					else if(data==-3){$('#admin_name').focus();msg='此帐号被禁止登录！';}
					else{$('#admin_name').focus();msg='异常错误！请重试~';}
				}
				notice(msg,pic);
			});
		}
		return false;
	});
});
function notice(msg,pic){
	$('.notice').remove();
	$('body').append('<div class="notice"><img src="./Public/Images/'+pic+'.gif" />'+msg+'</div>');
}