﻿function GetQueryString(name)   
{   
   var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");   
   var r = window.location.search.substr(1).match(reg);   
   if(r!=null) return unescape(r[2]); return null;   
}  
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 = 220;
var sign_in_flow = '<table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/index_7.gif"><tr><td  height="5" align="right"><span style="cursor:hand;color:#FFF" onclick="cancelSign();">×</span>&nbsp;</td></tr><tr><td align="center"><img src="images/index_5.gif" width="70" height="21" /></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/index_7.gif"><form id="login" name="login" method="post" action="login_ok.asp" onsubmit="return submitcheck();"><tr><td align="right" height="28" class="aw12">用户名：</td><td><input type="hidden" name="Http" id="Http" value="questionshow.asp?state='+GetQueryString("state")+'&id='+GetQueryString("id")+'" /><input name="UserName" type="text" class="text_1" id="UserName" size="14" maxlength="20" /></td></tr><tr><td align="right" height="28" class="aw12">密　码：</td><td><input name="PassWord" type="password" class="text_1" id="PassWord" size="14" maxlength="20" /></td></tr><tr><td height="35" colspan="2" align="center" valign="bottom"><input name="login" id="login" type="image" src="images/manu_1.gif" width="48" height="18" class="radio"/>&nbsp;&nbsp;&nbsp;<a href="reg.asp"><img src="images/manu_2.gif" height="18" border="0" /></a>&nbsp;&nbsp;&nbsp;<a href="regexpert.asp"><img src="images/manu_zhuanjian.gif" width="56" height="18" border="0" /></a></td></tr><tr><td colspan="2" align="center" valign="bottom">&nbsp;</td></tr></form></table>';

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 = '#CCCCCC';
     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+1000)/2 + 'px';
     width = loginDivWidth + 'px';
     zIndex = 99;
     border = '#66CCFF 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";
}


