// JavaScript Document
function do_login()
{
  if($('user').value.length < 1)
  {
    alert("Please enter username！")
    $('user').focus()
    return false
  }
  if($('password').value.length < 1)
  {
    alert("Please enter password!")
    $('password').focus()
    return false
  }

  		var w=300,h=100;
		var bgObj=document.createElement("div");
		bgObj.setAttribute('id','bgDiv');
		bgObj.style.position="absolute";
		bgObj.style.top="0";
		bgObj.style.background="#000";
		bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
		bgObj.style.opacity="0.6";
		bgObj.style.left="0";
		bgObj.style.width=document.body.clientWidth + "px";
		bgObj.style.height=document.body.scrollHeight + "px";
		bgObj.style.zIndex = "10000";
		document.body.appendChild(bgObj);
		
		var msgObj=document.createElement("div")
		msgObj.setAttribute("align","center");
		msgObj.style.background="white";
		msgObj.style.border="1px solid #5D81AD";
		msgObj.style.position = "absolute";
		msgObj.style.left = window.screen.availHeight/2-120+"px";
		msgObj.style.top = document.body.clientHeight/2-10+"px";
		msgObj.style.color="#999999";
		msgObj.style.paddingTop="20px";
		msgObj.style.fontSize="12px";
		msgObj.style.width = w + "px";
		msgObj.style.height =h + "px";
		msgObj.innerHTML = "<img src='"+weburl+"/image/default/cache.gif'><br><br> <h6> Loading....</h6>";
		msgObj.style.zIndex = "10001";
		document.body.appendChild(msgObj);
  

	var url = weburl+'/do_login.php';
	var sj = new Date();
	var pars = 'shuiji=' + sj+'&user='+$('user').value+'&password='+$('password').value+'&action=submit&forward='+$('forward').value; 
	var myAjax = new Ajax.Request(url,{method: 'get', parameters: pars, onComplete:showResponse} )

	function showResponse(originalRequest)
	{

		if(originalRequest.responseText==1)
		{
			
			$('tishi').innerHTML="&nbsp;Please Check Your ID!<br />";
			document.body.removeChild(bgObj);
			document.body.removeChild(msgObj);
		}
		else if(originalRequest.responseText==2)
		{
			$('tishi').innerHTML="&nbsp;Please Check Your Password!<br />";
			$('tishi').style.color="#FF0000";
			document.body.removeChild(bgObj);
			document.body.removeChild(msgObj);
		}
		else
		{
			tourl=originalRequest.responseText;
			if(enurl)
			{
				var login=request("loginScript",enurl+"/do_login.php?"+pars);
				window.setTimeout("goto(tourl)",30);
			}
			else
			{
				goto(tourl);
			}
		}
	}
  //==============================================================
}
function goto(url)
{
	window.location=url;
}
function request(id,url){
 oScript = document.getElementById(id);
 var head = document.getElementsByTagName("head").item(0);
 if (oScript) {
	head.removeChild(oScript);
 }
 oScript = document.createElement("script");
 oScript.setAttribute("src", url);
 oScript.setAttribute("id",id);
 oScript.setAttribute("type","text/javascript");
 oScript.setAttribute("language","javascript");
 head.appendChild(oScript);
 return true;
}