var image="";
var currentImg=-1;
var logos = new Array();
var totalImg=0;
var bannerRef = "";

function rotatePartner(product, imgRef) {
  bannerRef = imgRef;
  switch(product) {
    // controle d'acces
    case '1':
      logos = Array("kaba.gif","kaba-benzing.gif","time-design.gif");
      break;
    
    // gestion horaire
    case '2':
      logos = Array("kaba-benzing.gif","kaba.gif","time-design.gif","tisoware.gif");
      break;
    
    // portes automatiques
    case '3':
      logos = Array("kaba.gif", "faac.gif", "urbaco.gif");
      break;
    
    // video surveillance
    case '4':
      logos = Array("cbc.gif","videte.gif","ganz-computar.gif","dedicated-micros.gif","vcs.gif", "ids.gif");
      break;
    
    // restauration d'entreprise
    case '5':
      logos = Array("hess.gif","cashcontrol.gif","sag.gif");
      break;
    
    // systeme de centralisation
    case '6':
      logos = Array("omnisecurity.gif","entelec.gif", "til.gif");
      break;
    
    // support d'identification
    case '7':
      logos = Array("legic.gif","identa.gif");
      break;
    
    // securite perimetrique
    case '8':
      logos = Array("martec.gif","sorhea.gif");
      break;
    
    // detection incendie et d'intrusion
    case '9':
      logos = Array("ademco.gif", "novar.gif");
      break;
    
    // multimedia
    case '10':
      logos = Array("esii.gif","ent.gif");
      break;
    
    // parlphonie
    case '11':
      logos = Array("clarson.gif","zenitel.gif","amphitec.gif","siedle.gif");
      break;
    
    // blank
    default:
      logos = Array("blank.gif");
      break;
  }
  
  totalImg = logos.length;
  cycle('logos_partenaires');
}

function rotateRandomClients(imgRef) {
  bannerRef = imgRef;
  logosOrdered = Array(
    "administrations/euro_parl.gif","administrations/gouvernement.gif","administrations/inspection_travail.gif","administrations/nato.gif","administrations/ville_luxembourg.gif",
    "customer/abbl.gif","customer/bcee.gif","customer/bcl.gif","customer/bgl.gif","customer/bnp.gif","customer/dexia.gif","customer/dz_bank.gif","customer/kredietbank.gif",
    "industry/abattoirs.gif","industry/arbed.gif","industry/atofina.gif","industry/caterpillar.gif","industry/delphi.gif","industry/goodyear.gif","industry/pwurth.gif",
    "insurance/investlife.gif","insurance/laluxembourgeoise.gif","insurance/swisslife.gif","insurance/winterthur.gif",
    "tertiary/auchan.gif","tertiary/cactus.gif","tertiary/cargolux.gif","tertiary/cegedel.gif","tertiary/cocacola.gif","tertiary/lamesch.gif","tertiary/panalpina.gif","tertiary/pt.gif","tertiary/reuters.gif","tertiary/sodexho.gif",
    "trade/giorgetti.gif","trade/hoffmann.gif","trade/rossi.gif","trade/sanichaufer.gif"
  );
  
  totalImg = logosOrdered.length;
  logos = logosOrdered.sort(randOrd);
  cycle('logos_references');
}

function inArray(myVal, myArray) {
  for (j=0; j < myArray.length; j++) {
    if (myArray[j] == myVal) {
      return true;
    }
  }
  
  return false;
}
      

function cycle(logo_type) {
  // images random, si sur homepage
  /*if (logo_type == 'logos_references') {
    currentImg = rand(totalImg-1); 
  } */
  
  // sinon, dans l'ordre pour les produits
  //else {
    if (++currentImg >= totalImg) currentImg=0;
  //}
  
  image = "/images/" + logo_type + "/" + logos[currentImg];
  bannerRef.src = image;
  window.setTimeout("cycle('"+logo_type+"');", 1500);
}

//function loadImg() {
//   image = "i/rotation/schako0"+currentImg+".gif";
//}

rnd.today=new Date();                             
rnd.seed=rnd.today.getTime();                     
                                                  
function rnd() {                                  
  rnd.seed = (rnd.seed*9301+49297) % 233280;
  return rnd.seed/(233280.0);               
};                                                
                                                  
function rand(number) {                           
  return Math.ceil(rnd()*number);           
};                                                

function randOrd(a, b) {
  return (Math.round(Math.random())-0.5); 
}