function G(id){
    return document.getElementById(id);
};
function GC(t){
   return document.createElement(t);
};
String.prototype.trim = function(){
          return this.replace(/(^\s*)|(\s*$)/g, '');
};
function isIE(){
      return (document.all && window.ActiveXObject && !window.opera) ? true : false;
} 
     var loginDivWidth = 300;          //div宽度
	 //要显示的div
var sign_in_flow = '<div id="oLogin" class="login" ><h3><span class="special">协同办公</span>登录</h3>'
		+'<form id="form1" method="post" action=""><div class="lText"><p><label for="username">用户名</label><input type="text" name="username" class="userName" />'
		+'</p><p><label for="password">密　码</label><input type="password" name="password" class="password" />	</p>'
		+'<p class="noLogin"><a href="#" onclick="cancelSign();">取消登陆</a></p>'
		+'</div><div class="lSubmit"><p><input type="button" onclick ="tijiao();" name="Submit" value="登陆" class="submit" />'
		+'</p></div></form></div>';
//div退出时
function cancelSign(){
    G("sign_div").style.display = 'none';
    G("cover_div").style.display = 'none';
   document.body.style.overflow = '';
};


function popCoverDiv(){
   if (G("cover_div")) {
    G("cover_div").style.display = '';
   } else {
    var coverDiv = GC('div');
    document.body.appendChild(coverDiv);
    coverDiv.id = 'cover_div';
    with(coverDiv.style) {
     position = 'absolute';
     background = '#5c9748';   //弹出登陆后body的颜色
     left = '0px';
     top = '0px';
     var bodySize = getBodySize();
     width = bodySize[0] + 'px'
     height = bodySize[1] + 'px';
     zIndex = 98;
     if (isIE()) {
      filter = "Alpha(Opacity=60)";
     } else {
      opacity = 0.6;
     }
    }
   }
}
function getBodySize(){
   var bodySize = [];
   with(document.documentElement) {
    bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;
    bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;
   }
   return bodySize;
} 
function popSign(isLogin){
   if (G("sign_div")) {
    G("sign_div").style.display = '';
   } else {
    var signDiv = GC('div');
    document.body.appendChild(signDiv);
    signDiv.id = 'sign_div';
    signDiv.align = "center";
    signDiv.onkeypress = function(evt){
          var e = window.event?window.event:evt;
          if (e.keyCode==13 || e.which==13) {
           if (G("sign_button")) {
            G("sign_div").focus();
            G("sign_button").click();
           }
          }
         };
    with (signDiv.style) {
     position = 'absolute';
     left = (document.documentElement.clientWidth - loginDivWidth)/2 + 'px';
     top = (document.documentElement.clientHeight - 300)/2 + 'px';
     width = loginDivWidth + 'px';
     zIndex = 99;
     background = '#FFFFFF';
     border = '#596FC1 solid 1px';       //外框颜色
    }
   }
   if(isLogin) {
    G("sign_div").innerHTML = sign_in_flow;
   } else {
    G("sign_div").innerHTML = change_pwd_flow;
   }
  
}
function popSignFlow(isLogin) {
   popCoverDiv();  
   popSign(isLogin);  
   document.body.style.overflow = "hidden";
     
      if(isLogin) {		 
       G("username").focus();
      } else {
       G("old_pwd").focus();
      }
}
//登陆后提交js

function tijiao()
{
   user= G("username").value;
   pass=G("password").value;  
   window.location="http://222.134.52.34:8080/yyoa/CheckLogin?userName="+user+"&password="+pass;
}