var lock = false;
	function reloadimg(obj){
		obj.src="AuthImgSvl?"+GetRandomNum(1,9999)
	}	
	
	function GetRandomNum(Min,Max){
        var Range = Max - Min;
        var Rand = Math.random();
        return(Min + Math.round(Rand * Range));
	} 

function dologon(){
	var username = document.getElementById("username").value;
	username =username.replace(" ","");
	var sfid=document.getElementById("sfid").value;
	var cardtype=document.getElementById("cardtype").value;
	var sauthCode = document.getElementById("authCode").value;
       
	if(username != ""){
		if(sfid!=""){
			_CheckUser(username,sfid,sauthCode);
		}else{
			alert("请输入密码");
		}
	}else{
		alert("请输入健康卡号");
	}
}
        function _CheckUser(sPid,sPwd,sCode){
	    if(!lock ){
		lock  = true;
	    }else{
		alert('用户验证中,清稍等！');
		return ;
	    }	
            var sPostUrl ="CheckUserServlet?url=http://www.mhwsw.com&pid="+sPid+"&pwd="+sPwd+"&code="+sCode;
	 		     
 	    $.ajax({
                 url:  sPostUrl,
                 type: "POST",
                 error:function(a,b,c){lock=false;alert("ERROR:登陆失败\r\n请检查用户名、密码以及验证码是否正确！")},
                 success:function(sResultDate){
					lock  =false;
					//alert(sResultDate)
					if($.trim(sResultDate)!=null && sResultDate !=""){
						
						var aMsg = sResultDate.split("#");
						if(aMsg[0]=="1"){
							var sPram = aMsg[1].split(",");
							sPram[0]=sPram[0].replace("localhost","www.mhwsw.com");
							_openDocu(sPram[0],1024,768);

						}else if(aMsg[0]=="9"){
							ShowSmsPass();
						}else{
							alert("登陆失败\r\n请检查用户名、密码以及验证码是否正确！")
						}
					}
			    }
            }); 
        }
	function _openDocu(url,x,y)
	{

	var myWindowLeft;
	var myWindowTop;
	var myWindowWidth;
	var myWindowHeight;

	//Default value
	myWindowWidth=screen.availWidth+10;
	myWindowHeight=screen.availHeight+10;

	//	if(x) 
	//		myWindowWidth=x;
	//	if(y)
	//		myWindowHeight=y;

//		myWindowLeft=(screen.availWidth-myWindowWidth)/2;
//		myWindowTop=(screen.availHeight-myWindowHeight)/2;
		myWindowLeft = 0
		myWindowTop = 0

		window.open(url,'_blank','toolbar=no,resizable=no,scrollbars=no,status=no,titlebar=no,location =no,menubar =no,'
			+ ' left=' + myWindowLeft
			+ ' ,top=' + myWindowTop 
			+ ' ,height=' + myWindowHeight 
			+ ' ,width=' + myWindowWidth);
	}

var Obj=''   
document.onmouseup=MUp   
document.onmousemove=MMove   
   
function MDown(Object){    
Obj=Object.id    
document.all(Obj).setCapture()    
pX=event.x-document.all(Obj).style.pixelLeft;    
pY=event.y-document.all(Obj).style.pixelTop;    
}    
   
function MMove(){    
if(Obj!=''){    
  document.all(Obj).style.left=event.x-pX;    
  document.all(Obj).style.top=event.y-pY;    
  }    
}    
   
function MUp(){    
if(Obj!=''){    
  document.all(Obj).releaseCapture();    
  Obj='';    
  }    
}  
function ShowSmsPass(stitle,swidth,sheight){
	mask.style.visibility="visible";
	mask.style.visibility="visible";
	massage_box.style.visibility="visible";
	massage_box.style.width=400;
	massage_box.style.height=200;
	massage_title.style.width=100
} 
function doSmsLogin(){
	var Ssmspass = $('#smspass').val();
	var sPostUrl ="CheckUserServlet?url=http://222.66.47.179&smspass="+Ssmspass ;
		     
 	$.ajax({
                 url:  sPostUrl,
                 type: "POST",
                 async: false,
                 error:function(a,b,c){alert("ERROR:登陆失败\r\n请检查短信密码是否正确！")},
                 success:function(sResultDate){
			if(sResultDate!=null&&sResultDate!=1){
				massage_box.style.visibility='hidden';
				_openDocu(sResultDate,1024,768);
			}		
		}
        });   

}
