	function logininit(element){
		this.loginElement=element;
		if(getCookie("umid")==""){
			drawLoginform("","");
		}else{
			drawLoginOk();
		}
	}
	function login(userid,password){
		drawwaiting();
		var objectAsJSON = JSON.stringify("");
		
		var url = "/login?userid="+userid+"&password="+password+"&t="+new Date().getTime();
		XMLHttp.send_request("GET",url,objectAsJSON,"TEXT",handleLogin);
		
	}
	
	function handleLogin(xmlHttp){
		var resultText = xmlHttp.responseText;
		var resultJsonObject = resultText.parseJSON();
		if(resultJsonObject){
			if(resultJsonObject.id!=undefined&&resultJsonObject.id!=0){
				drawLoginOk();
			}else{
				v="";
				if(resultJsonObject.userid!=undefined) v=resultJsonObject.userid;
				drawLoginform("用户名或密码错误",v);
			}
			
		}
	}
	function dologin(){
		var lf=document.getElementsByName("loginform")[0];
		var uid=lf.userid.value;
		var pwd=lf.password.value;
		if(uid==""){
			alert("请填写用户名再登录！");
			lf.userid.focus();
			return false;
		}
		if(pwd==""){
			alert("请填写密码再登录！");
			lf.password.focus();
			return false;
		}
		login(uid,pwd);
		return false;
	}
	/*function drawLoginform(str,uid){
		document.getElementById("loginstr").innerHTML=str;
		if(this.loginElement){
			this.loginElement.innerHTML='<form name="loginform" method="post" style="margin-bottom: 0px;" onsubmit="return dologin();">'+
			'<div class="loginline">用户名：<input name="userid" type="text" style="width:120px;" value="'+uid+'"></div>'+
			'<div class="loginline">密　码：<input name="password" type="password" style="width:120px;"></div>'+
			'<div class="loginline"><input type="image" onfocus="this.blur()" src="/images/a02.gif" width="70" height="23" /> <a href="http://user.alyisheng.com/register/reg_main.aspx" target="_blank"><img src="/images/a01.gif" width="91" height="23" border="0" /></a></div>'+
			'<div class="loginline"><a href="http://user.alyisheng.com/getPassword.aspx" target="_blank" class="black_l">忘记密码？立即找回</a></div>'+
			'</form>';
		}
	}*/
	function drawLoginform(str,uid){
		document.getElementById("loginstr").innerHTML=str;
		if(this.loginElement){
			this.loginElement.innerHTML='<form name="loginform" action="http://user.alyisheng.com/logon.aspx" method="post" style="margin-bottom: 0px;">'+
			'<div class="loginline">用户名：<input name="txtUserID" type="text" style="width:120px;" value="'+uid+'"></div>'+
			'<div class="loginline">密　码：<input name="txtPassword" type="password" style="width:120px;"></div>'+
			'<div class="loginline"><input type="image" onfocus="this.blur()" src="/images/a02.gif" width="70" height="23" /> <a href="http://user.alyisheng.com/register/reg_main.aspx" target="_blank"><img src="/images/a01.gif" width="91" height="23" border="0" /></a></div>'+
			'<div class="loginline"><a href="http://user.alyisheng.com/getPassword.aspx" target="_blank" class="black_l">忘记密码？立即找回</a></div>'+
			'</form>';
		}
	}
	function drawLoginOk(){
		document.getElementById("loginstr").innerHTML="";
		if(this.loginElement){
			utypename="我的医院";
			jsloginlink2='<a href="http://bbs.alyisheng.com/" target="_blank"><font color="#069fc1" class="b14s">健康社区</font></a>';
			if(getCookie("usertype")=="doctor"){
				utypename="我的诊室";
				jsloginlink2='<a href="http://user.alyisheng.com/patient/MyArticlePost.aspx" target="_blank"><font color="#069fc1" class="b14s">发表文章</font></a>';
			}
			this.loginElement.innerHTML='<div class="loginline"><font color="#ff3000"><b>欢迎您：</b></font><font color="#f67611">'+getCookie("username")+'</font></div>'+
			'<div class="buttonbg" style="margin-left:38px !important;margin-left:0px;margin-top:28px !important;margin-top:5px;"><a href="http://user.alyisheng.com" target="_blank"><font color="#069fc1" class="b14s">'+utypename+'</font></a></div>'+
			'<div class="buttonbg" style="margin-left:38px !important;margin-left:0px;margin-top:4px;">'+jsloginlink2+'</div>'+
			'<div class="buttonbg" style="margin-left:38px !important;margin-left:0px;margin-top:4px;"><a href="http://user.alyisheng.com/logout.aspx"><font color="#07665e">退出</font></a></div>'+
			'</form>';
		}
	}
	function drawwaiting(){
		if(this.loginElement){
			this.loginElement.innerHTML='<br><br><div class="loginline"><img src="/images/waiting.gif"></div>';
		}
	}