// JavaScript Document
function LOG_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=LOG_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// validates that the entry is formatted as an email address
function LOGON_FieldIsEMailAddr(elem) {
	return LOGON_IsEMailAddr(elem.value);
}

// validates that the lib is formatted as an email address
function LOGON_IsEMailAddr(str) {
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    return str.match(re);
}

function Logon(_objname) {
	this.logon_objname    = _objname;
	this.Logon_id         = 'popupLogon';
	this.Logon_directory  = './';
	this.Logon_international = false;
	this.Logon_language        = 'fr';
	this.Logon_language_only   = '';
	this.namefield_username  = '';
	this.namefield_password  = '';
	this.namefield_action    = 'logonaction';
	this.logon_cpt_hit  = -1;
	this.logon_max_hit  = -1;	
	
	this.Logon_forget       = false;
	this.Logon_libchanged   = false;
	this.Logon_nameisemail  = true;
	this.Logon_username   = "";
	this.Logon_password   = "";
	this.logon_message    = "";
	this.action_en_cours  = "";

	this.Logon_url_yes         = "IfYes.htm";
	this.Logon_url_no          = "IfNo.htm";
	this.Logon_IconeQuestion   = 'question_a.gif';
	this.Logon_IconeMailYes    = 'mail_yes.gif';
	this.Logon_IconeMailNo     = 'mail_no.gif';
	this.Logon_IconeLoggedYes  = 'unlocked.gif';
	this.Logon_IconeLoggedNo   = 'locked.gif';
	this.Logon_IconeClose      = 'close.gif'; 


	this.Logon_SetMemoryModeDefault	= 0;
	this.Logon_background   = '';
	this.Logon_logoff       = true;
	this.Logon_Encryption   = true;
	
	this.Logon_try        = 1;
	this.Logon_maxtry     = 3;
	this.Logon_pwdmini    = 6;
	this.Logon_memorymode = -1;
	this.key = -1;
	this.submit_OK        = false;

	// fonction timer
	this.logon_timer_activated = false;

}
Logon.prototype.SetLabels = function () {
	// ADAPTATION INTERNATIONALE
	// initialisation de la table des langues
	this.Logon_t_languagesList = LOG_InitLanguages();
	// initialisation des messages en fonction de la angue choisie
	var t_label= LOG_InitLanguageMessages(this.Logon_language);

	this.Logon_languageLib     = this.Logon_t_languagesList[this.Logon_language];
	this.Logon_flag            = t_label['FLAG'];
	
	this.Logon_libuseremail    = t_label['LIBUSER'];
	this.Logon_libusername     = t_label['LIBUSERNAME'];
	
	this.Logon_libtitre_1      = t_label['PROCCNX'];
	this.Logon_closewin        = t_label['CLOSEWIN'];
	this.Logon_memorymodelabel = t_label['MEMORYMODE'];
	this.Logon_pwdlabel        = t_label['PWDLABEL'];
	this.Logon_pwdforgettitle  = t_label['PWDFORGETTTL'];
	this.Logon_Help_Forget     = t_label['PWDFORGET'];
	this.Logon_BtnSend         = t_label['BTNSEND'];
	this.Logon_ErrorFmt        = t_label['ERRORFMT'];
	this.Logon_MsgNoSended     = t_label['NOSENDED'];  
	this.Logon_MsgSended       = t_label['SENDED'];  
	this.Logon_Trying          = t_label['TRY'];  
	this.Logon_changelanglabel = t_label['AVAILABLELANG'];
	this.Logon_otherlanglabel  = t_label['OTHERLANGUAGE'];


	this.Logon_pwdmodifytitle  = t_label['PWDMODIFYTTL'];
	this.Logon_pwdmodifylabel1 = t_label['PWDMODIFYLBL1'];
	this.Logon_pwdmodifylabel2 = t_label['PWDMODIFYLBL2'];
	this.Logon_pwdmodifybtn    = t_label['PWDMODIFYLBTN'];
	this.Logon_pwdmodifyok	   = t_label['PWDMODIFYOK'];
	this.Logon_pwdmodifyerror1 = t_label['PWDMODERROR1'];
	this.Logon_pwdmodifyerror2 = t_label['PWDMODERROR2'];
	this.Logon_pwdmodifyerror3 = t_label['PWDMODERROR3'];
	
	this.Logon_accesdenied     = t_label['ACCESSDENIED'];
	this.Logon_currentlang     = t_label['CURRENTLANG'];
	

	this.Logon_Help_MemoryMode          = t_label['WARNAUTO'];
	this.Logon_Help_IconeCloseLoggedNo  = t_label['CANCELLOG'];
	this.Logon_Help_IconeCloseLoggedYes = t_label['CANCELPWD'];
	this.Logon_Help_IconeLoggedYes      = t_label['MSGCNXYES'];
	this.Logon_Help_IconeLoggedNo       = t_label['MSGCNXNO'];

	this.Logon_libselect  = new Array();
	this.Logon_libselect[0] = t_label['OPTCNX_0'];
	this.Logon_libselect[1] = t_label['OPTCNX_1'];
	this.Logon_libselect[2] = t_label['OPTCNX_2'];
	
}


