function scall(){
		document.getElementById("sign_div").style.top="0px";
		document.getElementById("sign_div").style.left="0px";
}
function scallcenter(){
		document.getElementById("light_div").style.top=240+"px";
		document.getElementById("light_div").style.left=(document.documentElement.scrollLeft+(document.documentElement.clientWidth-document.getElementById("light_div").offsetWidth)/2)+"px";
}
function scallcenter01(){
		document.getElementById("light_div").style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-document.getElementById("light_div").offsetHeight)/2)+"px";
		document.getElementById("light_div").style.left=(document.documentElement.scrollLeft+(document.documentElement.clientWidth-document.getElementById("light_div").offsetWidth)/2)+"px";
}

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 = 619;


/**more**/
var sign_in_flow = '<div class="big_pic01">'
        + '<dl><dd>(SGH-E908)<span><img src="/b2b/images/close01.gif" onclick="cancelSign();" onfocus="this.blur()" style="cursor:pointer" /><input type="button" value="cancel" style="display:none" /></span></dd><dt>'
		+ '<div class="big_info"><table border="0" cellspacing="0" cellpadding="0">'
		+ '<tr>'
		+ '<td align="center" align="middle" height="700"></td>'
		+ '</tr>'
		+ '</table></div></dt>'
		+ '</dl></div>'


function loadSignInFlow(){
   G("sign_div").innerHTML = sign_in_flow;
    G("sign_email").focus();
};
var sign_up_flow = '<div style="background:#CCFF00;">Create New Account</div><div>e-mail:*</div><div>'
       + '<input type="text" id="sign_email" maxlength="64" size="30"/>'
       + '</div><div>password:*</div><div><input type="password" id="sign_pwd" size="30"/>'
        + '</div><div>password again:*</div><div><input type="password" id="sign_repwd" size="30"/>'
        + '</div><div><input type="button" value="creat account" onclick="signFlow(0);" id="sign_button"/> '
        + ' <input type="button" value="cancel" onclick="cancelSign();"/></div>'
        + '<p><a href="javascript:loadSignInFlow();">login</a></p>';
function loadSignUpFlow(){
   G("sign_div").innerHTML = sign_up_flow;
    G("sign_email").focus();
};
function cancelSign(){
    G("sign_div").style.display = 'none';
    G("cover_div").style.display = 'none';
   document.body.style.overflow = '';
};
var forget_pwd_flow = '<div style="background:#FF99FF;">Forget Password</div><div>e-mail:*</div><div>'
       + '<input type="text" id="sign_email" maxlength="64" size="30"/>'
        + '</div><div><input type="button" value="sent pwd to e_mail" onclick="signFlow(2);" id="sign_button"/>   '
        + '   <input type="button" value="cancel" onclick="cancelSign();"/></div>';
