function VerifEntreeLimite(entree, limit) {
  if (typeof limit == 'undefined')
    limit = /.*/;

  for(var i=0; i<entree.length; i++)
  {
    var charIn = entree.charAt(i);
	if (!charIn.match(limit))
	  return false;
  }
  return true;
}

function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
}
}
}
}

function badconnexion()
{ alert("Problème de connexion, veuillez vérifier votre login et/ou votre mot de passe");
}


function ValiDate(obj, format){
dateBits = DateComponents(obj.value, format);
if (dateBits == null) return false;
day = dateBits[0];
month = dateBits[1];
year = dateBits[2];

if ((month < 1 || month > 12) || (day < 1 || day > 31)) { // check month range
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
return false;
}
if (month == 2) {
// check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
return false;
}
}
return true;
}

function DateComponents(dateStr, format) {
var results = new Array();
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = dateStr.match(datePat);

if (matchArray == null) return null;
// parse date into variables
if (format.charAt(0)=="d"){ //format=dd/mm
results[0] = matchArray[1];
results[1] = matchArray[3];
} else {
results[1] = matchArray[1];
results[0] = matchArray[3]; }
results[2] = matchArray[4];
return results;
}

function verifdatepasse1()
{
document.forms[0].action="Passe.php5";
if (document.forms[0].b_deb_val != null )
{
if ( ValiDate( document.forms[0].b_deb_val, "dd/mm/yyyy"))
{}
else
{alert ("Le format date n'est pas correct (dd/mm/aaaa)");
document.forms[0].b_deb_val.focus();}
}
}
//modif lvt 30/08/05
//indique si date1<date2 au format jj/mm/aaaa
function verifordredate(date1,date2)
{
  if (date1 == "") {
    alert("La date de début est vide");
    return  false;
  }
  if (date2 == "") {
    alert("La date de fin est vide");
    return  false;
  }
  e = new RegExp("^[0-9]{1,2}\/[0-9]{1,2}\/([0-9]{2}|[0-9]{4})$");
     
  if (!e.test(date1)) {
    alert("La date de début n'est pas valide");
    return  false;
  }
  if (!e.test(date2)) {
    alert("La date de fin n'est pas valide");
    return  false;
  }
  
  // On sépare la date en 3 variables pour vérification, parseInt() converti du texte en entier
  jdate1 = parseInt(date1.split("/")[0], 10); // jour
  mdate1 = parseInt(date1.split("/")[1], 10); // mois
  adate1 = parseInt(date1.split("/")[2], 10); // année
  jdate2 = parseInt(date2.split("/")[0], 10); // jour
  mdate2 = parseInt(date2.split("/")[1], 10); // mois
  adate2 = parseInt(date2.split("/")[2], 10); // année

  //on compare les années
  if (adate1<adate2){
     return true;
  }else if(adate1>adate2){
    alert("La date de début est supérieure à la date de fin");
    return false;
  }else if(mdate1<mdate2){  //adate1==adate2
     return true;
  }else if(mdate1>mdate2){
    alert("La date de début est supérieure à la date de fin");
    return false;
  }else if(jdate1<=jdate2){  //mdate1==mdate2
     return true;
  }else {
    alert("La date de début est supérieure à la date de fin");
    return false;
  }
}

function verifdatepasse2()
{
document.forms[0].action="Passe.php5";
if (document.forms[0].b_fin_val != null )
{
if ( ValiDate( document.forms[0].b_fin_val, "dd/mm/yyyy"))
{}
else
{alert ("Le format date n'est pas correct (dd/mm/aaaa)");
document.forms[0].b_fin_val.focus();}
}
}

function verifdateNpasse1()
{
document.forms[0].action="NewPasse.php5";
if (document.forms[0].b_deb_val != null )
{
if ( ValiDate( document.forms[0].b_deb_val, "dd/mm/yyyy"))
{}
else
{alert ("Le format date n'est pas correct (dd/mm/aaaa)");
document.forms[0].b_deb_val.focus();}
}
}

function verifdateNpasse2()
{
document.forms[0].action="NewPasse.php5";
if (document.forms[0].b_fin_val != null )
{
if ( ValiDate( document.forms[0].b_fin_val, "dd/mm/yyyy"))
{}
else
{alert ("Le format date n'est pas correct (dd/mm/aaaa)");
document.forms[0].b_fin_val.focus();}
}
}