Logon.prototype.InitKey = function (keycontainer) {
	this.key = GetCookie(keycontainer);
	// UNE FOIS RECUPERE LE COOKIE EST EFFACE
	SetCookie(keycontainer,'');
}

Logon.prototype.NoEncryption = function () {
	this.Logon_Encryption = false;
}

Logon.prototype.Forget = function (choice) {
	this.Logon_forget = choice;
}
Logon.prototype.Retrying = function (ntry) {
	this.Logon_try = ntry;
}

Logon.prototype.SetUsername = function (name) {
	if (this.key == -1)
		this.Logon_username = "Clef non definie";
	else {
		if (this.Logon_Encryption) {
			this.Logon_username = des(this.key, hexToString(name), 0, 0);
			this.Logon_username = this.Logon_username.replace(/\0/g, "");
		} else {
			this.Logon_username = name;
		}
	}
}

Logon.prototype.SetMemoryModeDefault = function (smsd) {
	this.Logon_SetMemoryModeDefault = smsd;
}

Logon.prototype.SetInternational = function (lang,inter,langcookiename,flag,lang_restriction) {
	this.Logon_language         = lang;
	this.Logon_International    = inter;	
	this.Logon_language_cookie  = langcookiename;
	this.Logon_language_flag    = flag;
	this.Logon_language_only    = lang_restriction;
}

Logon.prototype.SetUrl = function (urlyes,urlno) {
	this.Logon_url_yes      = urlyes;
	this.Logon_url_no       = urlno;
}

Logon.prototype.SetFields = function (champusr,champpwd) {
	this.namefield_username  = champusr;
	this.namefield_password  = champpwd;
	this.visiblefield_username = '_VISU_'+this.namefield_username;
	this.visiblefield_password = '_VISU_'+this.namefield_password;
	
}

Logon.prototype.SetMessage = function (msg) {
	this.logon_message  = msg;
}

Logon.prototype.HitCounter = function (_hit,_max) {
	this.logon_cpt_hit  = _hit;
	this.logon_max_hit  = _max;	
}



Logon.prototype.SetTitle = function (title) {
	this.Logon_libtitre_1  = title;
}

Logon.prototype.SetSkin = function (bg) {
	this.Logon_background  = bg;
}

Logon.prototype.SetUserLabel = function (label) {
	this.Logon_libuser    = label;
	this.Logon_libchanged = true;
}

Logon.prototype.SetUsernameIsEmail = function (_isemail) {
	this.Logon_nameisemail = _isemail;
}


Logon.prototype.SetPwdMini = function (mini) {
	this.Logon_pwdmini = mini;
}

Logon.prototype.WriteWindow = function ($body_code,$foot_code) {
	this.WriteStyle();
	document.write('<table width="200" border="0" cellpadding="0" cellspacing="0"><tr><th class="logonnormal" scope="row"><img src="'+this.Logon_directory+'logon_title.gif" width="250" height="57"></th></tr><tr><th height="240" align="left" valign="top"  class="logonnormal" background="'+this.Logon_directory+'logon_status.gif" bgcolor="#FFFFFF" scope="row"><table width="100%" border="0" cellspacing="10"><tr><th scope="row" class="logonnormal"><div align="left">');		   
	document.write($body_code);
	document.write('</div></th></tr></table></th></tr><tr><th height="24" background="'+this.Logon_directory+'logon_foot.gif" scope="row"><div align="right">');
	document.write($foot_code);
	document.write('&nbsp;</div></th></tr></table>');
	this.StartTimer();
}

