﻿
function loginAction() {
	var loginAccount = document.getElementById("userId").value;
	var password = document.getElementById("LOGPASS").value;
	var checkcode = document.getElementById("checkcode").value;
	var url = "../user/ajaxlogin.do?loginAccount=" + loginAccount + "&password=" + password  + "&checkcode=" + checkcode;
	//alert("url:"+url);
	initXmlHttp();
	xmlHttp.onreadystatechange = showLoginState;
	xmlHttp.open("post", url, true);
	xmlHttp.setrequestheader("CONTENT-TYPE", "application/x-www-form-urlencoded;charset=utf-8");
	var sendData = "";
	xmlHttp.send(sendData);
}
function showLoginState() {
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		var returnstate = xmlHttp.responseText;
		//alert("returnstate:"+returnstate);
		if("nullcode"==returnstate){
		    alert("验证码错误！");
		  //  document.getElementById("checkcodediv").innerHTML="验证码错误！";
		}else if("nulltype"==returnstate){
		    alert("错误的用户类型");
		}else if("erroruser"==returnstate){
		   alert("工作号错误！");
		   // document.getElementById('reloginaccount').innerHTML="";
		}else if("errorpass"==returnstate){
		   alert("密码错误！");
		   // document.getElementById("reloginpswddiv").innerHTML="密码错误！";
		}else if("success"==returnstate){
		   document.getElementById("reloginwindow").style.display = "none";
		   document.getElementById("reLoginDiv").style.display = "none";
		   reSetTime();
		}else{
		  alert("系统错误,请重试或者联系管理员!");
		}
		changCode();
	}
}
function resetAction() {
	document.getElementById("reloginwindow").style.display = "none";
	//document.getElementById("reLoginDiv").style.display = "none";
}
function showReLoginDiv() {
    //document.getElementById("reloginwindow").style.filter="alpha(opacity=100)";
    var reLoginDiv = document.getElementById("reLoginDiv");
    reLoginDiv.style.height=document.body.scrollHeight+document.body.clientHeight;
    reLoginDiv.style.width=document.body.scrollWidth+document.body.clientWidth;
	reLoginDiv.style.display = "block";
}
var xmlHttp;
function initXmlHttp() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest;
		}
	}
}
 function $(_sId){return document.getElementById(_sId);}
   function moveStart (event, _sId){
  var oObj = $(_sId);
  oObj.onmousemove = mousemove;
  oObj.onmouseup = mouseup;
  oObj.setCapture ? oObj.setCapture() : function(){};
  oEvent = window.event ? window.event : event;
  var dragData = {x : oEvent.clientX, y : oEvent.clientY};
  var backData = {x : parseInt(oObj.style.top), y : parseInt(oObj.style.left)};
  function mousemove(){
   var oEvent = window.event ? window.event : event;
   var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left);
   var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top);
   oObj.style.left = iLeft;
   oObj.style.top = iTop;
   dragData = {x: oEvent.clientX, y: oEvent.clientY};   
  }
  function mouseup(){
   var oEvent = window.event ? window.event : event;
   oObj.onmousemove = null;
   oObj.onmouseup = null;
   if(oEvent.clientX < 1 || oEvent.clientY < 1 || oEvent.clientX > document.body.clientWidth || oEvent.clientY > document.body.clientHeight){
    oObj.style.left = backData.y;
    oObj.style.top = backData.x;
   }
   oObj.releaseCapture ? oObj.releaseCapture() : function(){};
  }
 } 
