function refreshAuthentication(){
	if($("mesListes")==null){
		new Ajax.Request(	'/client/componentClient/authentification.jsp', 
							{	method:'POST', 
								onSuccess: function(response) {
									document.getElementById('AWL_REFRESH').innerHTML = response.responseText;
								}
							}
						);
	}
}

AuthenticationUp = Class.create();
AuthenticationUp.prototype = {
			
	initialize: function () {
		this.form = document.connectionUser;
		this.form.inputLogin.value = "";
		this.fC = new FormCheck();
		this.fC.registerMandatoryEmailInputText(this.form.inputLogin);
		this.fC.registerInputText(this.form.inputPass);
		this.fC.registerMandatoryInputText(this.form.inputPass,6);
		
		
		this.fields = this.fC.getAllMandatoryItems();
		this.errorsTxt = new Array($("error_email"),$("error_psw"));
		Event.observe($("validAccount"),"click",this.check.bind(this,true));
		
		Event.observe(this.form.inputPass,"blur",this.setChangeIput.bind(this,0));
		Event.observe(this.form.inputPass,"focus",this.setChangeIput.bind(this,1));
		
		this.form.inputLogin.value = this.form.inputLogin.alt;
		this.form.inputPass.value = this.form.inputPass.alt;
		
		this.formPwd = document.getMyPassword;
		this.formPwd.inputEmailGetMyPassword.value = "";
		this.fCPwd = new FormCheck();
		this.fCPwd.registerMandatoryEmailInputText(this.formPwd.inputEmailGetMyPassword);
		//Event.observe(this.formPwd.inputEmailGetMyPassword,"blur",this.getMyPassword.bind(this,false));
	},
			
	check: function (e,submitForm) {
		var chError = "";
		
		if(this.form.inputLogin.value == '' || this.form.inputLogin.value == this.form.inputLogin.alt){
			chError += ErrorMsg.emailEmpty+"<br />";
		}
		else if(!this.fC.validEmail(this.form.inputLogin.value)){
			chError += ErrorMsg.emailNotValid+"<br />";
		}
			
		if(this.form.inputPass.value == '' || this.form.inputPass.value == this.form.inputPass.alt){
			chError += ErrorMsg.pwdEmpty+"<br />";
		}
		
		if(this.form.inputPass.value != '' && this.form.inputPass.value.length<6){
			chError += ErrorMsg.pwdNotValid+"<br />";
		}
		
		if(chError != ""){
			$("errorContent").innerHTML = "<div class=\"PI_txtError\">"+chError+"</div>";
			PI_loadLay('errorLay','log');
		}
		else{
			// FORMULAIRE OK ---> SEND
			this.send();
		}
		
	},
	
	setChangeIput: function (id) {
		/*if(id == 1){
			this.form.inputPass.type = "password";
		}
		else{
			if(this.form.inputPass.value == '' || this.form.inputPass.value == this.form.inputPass.alt){
				this.form.inputPass.type = "text";
			}
		}*/
		
	},
	
	result: function (valid,typeError) {
		if (!valid&&typeError=="email") { PI_loadLay('errorLayEmail'); }
		else if (!valid&&typeError=="password") { PI_loadLay('errorLayPassword'); }
	},
	
	getMyPassword: function (submitForm) {
		$("error_emailGetPwd").innerHTML = "";
		var email = this.formPwd.inputEmailGetMyPassword.value;
		if (email==""&&submitForm) { $("error_emailGetPwd").innerHTML = ErrorMsg.emailEmpty; }
		else if (!this.fCPwd.validEmail(email)&&email!="") { $("error_emailGetPwd").innerHTML = ErrorMsg.emailNotValid; }
		else {  this.sendPassword(email); }
	},
	
	sendPassword: function (email) {
		// Send Password
		var url = '/client/componentClient/envoiPwdParEmail.jsp';
		var listeParameters = 'email='+email;
		var myAjaxConnection = new Ajax.Request
			(url, {	method:'POST',
					parameters:listeParameters,
					onComplete:this.callBack.bindAsEventListener(this,email)});
	},
	
	callBack:function(e,email){
		//alert("CallBack => "+e);
	    // affiche validation le layer de confirmation
	    setCont('id','lbEmailLayPwd3',null,email);
	    PI_removeLay();
	    //PI_loadLay('errorLayPassword3');
	},
	
	send: function () {
		// Send formulaire
		myAuthenticationUp.form.action="/client/componentClient/authentification.jsp?connectionUser=true";
		myAuthenticationUp.form.submit();
	}
			
}

var myAuthenticationUp;

Event.observe(window,"load",function () {
	if($("connectionUser")) myAuthenticationUp = new AuthenticationUp();
});	