
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 = 455;
var sign_in_flow = '<div id="TB_ajaxContent" class="TB_modal" style="width: 455px; height: 225px;"> <form method="post" action="/fafiecuser/login" name="loginform" onsubmit="return verifLoginPasswd();">'
	+'<table width="100%" border="0" cellspacing="0" cellpadding="0">'
	+'<tr><td height="61">&nbsp;</td><td colspan="2">&nbsp;</td></tr>'
	+'<tr>'
    +'<td width="36%" align="right" class="txt_identifier"><div align="right">Identifiant * :&nbsp;</div></td>'
    +'<td colspan="2" align="left"><input type="text" name="Login" value="" tabindex="1" id="Login"/></td>'
    +'</tr>'
    +'<tr>'
    +'<td align="right" class="txt_identifier"><div align="right">Mot de passe * :&nbsp;</div></td>'
    +'<td width="33%" align="left"><input type="password" name="Password" value="" tabindex="2" id="Password"/></td>'
    +'<td width="31%" align="left">'
    +'<input src="/extension/internet/design/internet/images/login_OK.gif" class="button" type="image" size="10" name="LoginButton" value="Identifier" tabindex="3" /></td>'
    +'</tr><tr><td colspan="3">&nbsp;</td></tr>'
    +'<tr>'
    +'<td colspan="2" class="txt_identifier"><div align="right">Vous avez oubli&eacute; votre mot de passe  :&nbsp;</div></td>'
    +'<td><a href="/fafiecuser/forgotpassword"><img src="/extension/internet/design/internet/images/cliquerOrange.gif" alt="Cliquer ici" width="102" height="22"/></a></td>'
    +'</tr><tr><td colspan="3">&nbsp;</td></tr>'
    +'<tr><td colspan="3">&nbsp;</td></tr>'
    +'<tr><td colspan="3">&nbsp;</td></tr>'
    +'<tr><td >&nbsp;</td><td >&nbsp;</td>'
    +'<td><div id="TB_closeAjaxWindow"><a class="txt_identifier" onclick="cancelSign();" href="#">Annuler</a></div></table></form></div>';

var dpc_flow = "";

function loadSignInFlow(){
   G("sign_div").innerHTML = sign_in_flow;
};
function cancelSign(){
    G("sign_div").style.display = 'none';
    G("cover_div").style.display = 'none';
   document.body.style.overflow = '';
};

function signFlow(isSignIn){
    var htmlText = null;
    if (isSignIn == 1) {     
     htmlText = sign_in_flow;
    } 
};
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 = '#000000';
     left = '0px';
     top = '0px';
     var bodySize = getBodySize();
     width = bodySize[0] + 'px'
     height = bodySize[1] + 'px';
     zIndex = 98;
     if (isIE()) {
      filter = "Alpha(Opacity=90)";
     } 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';
     padding = 15 + 'px';
     zIndex = 99;
   //  background = '#FFFFFF';
   //  border = '#66CCFF solid 1px';
    }
   }
   if(isLogin==1) {
    G("sign_div").innerHTML = sign_in_flow;
   }
   if(isLogin==2) {
	G("sign_div").innerHTML = dpc_flow;
   }
  
}
function popSignFlow(isLogin) {
   if(isLogin==2){
	   var msg=document.getElementById('param_msg_verouille').value;
	   dpc_flow='<div id="TB_ajaxContent" class="TB_modal" style="width: 455px; height: 100px;"> '
		+'<table width="100%" border="0" cellspacing="0" cellpadding="0">'
		+'<tr><td colspan="3">&nbsp;</td></tr>'
	    +'<tr><td >&nbsp;</td>'
	    +'<td class="txt_identifier"><div align="center" style="font-weight:normal;font-size:18px;">'+msg+'</div></td>'
	    +'<td >&nbsp;</td></tr>'
	    +'<tr><td colspan="3">&nbsp;</td></tr>'
	    +'</table></div>';
   }
   popCoverDiv();  
   popSign(isLogin);  
   document.body.style.overflow = "hidden";    
}
