function launchOnEnter(expression) {
  if(event.keyCode==3 || event.keyCode==13) {
    eval(expression);
  }
}

function goPop(typerubrique, rubriqueid, elementid, offset, nbrec, firstrec, height, width, ajout) {
  window.open('','popupDetails'+ajout,'scrollbars,resizable,status=yes,toolbar=no,directories=no,width='+width+',height='+height);
  document.getElementById('submitor').target = 'popupDetails'+ajout;
  document.getElementById('submitor').typerubrique.value = typerubrique;
  document.getElementById('submitor').rubriqueid.value = rubriqueid;
  document.getElementById('submitor').elementid.value = elementid;
  document.getElementById('submitor').offset.value = offset;
  document.getElementById('submitor').nbrec.value = nbrec;
  document.getElementById('submitor').openMode.value = "POPUP";
  document.getElementById('submitor').firstrec.value = firstrec;
  document.getElementById('submitor').submit();
  document.getElementById('submitor').target = '';
}

function openSite(liste) {
  open(liste.options[liste.selectedIndex].value, 'Site');
}

var timer=setTimeout('1',0);

function setEnr(enregistrementid,firstenr,nbenr) {
  document.getElementById('submitor').enregistrementid.value = enregistrementid;
  document.getElementById('submitor').nbenr.value = nbenr;
  document.getElementById('submitor').firstenr.value = firstenr;
} 



function setTimer(s) {
  clearTimeout(timer);
  timer=setTimeout(s,600);
}
  
function go(typerubrique,rubriqueid,elementid,offset,nbrec,firstrec) {
  document.getElementById('submitor').target='';
  document.getElementById('submitor').typerubrique.value = typerubrique;
  document.getElementById('submitor').rubriqueid.value = rubriqueid;
  document.getElementById('submitor').elementid.value = elementid;
  document.getElementById('submitor').offset.value = offset;
  document.getElementById('submitor').nbrec.value = nbrec;
  document.getElementById('submitor').firstrec.value = firstrec;
  document.getElementById('submitor').openMode.value = "";
  document.getElementById('submitor').submit();
} 

function notgood(field,msg) {
  field.focus();
  alert(msg);
  return false;
}

function isFull(field,msg){
  if (field.value=='') {return notgood(field,msg);}
  return true;
}

function isDigit(field,msg) {
  i = field.value.charCodeAt(0);
  if (!((47<i)&&(i<58))){return notgood(field,msg);}
  return true;
}

function isSelect(field,msg){
  if (field.selectedIndex==0 && field.options[0].value=="") {return notgood(field,msg);}
  return true;
}

function isMail(field,msg) {
  email=field.value;
  arobase=email.indexOf('@');
  point=email.indexOf('.',arobase);
  longueur=email.length;
  if(arobase<=0||point<=arobase+1||longueur<=point+1) {return notgood(field,msg);}
  return true;
}

function goMail(elementid,zeracine) {
  mailfen = window.open('','mail','scrollbars,toolbar=no,directories=no,width=350,height=200');
  racine=zeracine;
  
  imgLoad =new Image; imgLoad.src= racine + 'img/wait.gif';
  imgLoad.height=73;
  imgLoad.width=75;
  
  mailfen.moveTo((screen.width/2)-(350/2),(screen.height/2)-(200/2));
  
  wait = setTimeout("if(imgLoad.complete){writeMessageBeforeMailAndSend("+elementid+");}",315);    
}  

