var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

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;
	kurl2= document.URL ;
var sign_in_flow =   '<table width="300" height="200" border="0" cellpadding="0" cellspacing="0">'
   + '<form name=Form1 method=post action=/login.asp?kurl='+kurl2+' onsubmit="return Validator.Validate(this,2)" >'
  + '<tr>'
    + ' <td width="300" height="30" align="center" bgcolor="#EBEBEB">'
	+ ' <table width="96%" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#ebebeb">'
      + ' <tr>'
      + '   <td width="2%" height="30" align="left">&nbsp;</td>'
       + '  <td width="91%" align="left"><span class="STYLE51">Sign in</span></td>'
         + '<td width="7%"><a href="javascript:login.style.display = "none";forbid.style.visibility = "hidden"; void(0);">'
		+ ' <img src="/img/X.gif" width="15" height="15" border="0" onClick="javascricpt:cancelSign();"></td>'
       + '</tr>'
     + '</table></td>'
   + '</tr>'
   + '<tr>'
     + '<td height="127" align="center"><table cellspacing="0" cellpadding="0" width="96%">'
       + '<tbody>'
         + '<tr>'
         + ' <td width="98"></td>'
         + ' <td colspan="2" class="errorYukon"></td>'
       + ' </tr>'
       + ' <tr>'
       + '   <td colspan="3" height="11"></td>'
       + ' </tr>'
       + ' <tr>'
        + '  <td width="98" height="30" align="right" nowrap="nowrap"><label for="passport" class="STYLE53">Email :</label></td>'
        + '  <td width="7" align="center">&nbsp;</td>'
        + '  <td width="198" align="left">'
		 + '<input   style="FONT-FAMILY: Arial" tabindex="1"  maxlength="64" size="24" name="userEmail" datatype="Email" msg="Please enter a correct email address"/></td>'
       + ' </tr>'
         + '<tr>'
         + '  <td colspan="3" height="10"></td>'
        + ' </tr>'
        + ' <tr>'
         + '  <td width="98" align="right" nowrap="nowrap" class="STYLE53">Password :</td>'
         + '  <td>&nbsp;</td>'
          + ' <td align="left"><input  style="FONT-FAMILY: Arial" tabindex="2"  type="password" maxlength="64" size="24" name="pass" datatype="Require"  msg="Please enter a correct password"/></td>'
         + '</tr>'
        + ' <tr>'
          + ' <td height="30"></td>'
         + '  <td valign="top" style="FONT-SIZE: x-small; FONT-FAMILY: Verdana">&nbsp;</td>'
          + ' <td align="left" valign="middle" style="FONT-SIZE: x-small; FONT-FAMILY: Verdana">'
		  + '<a  href="/password.html" target="_blank" class="STYLE49">Forgot password? </a></td>'
        + ' </tr>'
      + ' </tbody>'
    + ' </table></td>'
   + '</tr>'
  + ' <tr>'
   + '  <td height="37" align="center"><table width="96%" border="0" cellspacing="0" cellpadding="0">'
    + '   <tr>'
     + '    <td height="2" colspan="3" align="center"></td>'
      + ' </tr>'
     + '  <tr>'
     + '    <td width="54%" height="34" align="right"><input type="submit" name="Submit2" value="Sign in" /></td>'
      + '   <td width="23%" align="center"><a href="/Registe.asp" class="STYLE54">Register</a></td>'
       + '  <td width="23%" align="center">&nbsp;</td>'
      + '  </tr>'
     + '</table></td>'
  + ' </tr></form>'
 + '</table>';
 
 
//alert(sign_in_flow);
function cancelSign(){
    G("sign_div").style.display = 'none';
    G("cover_div").style.display = 'none';
   document.body.style.overflow = '';
};
 
 
function checkEmail(){
   if((G("sign_email").value.indexOf('@')<=0)||(G("sign_email").value.indexOf('.')<=0)){
    return '<div style="color:#FF0000";">Sorry, unrecognized e_mail.</div>';
   }
   return '';
}
function checkPwd(){
   if(G("sign_pwd").value.trim() == ''){
    return '<div style="color:#FF0000";">Password field is required.</div>';
   }
   return '';
}
function checkRePwd(){
   if(G("sign_pwd").value.trim() != G("sign_repwd").value.trim()){
    return '<div style="color:#FF0000";">The specified passwords do not match.</div>';
   }
   return '';
}
function signFlow(isSignIn){
    var error = checkEmail();
    var htmlText = null;
    if (isSignIn == 1) {
     if (error == ''){
      error = checkPwd();
     }
     htmlText = sign_in_flow;
    } else if (isSignIn == 0) {
     if (error == ''){
      error = checkPwd();
      if (error == ''){
       error = checkRePwd();
      }
     }
     htmlText = sign_up_flow;
    } else if (isSignIn == 2) {
  
    }
    var eMailValue = G("sign_email").value.trim();
   if (error == '') {
    } else {
    G("sign_div").innerHTML = error + htmlText;
    G("sign_email").value = eMailValue; 
    }
};
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){
	document.Form1.action="/login.asp?kurl="+document.URL;
//   if (G("sign_div")) {
    G("sign_div").style.display = '';
//   } else {
    var signDiv =G("sign_div");// 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 = '#999999 solid 1px';
    }
 //  }
   if(isLogin) {
   // G("sign_div").innerHTML = sign_in_flow;
   } else {
    G("sign_div").innerHTML = change_pwd_flow;
   }
  
}
function popSignFlow(isLogin) {
   popCoverDiv();  
  // alert("ok");
   popSign(isLogin);  
   document.body.style.overflow = "hidden";
     
     
      
    
}
 