Logon.prototype.WriteStyle = function () {
	document.writeln('<style type="text/css">');
	document.writeln('.logontitle { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }');
	document.writeln('.logonnormal { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: normal; }');
	document.writeln('.logonlabel { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; line-height: 20px; font-weight: bold;}');
	libbg = (this.Logon_background != '') ? 'background: '+this.Logon_background+';' : '';
	document.writeln('.logonfield { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; '+libbg+'}');
	document.writeln('.logonselect { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; line-height: 20px; '+libbg+'}');
	document.writeln('.logonbtn { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; }');
	
	document.writeln('</style>');
}


Logon.prototype.initcode = function () {
	this.action_en_cours = 'I';
	this.code_js_1 = '';
	this.code_js_1 = '<form ACTION=\'\' method=\'POST\' id=\"LogonFormCnx\" name=\"LogonFormCnx\" onsubmit="return '+this.logon_objname+'.submit_autorise()">';
	this.code_js_1 += '<span class="logontitle">'+this.Logon_libtitre_1+'</span>';
	if (this.Logon_libchanged) {
		labelname = this.Logon_libuser;
	} else {
		if (this.Logon_nameisemail) {
			labelname = this.Logon_libuseremail;
		} else {
			labelname = this.Logon_libusername;
		}
	}
	this.code_js_1 += '<br><br><span class="logonlabel">'+labelname+' :</span>';
	this.code_js_1 += '<br><input type=\"text\" id=\"'+this.visiblefield_username+'\" onFocus="'+this.logon_objname+'.Logon_TimerStop()" value=\"'+this.Logon_username+'\" style="width:210px" class="logonfield"><br><br><span class="logonlabel">'+this.Logon_pwdlabel+' :</span>';
	if (this.logon_message.length>0) {
		this.code_js_1 += '&nbsp;<span class=\"logonlabel\" style=\"color: red\">('+this.Logon_Trying+' '+this.logon_message+')</span>';
	}
	if (this.Logon_forget) {
		if (this.Logon_libchanged) {
			this.code_js_1 += ' <a onMouseOver="'+this.logon_objname+'.Logon_TimerStop()" onClick="location.href=location.href.substring(0,location.href.indexOf(\'?\'))+\'?FORGET\';">';
		} else {
			this.code_js_1 += ' <a onClick="var n_user=LOG_findObj(\''+this.visiblefield_username+'\').value; if ('+this.logon_objname+'.Logon_Encryption) { var c_user=stringToHex(des(\''+this.key+'\',n_user,1,0)); } else {  var c_user=n_user } location.href=location.href.substring(0,location.href.indexOf(\'?\'))+\'?FORGET=\'+c_user;">';
		}
		this.code_js_1 += '<img src="'+this.Logon_directory+this.Logon_IconeQuestion+'"  onMouseOver="'+this.logon_objname+'.Logon_TimerStop()" border="0" title="'+this.Logon_Help_Forget+'"></a>';
	}
	this.code_js_1 += '<br><input type=\"password\" id=\"'+this.visiblefield_password+'\" value=\"'+this.Logon_password+'\" style=\"width:120px\" class="logonfield"  onFocus="'+this.logon_objname+'.Logon_TimerStop();" >';
	this.code_js_1 += '<input type="hidden" name="'+this.namefield_username+'">';
	this.code_js_1 += '<input type="hidden" name="'+this.namefield_password+'">';
	this.code_js_1 += '<input type="hidden" name="'+this.namefield_action+'">';
	// AJOUT DU BOUTON DE CONNEXION
	this.code_js_1 += '&nbsp;<input  type="submit" value="OK" class="logonbtn" style="width:50px" border="0" onClick="'+this.logon_objname+'.initcode_pushOK()">';
	this.code_js_1 += '<br><span id=\"errormsg\" class=\"logonlabel\" style=\"visibility:hidden; color: red\" name=\"errormsg\">'+this.Logon_pwdmodifyerror1+'</span>';
	// AJOUT EVENTUEL DU SELECTEUR DE MEMORISATION
	if (this.Logon_memorymode!=-1) {
		option0 = "";
		option1 = "";
		option2 = "";
		// dans ce cas indetermine on prend l'option definie 
		if (this.Logon_memorymode==0) {
			this.Logon_memorymode = this.Logon_SetMemoryModeDefault;
		}
		switch (this.Logon_memorymode) {
			case 1:
				option1 = "selected";
				break;
			case 2:
				option2 = "selected";
				break;		
			default:
				option0 = "selected";
		}
	    this.code_js_1 += '<br><span class="logonlabel">'+this.Logon_memorymodelabel+' :</span><br><select name=\"memorymode\"  class="logonselect" style=\"width:210px;font-size: 9px\"  onFocus="'+this.logon_objname+'.Logon_TimerStop()">  <option value=\"0\" '+option0+'>'+this.Logon_libselect[0]+'</option>  <option value=\"1\" '+option1+'>'+this.Logon_libselect[1]+'</option>  <option value=\"2\" '+option2+'>'+this.Logon_libselect[2]+'</option></select>';
	} else {
		this.code_js_1 += '<br>';
	}
	// AJOUT EVENTUEL DU SELECTEUR DE LANGUE AU PREMIER ESSAI SEULEMENT
	if (this.Logon_International && this.logon_cpt_hit==1) {

// ET ENSUITE 2 MODES POSSIBLES
		if (this.Logon_language_flag) {	// LES DRAPEAUX
		    this.code_js_1 += '<br><span class="logonlabel">'+this.Logon_otherlanglabel+' :</span><br>';
			for ( var i in this.Logon_t_languagesList ) {
				// controle si il y a restriction sur cette langue
				if (this.Logon_LanguageOK(i)) {
					tlang = LOG_InitLanguageMessages(i);
					// pour tous les langages supportes moins le courant
					if (this.Logon_language!=i) {
						this.code_js_1 += '<a onClick="'+this.logon_objname+'.Logon_ChangeLanguageLib(\''+i+'\')"><img src="'+this.Logon_directory+tlang['FLAG']+'" border="0" title="'+tlang['CHANGETO']+' '+this.Logon_t_languagesList[i]+'" width="16" height="16"></a>';
					}
				}
			} 
			
		} else {
		    this.code_js_1 += '<br><span class="logonlabel">'+this.Logon_changelanglabel+' :</span><br>';
			this.code_js_1 += '<select name=\"languagemode\"  class="logonselect" style=\"width:210px;font-size: 9px\"  onFocus="'+this.logon_objname+'.Logon_TimerStop()" onChange="'+this.logon_objname+'.Logon_ChangeLanguage(this)" >';
			for ( var i in this.Logon_t_languagesList ) {
				// controle si il y a restriction sur cette langue
				if (this.Logon_LanguageOK(i)) {
					libselected = (i==this.Logon_language)?' selected':'';
					this.code_js_1 += '<option value=\"'+i+'\" '+libselected+'>'+this.Logon_t_languagesList[i]+'</option>';
				}
			} 
	    	this.code_js_1 += '</select>';
		}
	}
	this.code_js_1 += '</form>';
	// on se place par defaut dans le champ "mot de passe" quand le "username" est déjà renseigne et que le timer est inactif
	if (this.Logon_username!='' && !this.logon_timer_activated) {
		this.code_js_1 += '<script> var obj=LOG_findObj(\''+this.visiblefield_password+'\'); if (obj) obj.focus(); </script>';
	}
	return this.code_js_1;
}

