function showLostPasswordForm(path,lng) {
  var tabLang = new Array(1);
  if(lng == "fr") {
    tabLang[0] = "Se connecter"; 
  } else if(lng == "en"){
    tabLang[0] = "Connect";
  }

  $('action').writeAttribute("value","lost_password");
  $('email_conteneur').update("<span>E-mail&nbsp;:&nbsp;</span><input id=\"email\" name=\"email\" type=\"text\">");
  $('password_conteneur').hide(); 
  $('valider').writeAttribute("onclick","retrievePassword('" + path + "','" + lng + "')");
  $('mdp_oublie').update("<a href=\"#\" onclick=\"showLoginForm('"+ path +"','"+ lng +"');\" title=\"" + tabLang[0] + "\">" + tabLang[0] + "</a>");
}

function showLoginForm(path,lng){
  var tabLang = new Array(3);
  if(lng == "fr") {
    tabLang[0] = "Retrouver son mot de passe"; 
    tabLang[1] = "Mot de passe oubli&eacute; ?";
    tabLang[2] = 'Identifiant';
  } else if(lng == "en"){
    tabLang[0] = "Recover password";
    tabLang[1] = "Lost password?";
    tabLang[2] = 'Login';
  }
  
  $('action').writeAttribute("value","login_front");
  $('email_conteneur').update("<span>" + tabLang[2] + "&nbsp;:&nbsp;</span><input id=\"email\" name=\"email\" class=\"validate-email required\" type=\"text\">");
  $('password_conteneur').show();
  $('valider').writeAttribute("onclick","this.form.submit();");
  $('mdp_oublie').update("<a href=\"#\" onclick=\"showLostPasswordForm('" + path + "','"+ lng +"');\" title=\"" + tabLang[0] + "\">" + tabLang[1] + "</a>");
}

function retrievePassword(path) {
  var params = {
  	action : $F('action'), 
  	email : $F('email')
	};
  new Ajax.Request(path + 'executer.php', {
        method: "post",
        parameters: params,
        encoding: 'UTF-8',
        onSuccess: function(transport) {
          $('confirm_recover').update(transport.responseText);
          $('confirm_recover').appear({ duration: 1.5 }); 
          setTimeout("cacheConfirm()",4000); 
        },
        onFailure: function(){
          $('confirm_recover').update(transport.responseText);
          $('confirm_recover').setStyle("color","#582216");
          $('confirm_recover').appear({ duration: 1.5 }); 
          setTimeout("cacheConfirm()",4000); 
        }
  });
}

function cacheConfirm() {
  $('confirm_recover').fade({ duration: 1.5 });
}

// writeAttribute = function(element, name, value) { 
//   element = $(element); 
//   var attributes = { }, t = Element._attributeTranslations.write;
// 
//   if (typeof name == 'object') 
//     attributes = name; 
//   else 
//     attributes[name] = Object.isUndefined(value) ? true : value;
// 
//   for (var attr in attributes) { 
//     name = t.names[attr] || attr; 
//     value = attributes[attr]; 
//     if (t.values[attr]) 
//       name = t.values[attr](element, value); 
//     if (value == false || value == null) 
//       element.removeAttribute(name); 
//     else if (value == true) 
//       element.setAttribute(name, name); 
//     else 
//       element.setAttribute(name, value);
//     if(attr == "class" && element["className"] == "") { 
//       element.removeAttribute(name); element.setAttribute(attr, value); 
//     } 
//   }
//   return element; 
// }; 