function loadForgetPwdFlow(){
   G("sign_div").innerHTML = forget_pwd_flow;
    G("sign_email").focus();
};
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) {
    htmlText = forget_pwd_flow;
    }
    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 = '#000';
     left = '0px';
     top = '0px';
     var bodySize = getBodySize();
     width = bodySize[0] + 'px'
     height = bodySize[1] + 'px';
     zIndex = 1000;
     if (isIE()) {
      filter = "Alpha(Opacity=60)";
     } else {
      opacity = 0.6;
     }
    }
   }
}
function getBodySize(){
   var bodySize = [];
   with(document.documentElement) {
    bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;
    //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 - 510)/2 + 'px';
     top = (document.documentElement.clientHeight - 600)/2 + 'px';
	 //left = (document.documentElement.clientWidth - loginDivWidth)/2 + 'px';
     //top = (document.documentElement.clientHeight - 300)/2 + 'px';
     width = loginDivWidth + 'px';
     zIndex = 1000;
     background = '#000000';
     border = '#AE9999 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";
}

function checkOldPwd(){
   if(G("old_pwd").value.trim() == ''){
    return '<div style="color:#FF0000";">Old Password field is required.</div>';
   }
   return '';
}
/**big pic*/
var change_pwd_flow = '<div class="big_pic01">'
        + '<dl><dd>(SGH-E908)<span><img src="/b2b/images/close01.gif" onclick="cancelSign();" onfocus="this.blur()" style="cursor:pointer" /><input type="button" value="cancel" style="display:none" /></span></dd><dt>'
		+ '<table width="738" border="0" cellspacing="0" cellpadding="0">'
		+ '<tr>'
		+ '<td align="center" align="middle" height="553"><img src="/b2b/images/011.gif" /></td>'
		+ '</tr>'
		+ '</table></dt>'
		+ '</dl></div>'

//function showLightBox(title,contentdiv,css)
function showLightBox(contentdiv)
{
     popCoverDiv();  
   if (G("light_div")) {
    G("light_div").style.display = '';
	G("light_div").className = 'pngbg'
   } else {
    var lightDiv = GC('div');
    document.body.appendChild(lightDiv);
    lightDiv.id = 'light_div';
    //lightDiv.align = "center";
    lightDiv.onkeypress = function(evt){
          var e = window.event?window.event:evt;
          if (e.keyCode==13 || e.which==13) {
           if (G("light_button")) {
            G("light_div").focus();
            G("light_button").click();
           }
          }
         };
    with (lightDiv.style) {
     position = 'absolute';
     left = (document.documentElement.clientWidth - 510)/2 + 'px';
     top = (document.documentElement.clientHeight - 600)/2 + 'px';
	 //left = (document.documentElement.clientWidth - loginDivWidth)/2 + 'px';
     //top = (document.documentElement.clientHeight - 300)/2 + 'px';
     width = '';
     zIndex = 10000;
     //background = '#FFFFFF';
     border = '#AE9999 solid 0px';
    }
   }
   var tmp=CONST_LIGHTBOXFOMAT;
   //tmp=tmp.replace("##CSS##",css);
   //tmp=tmp.replace("##TITLE##",title);
   tmp=tmp.replace("##CONTENT##",G(contentdiv).innerHTML);
   
    G("light_div").innerHTML = tmp;

   document.body.style.overflow = "hidden";
}


function hideLightBox(){
    try{
    	G("light_div").style.display = 'none';    
    	G("light_div").innerHTML = "";
    	G("cover_div").style.display = 'none';
   	document.body.style.overflow = '';
   }catch(e){}
}

/**big pic*/
var CONST_LIGHTBOXFOMAT = '##CONTENT##'
		
		
//var CONST_LIGHTBOXFOMAT = '<div class="##CSS##">'
//        + '<dl><dd>##TITLE##<span><img src="../images/close.gif" onclick="hideLightBox();" onfocus="this.blur()" style="cursor:pointer" /><input type="button" value="cancel" style="display:none" /></span></dd><dt>'
//		+ '##CONTENT##</dt>'
//		+ '</dl></div>'



mpBehavior=function(){var _PopupID;var _BackgroundCssClass="modalBackground";var _backgroundElement;var _foregroundElement;var _showHandler;var _okHandler;var _cancelHandler;var _scrollHandler;var _resizeHandler;var _isInit=false;this.init=function(){_backgroundElement=document.createElement('div');_backgroundElement.style.display='none';_backgroundElement.style.position='absolute';document.body.appendChild(_backgroundElement);_foregroundElement=document.getElementById(_PopupID);_foregroundElement.style.display='none';_foregroundElement.style.position='absolute';document.body.appendChild(_foregroundElement);_scrollHandler=this._onLayout;_resizeHandler=this._onLayout;};this._attachPopup=function(){window.attachEvent('onresize',_resizeHandler);window.attachEvent('onscroll',_scrollHandler);};this._detachPopup=function(){if(_scrollHandler){window.detachEvent('onscroll',_scrollHandler);};if(_resizeHandler){window.detachEvent('onresize',_resizeHandler);}};this._hide=function(){_backgroundElement.style.display='none';_backgroundElement.className="";_foregroundElement.style.display='none';this._detachPopup();};this._onShow=function(e){this._show();event.returnValue=false;return false;};this._onLayout=function(){this._layout();};this._show=function(){if(!_isInit){this.init();_isInit=true;};if(_BackgroundCssClass){_backgroundElement.className=_BackgroundCssClass;};_backgroundElement.style.display='';_foregroundElement.style.display='';this._layout();this._layout();};this._layout=function(){var scrollLeft=(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);var scrollTop=(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);var clientWidth;if(window.innerWidth){clientWidth=(window.__safari?window.innerWidth:Math.min(window.innerWidth,document.documentElement.clientWidth));}else{clientWidth=document.documentElement.clientWidth;};var clientHeight;if(window.innerHeight){clientHeight=(window.__safari?window.innerHeight:Math.min(window.innerHeight,document.documentElement.clientHeight));}else{clientHeight=document.documentElement.clientHeight;};_backgroundElement.style.left='0px';_backgroundElement.style.top='0px';_backgroundElement.style.width=document.body.scrollWidth;_backgroundElement.style.height=document.body.scrollHeight;if(scrollLeft+((clientWidth-_foregroundElement.offsetWidth)/2)>0){_foregroundElement.style.left=scrollLeft+((clientWidth-_foregroundElement.offsetWidth)/2)+'px';}else{_foregroundElement.style.left=0;};if(scrollTop+((clientWidth-_foregroundElement.offsetWidth)/2)>0){_foregroundElement.style.top=scrollTop+((clientHeight-_foregroundElement.offsetHeight)/2)+'px';}else{_foregroundElement.style.top=0;}};this.get_PopupID=function(){return _PopupID;};this.set_PopupID=function(value){_PopupID=value;}}