Logon.prototype.submit_autorise = function () {
	document.getElementById('errormsg').style.visibility = 'hidden';
	if (this.Logon_nameisemail) {
		var obj=LOG_findObj(this.visiblefield_username); 
		if( obj.value=='' || !LOGON_FieldIsEMailAddr(obj)) { 
			LOG_findObj('errormsg').style.visibility = 'visible';
			obj.focus();
			return false;
		}  
	}
	return this.submit_OK;
}

Logon.prototype.Logon_ChangeLanguage = function(obj) {
	this.Logon_ChangeLanguageLib(obj.value);
}

Logon.prototype.Logon_ChangeLanguageLib = function(_lang) {
	// MEMORISATION DANS UN COOKIE
	var today = new Date();
	var expire = new Date();
	expire.setTime(today.getTime() + 3600000*24*365*5);
	document.cookie = this.Logon_language_cookie+"="+escape(_lang)+";expires="+expire.toGMTString()+"; path=/"; 
	window.location.reload();
}


// test si la langue est autorisee
Logon.prototype.Logon_LanguageOK = function(_lang) {
	if (this.Logon_language_only=='') return true;
	var re = new RegExp(_lang)
    return this.Logon_language_only.match(re);
}

// CODE SPECIFIQUE QUAND ON APPUIE SUR "OK" DU CODE CI-DESSUS
Logon.prototype.initcode_pushOK = function () {
	// alert('push OK');
	this.submit_OK = false;
	this.Logon_TimerStop();
	document.getElementById('errormsg').style.visibility = 'hidden';
	if( (LOG_findObj(this.visiblefield_username).value=='') || (LOG_findObj(this.visiblefield_password).value=='') ) {
		LOG_findObj('errormsg').style.visibility = 'visible'; 
		return false;
	}  
	var n_usr=LOG_findObj(this.visiblefield_username).value; 
	if (this.Logon_Encryption) { 
		var c_user=stringToHex(des(this.key,n_usr,1,0)); 
	} else { 
		c_user=n_usr; 
	}  
	var obj=LOG_findObj(this.namefield_username);
	if (obj) {
		obj.value=c_user;
	} else {
		return false;
	}
	if (this.Logon_Encryption) { 
		LOG_findObj(this.namefield_password).value=stringToHex(des(this.key,LOG_findObj(this.visiblefield_password).value,1,0)); 
	} else { 
		LOG_findObj(this.namefield_password).value=LOG_findObj(this.visiblefield_password).value; 
	} 
	LOG_findObj(this.namefield_action).value= 'V'; 
	this.submit_OK = true;
	return true;
}



