function launchOnEnter(expression) {
  if(event.keyCode==3 || event.keyCode==13) {
    eval(expression);
  }
}

var timer=setTimeout('1',0);

function setEnr(enregistrementid,firstenr,nbenr){
  document.submitor.enregistrementid.value = enregistrementid;document.submitor.nbenr.value = nbenr;document.submitor.firstenr.value = firstenr;
} 
function Bip(id)
{ 
  var mesDivs = document.getElementsByTagName("DIV");
  for(var i=0; i<mesDivs.length; i++) {
    mesDivs[i].style.visibility = "hidden";
  }
   if (navigator.appName=='Microsoft Internet Explorer') {
    eval('document.all.menu'+id+'.style.visibility=\'visible\'');
  }
  else {
    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;
  eval('document.all.menu'+no+'.style.pixelLeft = x');
  eval('document.all.menu'+no+'.style.pixelTop = y');
}

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;
  eval('document.all.menuContenu.style.pixelLeft = x');
  eval('document.all.menuContenu.style.pixelTop = y');  
}  
         
function Boup(id) {                
  if (navigator.appName=='Microsoft Internet Explorer')
  {
       eval('document.all.menu'+id+'.style.visibility=\'hidden\'');
  }
  else
  {
       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.submitor.target='';
  document.submitor.typerubrique.value = typerubrique;document.submitor.rubriqueid.value = rubriqueid;
  document.submitor.elementid.value = elementid;document.submitor.offset.value = offset;
  document.submitor.nbrec.value = nbrec;
  document.submitor.firstrec.value = firstrec;
  document.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;
}

var mailfen;
var imgLoad;
var racine;

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 logon() {
    document.submitor.action="http://extranetindexel.activsoft.com/xslt.aspx";
    document.submitor.method="POST";
    setEnr('1','','');
    go('1','1','','','','');
  }

  
  function NewsInitResize(){
    var offsetClient;
    

    var wid = (document.body.clientWidth);
    
    
    if (wid > 900){ 
      offsetClient=((wid-900)/2)+225;
    }else{
           offsetClient=225;
    }

    

// Test effectué sur {IE 6, Firefox 1.0.7, Mozilla 1.7, Netscape 7} => Tout OK

     document.getElementById("mainnews").style.left = offsetClient;
     document.getElementById("mainnews").style.top = document.getElementById("NewsContent").offsetTop + document.getElementById("NewsReader").offsetTop + 234
     document.getElementById("mainnews").style.width = document.getElementById("NewsContent").offsetWidth -1
     document.getElementById("mainnews").style.height = document.getElementById("NewsContent").offsetHeight - 1  
  
  }
  
  
  function NewsInit(){


var offsetClient;
    var wid = (document.body.clientWidth);
    
    if (wid > 900){ 
      offsetClient=((wid-900)/2)+225;
    }else{
           offsetClient=225;
    }


// Test effectué sur {IE 6, Firefox 1.0.7, Mozilla 1.7, Netscape 7} => Tout OK
     document.getElementById("mainnews").style.left = offsetClient;
     document.getElementById("mainnews").style.top = document.getElementById("NewsContent").offsetTop + document.getElementById("NewsReader").offsetTop + 234
     document.getElementById("mainnews").style.width = document.getElementById("NewsContent").offsetWidth -1
     document.getElementById("mainnews").style.height = document.getElementById("NewsContent").offsetHeight - 1
    ScrollNews()
}

var newsblock
var topinit = 150    //    point de depart
var Index = 0    //    index dans la collection de news
var OldIndex = 0    //    index d'avant
var Top = topinit    //    valeur courante
var start = 1
// ICI ON DECLARE UNE VAR QUI CONTIENT UN ENTIER, QUI CORRESPOND
// ON NOMBRE DE NEWS, GENERALEMENT CA SERA DONNE PAR UNE REQ SQL
var nbnews = 2 // de 0 à 2 => 3

function ScrollNews(){
     if (Top == 4)
         {
             OldIndex = Index
// SI Index SUP OU EG A nbnews - 1 sois news2 DONC DERNIERE NEWS A AFFICHER
// ALORS Index= 0
// SINON INCREMENT Index
             Index >= (nbnews - 1) ? Index = 0 : Index++ 
             Top = topinit
             setTimeout("ScrollNews()",2000)
             start=0
             return false
         }
     if (Top == (topinit-1)) {document.getElementById("news" + OldIndex).style.top = topinit}
     Top--
     document.getElementById("news" + Index).style.top = Top
     if (start==0){document.getElementById("news" + OldIndex).style.top = Top-146}
     setTimeout("ScrollNews()",5)
}

