var Login = {
	'name':null,
	'pwd':null,
	'flag':false,
	'check':function(){
		this.name = $('username').value;
		this.pwd = $('password').value;
		if(this.name =='')
		{
			alert("請輸入帳號");
			$('username').focus();
			this.flag = false;
			return;
		}
		else if(this.pwd =='')
		{
			alert("請輸入密碼");
			$('password').focus();
			this.flag = false;
			return;
		}
		this.flag = true;
	},
	'submit':function(){
		this.check();
		if(this.flag)
		{
			var str = "usr="+this.name+"&pwd="+this.pwd;
			var url = "login.php";
			new Ajax.Request(url,{
				method:'post',
				parameters:str,
				onComplete:function(originalRequest){
					var b = originalRequest.responseText;
					if(b==1)
					{
						alert("成功");
						//$('LoginBox').innerHTML = '';
						location.reload();
					}
					else
					{
						alert("登錄失敗，用戶名或密碼錯誤");
					}
				}
			});
		}
	}
}