// CODE SPECIFIQUE A L'ENVOI DU MOT DE PASSE OUBLIE
Logon.prototype.initcodeforget = function (status) {
	this.action_en_cours = 'F';

	this.code_js_1 = '';
	this.code_js_1 = '<form ACTION=\'\' method=\'POST\' id=\"LogonFormCnx\" name=\"LogonFormCnx\" onSubmit="return '+this.logon_objname+'.initcodeforget_onSubmit()">';
	this.code_js_1 += '<img src="'+this.Logon_directory+this.Logon_IconeQuestion+'" border="0">&nbsp;<span class="logontitle">'+this.Logon_pwdforgettitle+'</span>';
	this.code_js_1 += '<br><br><span class="logonlabel">'+this.Logon_libuseremail+' :</span>';
	// on verifie que le champ nom recupere est bien au format email
	if (LOGON_IsEMailAddr(this.Logon_username)) {
		recup_email = this.Logon_username;
	} else {
		recup_email = '';
	}	
	this.code_js_1 += '<br><input type=\"text\" id=\"'+this.visiblefield_username+'\" value=\"'+recup_email+'\"  onFocus="'+this.logon_objname+'.Logon_TimerStop()"';
	if (status>=0) {
		this.code_js_1 += ' readonly="true" ';		
		this.code_js_1 += ' onChange="return ;" ';		
	} else {
		this.code_js_1 += ' onFocus="document.getElementById(\'errormsg\').style.visibility = \'hidden\'" ';		
	}

	
	this.code_js_1 += ' style="width:210px" class="logonfield">';
	this.code_js_1 += '<input type="hidden" name="'+this.namefield_username+'">';
	this.code_js_1 += '<input type="hidden" name="'+this.namefield_password+'">';
	this.code_js_1 += '<input type="hidden" name="'+this.namefield_action+'">';
	switch (status) {
		case -1:
			// AJOUT DU BOUTON D'ENVOI
			this.code_js_1 += '<br><br><input  type="submit" value="'+this.Logon_BtnSend+'" class="logonbtn" style="width:80px" border="0">';
			this.code_js_1 += '&nbsp;<span id=\"errormsg\" class=\"logonlabel\" style=\"visibility:hidden; color: red\" name=\"errormsg\">'+this.Logon_ErrorFmt+'</span>';
			break;
		case 0:
			this.code_js_1 += '<p><img src="'+this.Logon_directory+this.Logon_IconeMailNo+'">&nbsp;<span class=\"logonlabel\" style=\"color: red\">'+this.Logon_MsgNoSended+'</span></p>';
			break;
		default:
			this.code_js_1 += '<p><img src="'+this.Logon_directory+this.Logon_IconeMailYes+'">&nbsp;<span class=\"logonlabel\">'+this.Logon_MsgSended+'</span></p>';
			break;
	}
	if (this.logon_message.length>0) {
		this.code_js_1 += '<span class=\"logonnormal\">'+this.logon_message+'</span>';
	}
	this.code_js_1 += '</form>';
	return this.code_js_1;
}

