var indSlide = 0;
var maxSlide = 0;
var slideShowSpeed = 3000; 
var crossFadeDuration = 3; 
function permute()
{
 var images = document.getElementsByTagName('img');
 for (var i=0;i<images.length;i++)
 {
  if ( images[i].name.substring(0,3) == 'IMG' && images[i].name.substring(3) != '' )
  {
   if ( images[i].name.substring(3) > maxSlide )
   {
    maxSlide = images[i].name.substring(3); 
   }
  }
 }
 if ( images[0] ) document.getElementById('IMAGE').src = images[0].src;
 if ( maxSlide > 0 ) alterne(); 
}

function alterne()
{
 var images = document.getElementsByTagName('img');
 for (var i=0;i<images.length;i++)
 {
  if ( images[i].name.substring(0,3) == 'IMG' && images[i].name.substring(3,4) == indSlide && images[i].src != '' )
  {
   if ( document.all )
   {
    document.getElementById('IMAGE').style.filter = "blendTrans(duration=crossFadeDuration)";
    document.getElementById('IMAGE').filters.blendTrans.Apply();
   }
   document.getElementById('IMAGE').src = images[i].src;
   if (document.all)
   {
    document.getElementById('IMAGE').filters.blendTrans.Play();
   }    
   indSlide = indSlide + 1;
   if ( indSlide > maxSlide ) indSlide = 0;
   setTimeout('alterne()',slideShowSpeed);
   return;
  }
 }
}

function shw(obj)
{
 document.getElementById(obj).style.visibility = "visible";
}
function hid(obj)
{
 document.getElementById(obj).style.visibility = "hidden";
}
function changeCouleur(ligne,classe)
{
 ligne.className = classe;
}

String.prototype.trim = function() 
{
 var reg1 = new RegExp("^\\s*");
 var reg2 = new RegExp("\\s*$");
 return this.replace(reg1,"").replace(reg2,"");
};

function trim_all(form) 
{ 
 for (var i=0;i<form.elements.length;i++) 
 {
  if ( form.elements[i].type == 'text' || form.elements[i].type == 'textarea' )
  {
   form.elements[i].value = form.elements[i].value.trim();
  } 
 }
}

function checkall(form,champ,chkflag)
{
 for (var i=0;i<form.elements.length;i++) 
 { 
  if ( form.elements[i].name.substring(0,champ.length) == champ )
  {
   form.elements[i].checked = chkflag;
  }
 }
}

function redirection(url)
{
 document.location.href = url;
}

function changeURL(formSelection)
{
 if ( formSelection.options[formSelection.selectedIndex].value.trim() != '' )
 {
  redirection(formSelection.options[formSelection.selectedIndex].value);
 }
}

function Confirmation(texte,url)
{
 if ( confirm(texte) )
 {
  redirection(url);
 }
}

function popup(url,width,height,nom)
{
 var n6 = (document.getElementById && ! document.all) ? 1 : 0;
 var plusN6 = 10;
 if ( width < 1 )
 {
  var windowWidth = Math.round(screen.width * width);
 }
 else
 {
  var windowWidth = parseInt(width);
 }
 if ( height < 1 )
 {
  var windowHeight = Math.round(screen.height * height);
 }
 else
 {
  var windowHeight = parseInt(height);
 }
 if ( n6 )
 {
  windowHeight = windowHeight + plusN6;	
 } 
 var windowLeft = (screen.width-windowWidth)/2;
 var windowTop  = (screen.height-windowHeight)/2;
 w = window.open(url,nom,'menubar=yes,status=yes,resizable=yes,scrollbars=yes,fullscreen=no,width='+windowWidth+',height='+windowHeight+',top='+windowTop+',left='+windowLeft);
}

function confirmSuppression(lienHref)
{
 if ( confirm("Confirmez-vous la suppression de cet élément ?") )
 {
  if ( lienHref != '' )
  {
   document.location.href = lienHref;	
  }
  else
  {
   lienFct();
  }
 }
}
function confirmDivers(lienHref,texte)
{
 if ( confirm(texte) )
 {
  document.location.href = lienHref;	
 }
}
function submitCallback(elt)
{
 elt.form.submit();
}
function initOnSubmit(formulaire,fonction,argument)
{
 var form = document.forms[formulaire];
 form.onsubmit = 
 function() 
 {  
  eval('ret = '+fonction+'(form,argument)');
  return ret;   
 }  
}
function calculEBE(form,ve,v1,v2,v3,res)
{
 eval('var vebe = form.'+ve+'.value');
 if ( vebe == '' )
 {
  vebe = 0;
 }
 else
 {
  vebe = parseInt(vebe);
 }
 eval('var val1 = form.'+v1+'.value');
 if ( val1 == '' )
 {
  val1 = 0;
 }
 else
 {
  val1 = parseInt(val1);
 }
 eval('var val2 = form.'+v2+'.value');
 if ( val2 == '' )
 {
  val2 = 0;
 }
 else
 {
  val2 = parseInt(val2);
 }
 eval('var val3 = form.'+v3+'.value');
 if ( val3 == '' )
 {
  val3 = 0;
 }
 else
 {
  val3 = parseInt(val3);
 }
 eval('form.'+res+'.value = '+(vebe+val1 + val2 + val3)); 
}