function Login(cookieobj){
	this.cookieobj=cookieobj;
	this.login_username;
	this.login_password;
	this.formobj;
}

Login.prototype={
	trim:function(s){
		s=s.replace(/^\s*/ig,"");
		s=s.replace(/\s*$/ig,"");
		return s;
	},
	setLoginSpace:function(login_space){
		var nickname=this.cookieobj.getCookie('_nickname');
		var uid=this.cookieobj.getCookie('_uid');
		if(nickname && nickname!=""){
			document.getElementById(login_space).innerHTML='<p>欢迎您，<strong><a href="action.php?do=oneview&uid='+uid+'">'+nickname+'</a></strong>&nbsp;&nbsp;<a href="http://account.178.com/q_account.php?_act=logout" title="退出" style="color:#f00;margin-top:5px;" target="_self">退出</a></p>';
		}else{
			var _this=this;
			var login_show_space=document.getElementById(login_space);
			var form_obj=document.createElement('form');
			form_obj.action='http://account.178.com/q_account.php'
			form_obj.method='post';
			form_obj.appendChild(document.createTextNode('登录方式 '));
			var temp_obj=document.createElement('input');
			temp_obj.type='hidden';temp_obj.name='_act';temp_obj.value='login';
			form_obj.appendChild(temp_obj);
			temp_obj=document.createElement('input');
			temp_obj.type='hidden';temp_obj.name='to';temp_obj.value='';
			form_obj.appendChild(temp_obj);
			temp_obj=document.createElement('select');
			temp_obj.name='type';
			temp_obj.appendChild(document.createElement('option'));
			temp_obj.appendChild(document.createElement('option'));
			temp_obj.appendChild(document.createElement('option'));
			temp_obj.options[0].value='uid';
			temp_obj.options[0].text='UID';
			temp_obj.options[1].value='username';
			temp_obj.options[1].text='用户名';
			temp_obj.options[1].selected=true;
			temp_obj.options[2].value='email';
			temp_obj.options[2].text='Email';
			form_obj.appendChild(temp_obj);
			form_obj.appendChild(document.createTextNode(' 用户名 '));
			temp_obj=document.createElement('input');
			this.login_username=temp_obj;
			temp_obj.size=9;
			temp_obj.type='text';
			temp_obj.name='email';
			form_obj.appendChild(temp_obj);
			form_obj.appendChild(document.createTextNode(' 密码 '));
			temp_obj=document.createElement('input');
			this.login_password=temp_obj;
			temp_obj.size=9;
			temp_obj.type='password';
			temp_obj.name='password';
			temp_obj.onkeypress=function(e){
				var e= window.event?window.event:e;
				if(e.keyCode==13){
					_this.login();
				}
			};
			form_obj.appendChild(temp_obj);
			form_obj.appendChild(document.createTextNode(' '));
			temp_obj=document.createElement('input');
			temp_obj.onclick=function(){_this.login();};
			temp_obj.type='button';
			temp_obj.value='登录';
			form_obj.appendChild(temp_obj);
			form_obj.appendChild(document.createTextNode(' '));
			temp_obj=document.createElement('a');
			temp_obj.target='_blank';
			temp_obj.href='http://account.178.com/?p=register';
			temp_obj.innerHTML='注册';
			form_obj.appendChild(temp_obj);
			form_obj.appendChild(document.createTextNode(' '));
			temp_obj=document.createElement('a');
			temp_obj.target='_blank';
			temp_obj.href='http://account.178.com/?p=reset_pass';
			temp_obj.innerHTML='忘记密码';
			form_obj.appendChild(temp_obj);
			login_show_space.appendChild(form_obj);
			this.formobj=form_obj;
			this.formobj.target='_self';
		}
	},
	login:function(){
		var username=this.trim(this.login_username.value);
		var password=this.trim(this.login_password.value);
		if(username==""){
			alert('请输入登录名!');
			return;
		}
		if(password==""){
			alert('请输入登录密码!');
			return;
		}
		this.formobj.submit();
	},
	getNickname:function(){
		return this.cookieobj.getCookie('_nickname');
	},
	getUid:function(){
		return this.cookieobj.getCookie('_uid');
	}
}