function doLang(oLink,langue) {
  try {
    var OK =0; //verifie si la langue est trouvée
    //decoupage de l'URL
    var aLang = window.location.pathname.split("\/");
    var newURL = "";
    //recherche de la langue
    for(i=1;i<aLang.length-1;i++){  // on ne prend pas en compte le dernier element, qui est la page html
      if(aLang[i].length == 2 ){ //si une chaine de 2 lettres est trouvée  
        newURL +="/"+langue;
        OK = 1;
      } else {
        newURL +="/"+aLang[i];
      }
    }
    //si la langue n'a pas été trouvée, on l'ajoute
    if(OK == 0){
      newURL +="/"+langue;
    }

    //ajout de la page en cours

    if(window.location.href.indexOf(".html") != -1){
        var indice = window.location.href.lastIndexOf('/'); //position de l'indice ou l'on doit découper
        newURL +=window.location.href.substring(indice);  //recuperation de la fin de l'url
    } else {
        newURL +="/accueil.html";  //recuperation de la fin de l'url
    }
    oLink.href=newURL;
 } catch(e) {
   alert(e.message);
 }
} 

/*function doLang(oLink) {
  try {
    //get new Language from link HREF
    var aLang=oLink.href.split(/\./);
    var sNewLang=aLang.pop().substr(0,2);
    //get current page name
    var aPath=document.location.pathname.split(/\//);
    var aPage=aPath.pop().split(/\./);
    var sPath=aPath.join("/")+"/";
    if(sPath.substr(0,1)=="/") sPath=sPath.substr(1);
    var sPage=aPage.length < 2?"index":aPage[0].replace(/_(br)$/,"");
    //set new page name 
    var sNewPage=(/^(br)$/i.test(sNewLang)?sPage+"_"+sNewLang:sPage)+".html";
    //update link
    oLink.href=oLink.href+sPath+sNewPage;
 } catch(e) {
   alert(e.message);
 }
} */

function doHome(oLink) {
  //get new Language from link HREF
  var aLang=oLink.href.split(/\//);
  var sPage=aLang.pop();
  var sNewLang=aLang.pop();
  var aPath=document.location.pathname.split(/\//);
  var aPageLang=aPath.pop();
  aPageLang=aPath.pop();
  oLink.href=(aPageLang.length==2?"../":"")+(/^(br)$/i.test(sNewLang)?sNewLang+"/accueil_"+sNewLang+".html":"index.html");
} 