// CODE SPECIFIQUE QUAND ON APPUIE SUR "OK" DU CODE CI-DESSUS
Logon.prototype.initcodeforget_onSubmit = function () {
	document.getElementById('errormsg').style.visibility = 'hidden';
	var obj=LOG_findObj(this.visiblefield_username); 
	if( obj.value=='' || !LOGON_FieldIsEMailAddr(obj)) { 
		LOG_findObj('errormsg').style.visibility = 'visible';
		return false;
	}  
	LOG_findObj(this.namefield_action).value='F';
	var obj=LOG_findObj(this.namefield_username);
	if (obj) {
		obj.value=stringToHex(des(this.key,LOG_findObj(this.visiblefield_username).value,1,0)); 
	} else {
		return false;
	} 
	return true;		
}


// CODE SPECIFIQUE POUR CHANGER DE MOT DE PASSE
Logon.prototype.initcodechange = function (pwd_changed) {
	this.action_en_cours  = 'C';
	this.code_js_1 = '';

	if (!pwd_changed) {
		var url=location.href.substring(0,location.href.indexOf('?'));
		this.code_js_1 = '<form ACTION=\''+url+'\' method=\'POST\' id=\"LogonFormCnx\" name=\"LogonFormCnx\">';
		this.code_js_1 += '<span class="logontitle">'+this.Logon_pwdmodifytitle+'</span>';
		this.code_js_1 += '<br><br><span class="logonlabel">'+this.Logon_pwdmodifylabel1+' :</span>';
		this.code_js_1 += '<br><input type="password" id="pwd1" value="" style="width:210px" class="logonfield" onFocus="'+this.logon_objname+'.Logon_TimerStop(); document.getElementById(\'errormsg\').style.visibility = \'hidden\';">';
		this.code_js_1 += '<br><span class="logonlabel">'+this.Logon_pwdmodifylabel2+' :</span>';
		this.code_js_1 += '<br><input type="password" id="pwd2" value="" style="width:210px" class="logonfield" onFocus="'+this.logon_objname+'.Logon_TimerStop(); document.getElementById(\'errormsg\').style.visibility = \'hidden\';">';

		this.code_js_1 += '<input type="hidden" name="'+this.namefield_password+'">';
		this.code_js_1 += '<input type="hidden" name="'+this.namefield_action+'" value="C">';

		// AJOUT DU BOUTON D'ENREGISTREMENT
		this.code_js_1 += '<br><br><input  type="submit" value="'+this.Logon_pwdmodifybtn+'" class="logonbtn" style="width:100px" border="0" onClick="document.getElementById(\'errormsg\').style.visibility = \'hidden\'; var n_pwd1=LOG_findObj(\'pwd1\').value; var n_pwd2=LOG_findObj(\'pwd2\').value; if (n_pwd1==n_pwd2 && n_pwd1.length>='+this.Logon_pwdmini+') { c_pwd=stringToHex(des(\''+this.key+'\',n_pwd1,1,0)); LOG_findObj(\''+this.namefield_password+'\').value=c_pwd; return true;} else {LOG_findObj(\'errormsg\').style.visibility = \'visible\'; LOG_findObj(\'pwd1\').value=\'\'; LOG_findObj(\'pwd2\').value=\'\'; return false;}">';
		this.code_js_1 += ' <span id=\"errormsg\" class=\"logonlabel\" style=\"visibility:hidden; color: red\" name=\"errormsg\">'+this.Logon_pwdmodifyerror1+' :<ul><li>'+this.Logon_pwdmodifyerror2+'</li><li>'+this.Logon_pwdmini+' '+this.Logon_pwdmodifyerror3+'</li></ul></span>';
		this.code_js_1 += '</form>';
	} else {
		this.code_js_1 += '<img src="'+this.Logon_directory+'info4.gif">&nbsp;<span class="logontitle">'+this.Logon_pwdmodifyok+'</span>';
	}
	// le timer n'est pas actif avec cette option
	// this.logon_timer_activated = false;
	return this.code_js_1;
}