function passe()
{
if(document.forms[0].a.value==1)
{document.forms[0].a.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function passe2()
{
if(document.forms[0].a.value==0)
{
  if (document.forms[0].si.value==1)
  { 
    document.forms[0].si.value=0;
  }
  document.forms[0].a.value=1;
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}

function param()
{
if(document.forms[0].p.value==1)
{document.forms[0].p.value=0;
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}


function param2()
{
  if(document.forms[0].p.value!=1)
  {
    document.forms[0].p.value=1;
    //on ferme le noeud clés
    document.forms[0].ba.value=0;
    //on ferme le noeud édition des messages
    document.forms[0].EdtMess.value=0;
    //on ferme le noeud Action sur entree
    document.forms[0].ActionEntre.value=0;
  }
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}


function site(code)
{
if(document.forms[0].b.value==1+"|"+code){

document.forms[0].b.value=0+"|"+code;
}
var csi="#"+code;
document.forms[0].action="init.php5"+csi;
document.forms[0].submit();
}


function site2(code)
{

document.forms[0].b.value=1+"|"+code;
var csi="#"+code;

document.forms[0].action="init.php5"+csi;
document.forms[0].submit();
}


function porte()
{
if(document.forms[0].c.value==1)
{document.forms[0].c.value=0;
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}


function porte2()
{
if(document.forms[0].c.value==0)
{document.forms[0].c.value=1;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}

function LectSpe()
{
  if(document.forms[0].LS.value==1)
  {
    document.forms[0].LS.value=0;
  }
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}


function LectSpe2()
{
  if(document.forms[0].LS.value==0)
  {
    document.forms[0].LS.value=1;
  }
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}

function Centrale()
{
  if(document.forms[0].Centr.value==1)
  {
    document.forms[0].Centr.value=0;
  }
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}


function Centrale2()
{
  if(document.forms[0].Centr.value==0)
  {
    document.forms[0].Centr.value=1;
  }
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}

function autorisation()
{
if(document.forms[0].d.value==1)
{document.forms[0].d.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function autorisation2()
{
if(document.forms[0].d.value==0)
{
document.forms[0].d.value=1;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}

function NoeudZone1()
{
  if(document.forms[0].Zones.value==1)
  {document.forms[0].Zones.value=0;}
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}


function NoeudZone2()
{
  if(document.forms[0].Zones.value==0)
  {document.forms[0].Zones.value=1;}
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}


function residence()
{
if(document.forms[0].e.value==1)
{document.forms[0].e.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function residence2()
{
if(document.forms[0].e.value==0)
{document.forms[0].e.value=1;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function res(code)
{
if(document.forms[0].r.value==1+"|"+code){

document.forms[0].r.value=0+"|"+code;
document.forms[0].cpl2.value="";
}
var cre="#"+code;
document.forms[0].action="init.php5"+cre;
document.forms[0].submit();
}

function res2(code)
{

document.forms[0].r.value=1+"|"+code;
document.forms[0].cr2.value=code+"#"+code;
document.forms[0].submit();
}


function vigik()
{
if(document.forms[0].f.value==1)
{document.forms[0].f.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function vigik2()
{
if(document.forms[0].f.value==0)
{document.forms[0].f.value=1;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}

function badgesupp()
{
if(document.forms[0].g.value==1)
{document.forms[0].g.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function badgesupp2()
{
if(document.forms[0].g.value==0)
{
  //Ouverture du noeud badges supprimés
  document.forms[0].g.value=1;
  //fermeture du noeud cles non résidants
  document.forms[0].y.value=0;
  //fermeture du noeud apparts
  document.forms[0].ap.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}

function parking()
{
if(document.forms[0].h.value==1)
{
  document.forms[0].h.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function parking2()
{
if(document.forms[0].h.value!=1)
{
  //ouverture du noeud parking
  document.forms[0].h.value=1;
  //fermeture du noeud accès communs
  document.forms[0].x.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}

function nonresidents()
{
  if(document.forms[0].y.value==1)
  {
    document.forms[0].y.value=0;
  }
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}

function nonresidents2()
{
if(document.forms[0].y.value==0)
{
  //ouverture du noeud non residants
  document.forms[0].y.value=1;
  //fermture du noeud badges supprimés
  document.forms[0].g.value=0;
  //fermture du noeud apparts
  document.forms[0].ap.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function communs()
{
if(document.forms[0].x.value==1)
{
  document.forms[0].x.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function communs2()
{
if(document.forms[0].x.value==0)
{
  //ouverture du noeud accès communs
  document.forms[0].x.value=1;
  //fermeture du noeud Parking
  document.forms[0].h.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


function badge(code)
{
if(document.forms[0].aa.value==1+"|"+code){

document.forms[0].aa.value=0+"|"+code;
document.forms[0].ca2.value=code;

}
var cba="#"+code;
document.forms[0].action="init.php5"+cba;
document.forms[0].submit();
}

function badge2(code)
{

document.forms[0].aa.value=1+"|"+code;
document.forms[0].ca2.value=code;

var cba="#"+code;

document.forms[0].action="init.php5"+cba;
document.forms[0].submit();
}


function badges()
{
  if(document.forms[0].ba.value==1)
  {
    //fermeture du noeud badge
    document.forms[0].ba.value=0;
    //fermeture du noeud badges supprimés si ouvert
    //document.forms[0].g.value=0;
    //fermeture du noeud clés non résidents si ouvert
    //document.forms[0].y.value=0;
    //fermeture du noeud accès communs si ouvert
    //document.forms[0].x.value=0;
    //fermeture du noeud parking si ouvert
    //document.forms[0].h.value=0;    
    //fermeture du noeud apparts si ouvert
    //document.forms[0].ap.value=0;
    //fermeture du noeud d'un appartement si ouvert
    //document.forms[0].aa.value="";
  }
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}

function badges2()
{
  if(document.forms[0].ba.value!=1)
  {
    //ouverture du noeud clés
    document.forms[0].ba.value=1;
    //fermeture du noeud paramètres
    document.forms[0].p.value=0; 
    //fermeture du noeud edition des messages
    document.forms[0].EdtMess.value=0; 
    //fermeutre du noeud Action sur entrée
    document.forms[0].ActionEntre.value=0;     
  }
  document.forms[0].action="init.php5";
  document.forms[0].submit();
}

function appart()
{
if(document.forms[0].ap.value==1)
{
  document.forms[0].ap.value=0;  
  //On referme le noeud appartement qui était peut-être ouvert
  document.forms[0].aa.value="0";
  //On enlève la surbrillance du noeud
  document.forms[0].ca2.value="";
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}

function appart2()
{
if(document.forms[0].ap.value==0)
{
  //ouverture du noeud appartements
  document.forms[0].ap.value=1;
  //fermeture du noeud badges supprimés
  document.forms[0].g.value=0;
  //fermeture du noeud cles non residants
  document.forms[0].y.value=0;
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}

function EditionMessages()
{
if(document.forms[0].EdtMess.value==1)
{document.forms[0].EdtMess.value=0;
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}

function EditionMessages2()
{
if(document.forms[0].EdtMess.value!=1)
{
  //ouverture du noeud edition des messages
  document.forms[0].EdtMess.value=1;
  //fermeture du noeud clés
  document.forms[0].ba.value=0;
  //fermeture du noeud paramètres
  document.forms[0].p.value=0; 
  //fermeutre du noeud Action sur entrée
  document.forms[0].ActionEntre.value=0; 
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}

function EditionMessagesEntree()
{
if(document.forms[0].EdtMessE.value==1)
{document.forms[0].EdtMessE.value=0;
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}

function EditionMessagesEntree2()
{
if(document.forms[0].EdtMessE.value==0)
{document.forms[0].EdtMessE.value=1;
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}

function Action()
{
if(document.forms[0].ActionEntre.value==1)
{document.forms[0].ActionEntre.value=0;
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}

function Action2()
{
if(document.forms[0].ActionEntre.value==0)
{
  //Ouverture du noeud Action sur entrée
  document.forms[0].ActionEntre.value=1;
  //fermeture du noeud edition des messages
  document.forms[0].EdtMess.value=0;
  //fermeture du noeud clés
  document.forms[0].ba.value=0;
  //fermeture du noeud paramètres
  document.forms[0].p.value=0; 
}
document.forms[0].action="init.php5";
document.forms[0].submit();
}

function users()
{
if(document.forms[0].a.value==1)
{document.forms[0].a.value=0;
}

document.forms[0].action="Users.php5";
document.forms[0].submit();
}

function users2()
{
if(document.forms[0].a.value==0)
{document.forms[0].a.value=1;
}

document.forms[0].action="Users.php5";
document.forms[0].submit();
}


function sites()
{
if(document.forms[0].si.value==1)
{document.forms[0].si.value=0;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}

function sites2()
{
if(document.forms[0].si.value==0)
{
  if (document.forms[0].a.value==1)
  { 
    document.forms[0].a.value=0;
  }
  document.forms[0].si.value=1;
}

document.forms[0].action="init.php5";
document.forms[0].submit();
}


// Compare two options within a list by VALUES
function compareOptionValues(a, b)
{
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = parseInt( a.value, 36 );
  var sB = parseInt( b.value, 36 );
  return sA - sB;
}



// Compare two options within a list by TEXT
function compareOptionText(a, b)
{
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = parseInt( a.text, 36 );
  var sB = parseInt( b.text, 36 );
  return sA - sB;
}


// Dual list move function

function moveDualList( srcList, destList, moveAll )
{
  // Do nothing if nothing is selected
  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   )
  {
    return;
  }

  newDestList = new Array( destList.options.length );
  var len = 0;

  for( len = 0; len < destList.options.length; len++ )
  {
    if ( destList.options[ len ] != null )
    {
      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
    }
  }

  for( var i = 0; i < srcList.options.length; i++ )
  {
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
    {
       // Statements to perform if option is selected

       // Incorporate into new list
       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
       len++;
    }
  }

  // Sort out the new destination list
  newDestList.sort( compareOptionValues );   // BY VALUES
  //newDestList.sort( compareOptionText );   // BY TEXT

  // Populate the destination with the items from the new array
  for ( var j = 0; j < newDestList.length; j++ )
  {
    if ( newDestList[ j ] != null )
    {
      destList.options[ j ] = newDestList[ j ];
    }
  }

  // Erase source list selected elements
  for( var i = srcList.options.length - 1; i >= 0; i-- )
  {
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
    {
       // Erase Source
       //srcList.options[i].value = "";
       //srcList.options[i].text  = "";
       srcList.options[i]       = null;
    }
  }
} // End of moveDualList()
//  End -->


function selectall()
{
  if(document.forms[0].inpost.value != '-1' )
  {
    for(var i=0;i<document.forms[0].listRight.options.length;i++)
    {
      document.forms[0].listRight.options[i].selected=true;
    }
  }
}

function veriflistesite()
{
  var sitesSelect = document.getElementById('listRight');
  document.forms[0].inpost.value = sitesSelect.selectedIndex;
  if(document.forms[0].inpost.value == '-1' ) {
    alert("Le choix d'au moins un site est obligatoire");
    return false;
  } else {
    return true;
  }
}

function verifdates()
{
date1=document.forms[0].b_deb_val.value;
alert(date(date1));
}


function confirmSubmit()
{
  result=confirm("Etes vous sûr de vouloir effectuer la suppression ? ");
  if (result == true)
  {
     document.forms[0].action="Validation.php5";
     document.forms[0].submit();
     }
     else
     {  }
}
  
  function submitmodif()
  {
  document.forms[0].action="Validation.php5";
  document.forms[0].submit();
  }

  function submitplatine()
    {
    if(document.forms[0].nom.value =='' )
      {
      alert('Le nom est obligatoire');
      }
      if(document.forms[0].nom.value !='' )
      { //modif lvt 30/08/05
        if(document.forms[0].portes.selectedIndex>=0){
          submitmodif();
        }else{
          alert('La porte est obligatoire');
        }
      }
   }
   
    function submitmodif2()
       {
       document.forms[0].action="validationAuto.php5";
       document.forms[0].submit();
        }

    function submitmodif3()
       {
       document.forms[0].action="validationSite.php5";
       document.forms[0].submit();
        }
        
  
  function affichage()
      {
      document.forms[0].b.value=1;
      document.forms[0].action="Passe.php5";
      document.forms[0].submit();
      }
  
  function pbadge()
      {
      document.forms[0].a.value=1;
      document.forms[0].action="Passe.php5";
      document.forms[0].submit();
      }
  
   function ppasse()
   {
     document.forms[0].c.value=1;
     document.forms[0].action="Passe.php5";
     document.forms[0].submit();
   }
  
     function pdate1()
  {
document.forms[0].d1.value=1;
 document.forms[0].action="Passe.php5";
     document.forms[0].submit();

      }
  
  
  function pdate2()
  {
       document.forms[0].d2.value=1;
        document.forms[0].action="Passe.php5";
            document.forms[0].submit();

      }




function verifnomuser()
{

if(document.forms[0].logto.value =='' )
{
alert("Le nom est obligatoire");
}
}

function mdp()
{

if(document.forms[0].mdp.value != '' &&  document.forms[0].mdp2.value != '')
{
  if(document.forms[0].mdp.value != document.forms[0].mdp2.value )
  {
  alert("La confirmation de votre mot de passe n'est pas correcte !");
  }
}
else
{
alert("Le mot de passe est obligatoire !");
}

}

function VerifCreerUser()
{ 
  //invité et utilisateur
  if(document.forms[0].droits[3].checked || document.forms[0].droits[2].checked || document.forms[0].droits[1].checked)
  {
    selectall();
    document.forms[0].inpost.value = document.forms[0].listRight.selectedIndex;
    document.forms[0].listRight.name='listRight[]';
    if (veriflistesite()==false) return false;
    return true;
  }

  //Administrateur
  else if(document.forms[0].droits[0].checked)
  {
    return true;
  }
  else
  {
    return false;
  }
}


//function submitmodifUser()
//{
//  document.forms[0].action="validationuser.php5";
//  document.forms[0].submit();
//}

function verifModifUser()
{
  if(document.forms[0].dro.value == "0" || document.forms[0].dro.value == "1" || document.forms[0].dro.value == "2")
  {
    selectall();
    if (veriflistesite()==false) return false;  
    //submitmodifUser();
    document.forms[0].listRight.name='listRight[]';
    //alert("Utilisateur modifié");  
    return true;
  }
  else if (document.forms[0].dro.value=="3" || document.forms[0].dro.value=="5")
  {
    //submitmodifUser();
    //alert("Utilisateur modifié");
    return true;
  }
  else
  {    
    return false;
  }
}


function verifnomPlatine()
{
if(document.forms[0].nom.value == ""  )
{
alert("Le nom de platine est obligatoire");
}
}

function verifsiPorte()
{
if(document.forms[0].portes.selectedIndex == -1)
{ 
alert("Le choix d'une porte est obligatoire");
}
}

function veriftemps()
{
if(document.forms[0].tpsson.value == ""  )
{
alert("Le temps de sonnerie est obligatoire");
}
if(document.forms[0].tpscom.value == ""  )
{
alert("Le temps de communication est obligatoire");
}
if(document.forms[0].tpsoccu.value == "" )
{
alert("Le temps d'occupation est obligatoire");
}
}


function verifoccu()
{
if(document.forms[0].tpsoccu.value < 20  )
{
alert("Le temps d'occupation ne peut être inférieur à 20");
}

}

function FormatStr(Num,nbcar)
{
  res = Num.toString();
  lg = res.length;
  for(i=lg+1;i<=nbcar;i++)
  {
    s1 = res;
    res = '0' + s1;
  }
  return res;
}

function Calcul_Code_Combine(Combine,TypePlatine)
{
  if (TypePlatine == 0)
  {
    if(document.forms[0].formatage!=undefined)
      document.forms[0].formatage.value="%03d";
    NbFormat = 3;
  }
  else
  {
    if(document.forms[0].formatage!=undefined)
      document.forms[0].formatage.value="%04d";
    NbFormat = 4;
  }
  strCombine = Combine.toString();
  if (strCombine.length < 3) 
  {
    switch(TypePlatine)
    {
      case 0 : 
        if (Combine > 640)
          strCombine = 'INVALIDE';
        else
          strCombine = FormatStr(Combine+1,NbFormat);
      break;
      case 1 :
        if (Combine < 16)
          strCombine = '00' + FormatStr(Combine+1,2);
        else
          strCombine = '0101';
      break;
      case 2 :
        if (Combine < 4) 
          strCombine = '00' + FormatStr(Combine+1,2);
        else
          strCombine = '0101';
      break;
      default : break;
    }
  }
  else
  {
    strCombine = FormatStr(Combine,4);
    l_CodeCombine = parseInt(strCombine.slice(2,4),10) ;
    switch(TypePlatine)
    {
      case 0 : 
        if (Combine > 640)
          strCombine = 'INVALIDE';
        else
          strCombine = FormatStr(Combine+1,NbFormat);
      break;
      case 1 :
        if (l_CodeCombine < 16)
        {
          if (parseInt(strCombine.slice(0,2),10) < 32)
            strCombine = strCombine.slice(0,2) + FormatStr(l_CodeCombine+1,2);
          else
            strCombine = 'INVALIDE' ;
        }
        else
        {
          if (parseInt(strCombine.slice(0,2),10)+1 < 32)
            strCombine = FormatStr(parseInt(strCombine.slice(0,2),10)+1,2) + '01';
          else
            strCombine = 'INVALIDE' ;
        }
      break;
      case 2 :
        if (l_CodeCombine < 4)
        {
          if (parseInt(strCombine.slice(0,2),10) < 64)
            strCombine = strCombine.slice(0,2) + FormatStr(l_CodeCombine+1,2);
          else
            strCombine = 'INVALIDE' ;
        }
        else
        {
          if (parseInt(strCombine.slice(0,2),10)+1 < 64)
            strCombine = FormatStr(parseInt(strCombine.slice(0,2),10)+1,2) + '01';
          else
            strCombine = 'INVALIDE';
        }
      break;
      default : break;
    }
  }
  return strCombine;
}


function ValiderBdgConf()
{
  lgPwd=document.forms[0].edtMdp.value.length;
  if ((lgPwd<4) | (lgPwd>16))
  {
   alert('Mot de passe incorrect');
   return;
  }
  if(document.forms[0].listRight!=undefined)
  {
    for(i=0;i<document.forms[0].listRight.options.length;i++)
      document.forms[0].listRight.options[i].selected=true;
    document.forms[0].listRight.name='listRight[]';
  }
  if(document.forms[0].listLeft!=undefined)
  {
    for(i=0;i<document.forms[0].listLeft.options.length;i++)
      document.forms[0].listLeft.options[i].selected=true;
    document.forms[0].listLeft.name='listLeft[]';
  }
  document.forms[0].STARTENCOD.value="1";
  document.forms[0].action='BdgConfig.php5';
  document.forms[0].submit();
}


function getkey(e)
{
  if (window.event)
    return window.event.keyCode;
  else if (e)
    return e.which;
  else
    return null;
}

function ValidChar(e)
{
  var key, keychar;
  key = getkey(e);
  if (key == null) return true;
  // 13:entrée 39:' 34:"
  if (key==13)
  {
    document.forms[0].C_OK.value='Valider';
    document.forms[0].submit();
    return false;

  }
  else if (key==39 ||key==34)
  {
    return false;
  }
  else return true;
}

function popup(page)
{
  // ouvre une fenetre sans barre d'etat, ni d'ascenceur
  window.open(page,'popup','width=400,height=200,toolbar=false,scrollbars=false,left='+((screen.width-400)/2)+',top='+((screen.height-200)/2));
}

////////////////////////////////////////////////////
// fonctions standard chaînes de caractères alex
////////////////////////////////////////////////////
function trim(s)
{
  if(s.length>0)
  {
    while(s.charAt(0)==" ")
    {
      s=s.substring(1);
    }
    while(s.charAt(s.length-1)==" ")
    {
      s=s.substr(0,s.length-1);
    }
  }
  return s;
}

function decalDroite(id_texte,longueur)
{
  tmpTxt = document.getElementById(id_texte);
  tmpTxt.value = trim(tmpTxt.value);
  tmpTxt.style.textAlign = 'right';
}

function decalGauche(id_texte,longueur)
{
  tmpTxt = document.getElementById(id_texte);
  tmpTxt.value = trim(tmpTxt.value);
  tmpTxt.style.textAlign = 'left';  
}

function decalCentre(id_texte,longueur)
{
  tmpTxt = document.getElementById(id_texte);
  tmpTxt.value = trim(tmpTxt.value);
  tmpTxt.style.textAlign = 'center';   
}

function Autotab(box, longueur, texte)
{
    toucheOk = (window.event.keyCode < 37) || (window.event.keyCode > 40);
    if (texte.length == longueur && toucheOk) {
        document.getElementById('L'+box).focus();
    }
}

function entreeEntier(event)
{
  // Compatibilité IE / Firefox
  if(!event&&window.event)
  { event=window.event;}
  
  // IE
  if(event.keyCode < 48 || event.keyCode > 57)
  {
    event.returnValue = false;
    event.cancelBubble = true;
  }
  // DOM
  if(event.keyCode < 48 || event.keyCode > 57)
  {
    event.preventDefault();
    event.stopPropagation();
  }
}

function entreeCode(event)
{
  // Compatibilité IE / Firefox
  if(!event&&window.event)
  { event=window.event;}
  
  if(event.keyCode>=97 && event.keyCode<=102)
  { event.keyCode = event.keyCode-32; }
  
  // IE
  if((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 65 || event.keyCode > 70))
  {
    event.returnValue = false;
    event.cancelBubble = true;
  }
  // DOM
  if((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 65 || event.keyCode > 70))
  {
    event.preventDefault();
    event.stopPropagation();
  }
}

function entreeMsgLigne(event)
{
  // Compatibilité IE / Firefox
  if(!event&&window.event)
  {
    event=window.event;
  }
  // IE
  if((event.keyCode == 34) || (event.keyCode == 39))
  {
    event.returnValue = false;
    event.cancelBubble = true;
  }
  // DOM
  if((event.keyCode == 34) || (event.keyCode == 39))
  {
    event.preventDefault();
    event.stopPropagation();
  }
}

function entreeUtilisateur(event)
{
  // Compatibilité IE / Firefox
  if(!event&&window.event)
  {
    event=window.event;
  }
  // IE
  if((event.keyCode == 34) || (event.keyCode == 39) || (event.keyCode == 32) )
  {
    event.returnValue = false;
    event.cancelBubble = true;
  }
  // DOM
  if((event.keyCode == 34) || (event.keyCode == 39) || (event.keyCode == 32))
  {
    event.preventDefault();
    event.stopPropagation();
  }
}

////////////////////////////////////////////////////
// Fonctions Graphique             alex
////////////////////////////////////////////////////

// barre d'attente
function BarreAttente() {

  if(ind > 10)
  {
    ind = 1;
    if(fermeFenetre == 1) { window.close(); }
  }
  if(bloc = document.getElementById("td"+ind)) { bloc.bgColor = '#3B4E77'; }
  switch(ind) {
    case 1:
      if(bloc = document.getElementById("td8")) { bloc.bgColor = '#9EBFE8'; }
    break;
    case 2:
      if(bloc = document.getElementById("td9")) { bloc.bgColor = '#9EBFE8'; }
    break;
    case 3:
      if(bloc = document.getElementById("td10")) { bloc.bgColor = '#9EBFE8'; }
    break;
    case 4:
      if(bloc = document.getElementById("td1")) { bloc.bgColor = '#9EBFE8'; }
    break;
    case 5:
      if(bloc = document.getElementById("td2")) { bloc.bgColor = '#9EBFE8'; }
    break;
    case 6:
      if(bloc = document.getElementById("td3")) { bloc.bgColor = '#9EBFE8'; }
    break;
    case 7:
       if(bloc = document.getElementById("td4")) { bloc.bgColor = '#9EBFE8'; }
    break;
    case 8:
      if(bloc = document.getElementById("td5")) { bloc.bgColor = '#9EBFE8'; }
    break;      
    case 9:
      if(bloc = document.getElementById("td6")) { bloc.bgColor = '#9EBFE8'; }
    break;
    case 10:
       if(bloc = document.getElementById("td7")) { bloc.bgColor = '#9EBFE8'; }
    break;
  }    
  ind = parseInt(ind) + 1;
}