function launchOnEnter(expression) {
  if(event.keyCode==3 || event.keyCode==13) {
    eval(expression);
  }
}

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 Bip(id) { 
  var mesDivs = document.getElementsByTagName("div");
  for(var i=0; i<mesDivs.length; i++) {
    if(mesDivs[i].id.indexOf('menu')==0) {
      mesDivs[i].style.visibility = "hidden";
    }
  }
  document.getElementById('menu'+id).style.visibility='visible';
}

function adjustMenu(no,pos,lg,y) {
  if (document.body.clientWidth > 780) {
    x_sup = (document.body.clientWidth-780) / 2;
  }
  else {
    x_sup = 0;
  }
  x = lg * (pos-1) + x_sup;
  document.getElementById('menu'+no).style.left = x+'px';
  document.getElementById('menu'+no).style.top = y+'px';
}

function adjustMain() {
  x = 0;
  y = 0;
  if (document.body.clientWidth > 780) {
    x_sup = (document.body.clientWidth-780) / 2;
  }
  else {
    x_sup = 0;
  }
  if (document.body.clientHeight > 480) {
    y_sup = (document.body.clientHeight-480) / 2;
  }
  else {
    y_sup = 0;
  }
  x = x_sup + 495;
  y = y_sup + 5;
  y = 5;
  document.getElementById('menuContenu').style.left = x+'px';
  document.getElementById('menuContenu').style.top = y+'px';
}  
         
function Boup(id) {                
  document.getElementById('menu'+id).style.visibility='hidden';
}                 
    
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').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').reset();
  document.getElementById('submitor').target = '';
  document.getElementById('submitor').action='xslt.aspx';    
}
  
function goSousMenu(arbo){
  var nbDiv = document.getElementById('menu').getElementsByTagName('div').length;
  var sub;
  var divEnCours;
  for ( var i = 0 ; i < nbDiv ; i++ )
  {
    divEnCours = document.getElementById('menu').getElementsByTagName('div')[i];
    if(divEnCours.id != ''){
      sub = divEnCours.id.substring(0,8);
      if(sub == arbo){
        divEnCours.style.display = '';
      }
      else{
        divEnCours.style.display = 'none';
      }   
    }
  }
}

function emptySearch(inputObj,txt){
  if(inputObj.value==txt){
    inputObj.value="";
  } 
}
function fillSearch(inputObj,txt){
  if(inputObj.value==""){
    inputObj.value=txt;
  } 
}