Logon.prototype.initcodelock = function (msglocked) {
	var codelock = '';
	if (typeof msglocked!="undefined") {
		this.msg_locked = msglocked;
	} else {
		this.msg_locked = this.Logon_accesdenied;
	}
	this.logon_message_lock = '<br><br><br><table width="100%"  border="0"><tr><td><div align="center"><p><img src="'+this.Logon_directory+'lock.jpg"></p><p class="logonlabel">'+this.msg_locked+'</p></div></td></tr></table>';
	
	codelock += '<span class="logontitle">'+this.Logon_libtitre_1+'</span>';
	codelock += this.logon_message_lock;
	return codelock;
}

Logon.prototype.initfootcode = function (connected) {
	if (connected) {
		icone=this.Logon_IconeLoggedYes;
		gotourl=this.Logon_url_yes;
		var messageYesOrNo=this.Logon_Help_IconeLoggedYes;
	} else {
		icone=this.Logon_IconeLoggedNo;
		gotourl=this.Logon_url_no;
		var messageYesOrNo=this.Logon_Help_IconeLoggedNo;
	}
	switch(this.action_en_cours) {
		case 'I':
		case 'F':
			var messageIconeFermer=this.Logon_Help_IconeCloseLoggedNo;
			break;
		case 'C':
			var messageIconeFermer=this.Logon_Help_IconeCloseLoggedYes;
			break;
	}
	// var footcode = '<a href="'+gotourl+'"><span class="logonlabel">Fermer la fenêtre</span></a>';
	var footcode = '';
	if (this.Logon_International) {	
		footcode += '<img src="'+this.Logon_directory+this.Logon_flag+'" border="0" title="'+this.Logon_currentlang+' : '+this.Logon_languageLib+'" width="16" height="16"></a>';
	}
	footcode += '<img src="'+this.Logon_directory+icone+'" border="0" title="'+messageYesOrNo+'"></a>';
	footcode += '&nbsp;<a href="'+gotourl+'"><img src="'+this.Logon_directory+this.Logon_IconeClose+'" border="0" title="'+messageIconeFermer+'"></a>';
	return footcode;
}

Logon.prototype.SetMemoryMode = function (nummode) {
	// -1 : (= 0) mais ne l'affiche pas
	this.Logon_memorymode = nummode;

}



// FONCTION DE TIMER
Logon.prototype.SetTimer = function (_ttl) {
	//alert('set timer');
		this.logon_timer_ttl       = _ttl; 
		this.logon_timer_activated = true;
}

Logon.prototype.StartTimer = function() {
		if (!this.logon_timer_activated) return;
		var cTicks = this.logon_timer_ttl;
		// en fonction de l'action en cours le branchement automatique se fait soit sur l'url_yes soit sur l'url_no
		switch(this.action_en_cours) {
			case 'I':
			case 'F':
				// au bout de x secondes la page se branche automatiquement a l'url NO
				var url    = this.Logon_url_no;
				break;
			case 'C':
				var url    = this.Logon_url_yes;
				break;
		}

		var evalfct = this.logon_objname +'.Logon_TimerTest()';
		if( cTicks ) {
			--cTicks;
		}
		var timer = setInterval(function()
			{
				valret = eval(evalfct);
				if (valret) {
					if( cTicks ) {
						--cTicks;
					} else {
				       	clearInterval(timer);					
						location = url;	  
					}
				} else {
					clearInterval(timer);
				}
			}, 1000 );

}	

Logon.prototype.Logon_TimerTest = function() {
		//alert('Timer test');
	return (this.logon_timer_activated);
}

Logon.prototype.Logon_TimerStop = function() {
		//alert('Timer stop');
	this.logon_timer_activated = false;
}