function writeMessageBeforeMailAndSend(elementid){
  mailfen.document.writeln('<html>');
  mailfen.document.writeln('<head>');
  mailfen.document.writeln('  <title>Envoi de message</title>');
  mailfen.document.writeln('</head>');
  mailfen.document.writeln('<body>    ');
  mailfen.document.writeln('  <table cellpadding="0" border="0" cellspacing="0" width="100%">');
  mailfen.document.writeln('    <tr>');
  mailfen.document.writeln('      <td align="center">');
  mailfen.document.writeln('        &#160;');
  mailfen.document.writeln('      </td>');
  mailfen.document.writeln('    </tr>');
  mailfen.document.writeln('    <tr>');
  mailfen.document.writeln('      <td align="center">');
  mailfen.document.writeln('        &#160;');
  mailfen.document.writeln('      </td>');
  mailfen.document.writeln('    </tr>');
  mailfen.document.writeln('    <tr>');
  mailfen.document.writeln('      <td align="center">');
  mailfen.document.writeln('        <span class="texte">');
  mailfen.document.writeln('          <img height="73" width="75" id="wait" src="' + racine + 'img/wait.gif"/>');
  mailfen.document.writeln('        </span>');
  mailfen.document.writeln('      </td>');
  mailfen.document.writeln('    </tr>');
  mailfen.document.writeln('    <tr>');
  mailfen.document.writeln('      <td align="center" style="font-family:verdana;font-size:10px;">');
  mailfen.document.writeln('        <span class="texte">');
  mailfen.document.writeln('          Veuillez patienter...');
  mailfen.document.writeln('        </span>');
  mailfen.document.writeln('      </td>');
  mailfen.document.writeln('    </tr>');
  mailfen.document.writeln('  </table>   ');    
  mailfen.document.writeln('</body>');
  mailfen.document.writeln('</html>');
  
  document.getElementById('submitor').target = 'mail';
  document.getElementById('submitor').action = racine + 'xsltMailer.aspx';
  ///alert(document.getElementById('submitor').elementid);
  document.getElementById('submitor').elementid.value = elementid;
  document.getElementById('submitor').submit();
  document.getElementById('submitor').target = '';
  document.getElementById('submitor').action='xslt.aspx';    
  document.getElementById('submitor').reset();
}

          var top = 0;
    	  var s1,s2;
              
          function prepare() {
            s1 = document.getElementById('scroller1');
            s2 = document.getElementById('scroller2');
            s2.style.top = s1.offsetHeight;
            setTimeout("move()",120);
          }
          
          function move() {
            top -= 2;
            s1.style.top = top + 'px';
            s2.style.top = top + 'px';
            if (Math.abs(top)>s1.offsetHeight) {
              top = 0;
              s1.parentNode.removeChild(s1);
              s2.style.top = top + 'px';
              s2.parentNode.appendChild(s1);
              s1.style.top = top + 'px';
              s = s2;
              s2 = s1;
              s1 = s;
            }
            setTimeout("move()",120);
          }
  
         function recherche() {
           var chaine = document.getElementById('submitor').rec112_tb.value ;
           
           var reg=new RegExp("\\s{2,}", "g");
           var regCleanSmallWord=new RegExp("\\s\\S{1,2}\\s", "g");
           var reg2=new RegExp("\\sor\\s", "g");
           var reg3=new RegExp("\\sand\\s", "g");
           var reg2b=new RegExp("\\sou\\s", "g");
           var reg3b=new RegExp("\\set\\s", "g");
           
           var reg4=new RegExp("\\s", "g");           
           
           var reg5=new RegExp("µµorµµ", "g");
           var reg6=new RegExp("µµandµµ", "g");
           
           chaine=chaine.toLowerCase().replace(reg, ' ').replace(reg2,'µµorµµ').replace(reg2b,'µµorµµ').replace(reg3,'µµandµµ').replace(reg3b,'µµandµµ').replace(regCleanSmallWord,' ').replace(reg4,' and ').replace(reg5,' or ').replace(reg6,' and ');
           document.getElementById('submitor').rec112.value=chaine ;
           
           if(chaine.length > 2){
           //alert(chaine);
           go(1,10,'','',1,112);
           }else{
             alert('Vous devez renseigner au moins 3 caractères.');
           }
         }
         
function setBloc(){  
  //Si un des blocs gauche ou droit est plus grand que le central, on resize ce dernier
  var left=document.getElementById("content2"); 
  var right=document.getElementById("contenu"); 
  var offset = 222;

  
  //Le droit est plus grand
  if((left.offsetHeight + offset) <=right.offsetHeight){
    left.style.height=((right.offsetHeight) - offset)+'px';    
    return;
  }
  //Le gauche est plus grand
  if(right.offsetHeight<=(left.offsetHeight) + offset){
    right.style.height=((left.offsetHeight) + offset)+'px';    
    return;
  }    
}         

function setAlignementMenu(){
  //fonction permettant de changer le mode d'alignement du fil d'ariane
  //Si le file d'ariane tient sur 2 lignes alors on aligne a gauche Sinon on aligne a droite
   
  //valeur 15 => une ligne et 28 => deux lignes  etc. 
  var fil=document.getElementById("filAriane"); 
  
  if (fil.offsetHeight < 28){
    fil.className="UneLigne";
  }else{
    fil.className="DeuxLigne";
  }
	
}


