//24-10-2008 JFONT: Aquest es el codio de rotacio_banners.js que hi ha a producció abans del desplegament del 24-11-2008
// Objecte Banner
function Banner(image, url,name,popup) {
    this.image = image;
    this.url = url;
    this.name =name;
    this.popup = popup;
}

// Variables temporals
var pos = 0, timeout = 1000, imatges = [];

// Funcio del temporitzador
function Timer() {
  pos = (pos + 1) % imatges.length;
  canvia(pos);
//  document.getElementById("img").src = imatges[pos].image;
//  document.getElementById("link").href = imatges[pos].url;
}

function canvia(posicio) {
  var img = imatges[posicio].image;
  if(img.substr(img.lastIndexOf(".")) != ".swf") { // imatge
    document.getElementById("imgtd").innerHTML =
      '<a href="' + imatges[posicio].url + '" target="' + imatges[posicio].popup + '" id="link">' +
      '  <img width="664" height="214" border="0" src="' + img + '" alt= "' + imatges[posicio].name + '"\/>' +
      '<\/a>';
  } else { // flash
    document.getElementById("imgtd").innerHTML =
      '  <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' + 
      '          WIDTH="664" HEIGHT="214" id="banner" ALIGN="">' +
      '    <PARAM NAME=movie VALUE="' + img + '">' +
      '    <PARAM NAME=quality VALUE=high>' +
      '    <PARAM NAME=bgcolor VALUE=#FFFFFF>' +
      '    <EMBED src="' + img + '" quality=high bgcolor=#FFFFFF  WIDTH="664" HEIGHT="214" NAME="banner" ALIGN="" TYPE="application/x-shockwave-flash"' + 
      '           PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">' +
      '    <\/EMBED>' +
      '  <\/OBJECT>';
  }
/*
  document.getElementById("imgtd").style.backgroundImage = "url("+imatges[posicio].image+")";
  document.getElementById("img").alt = imatges[posicio].name;
  document.getElementById("img").title = imatges[posicio].name;
  document.getElementById("link").href = imatges[posicio].url;
  document.getElementById("link").target = imatges[posicio].popup;
*/
}

// Inicialitzacio
function temporitzadorImatges(p_timeout, p_imatges) {
  timeout = 16000; //p_timeout;
  imatges = p_imatges;
  setInterval("Timer()", timeout);
}