/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var delay = 6000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(255,88,1); // end color (red, green, blue)

var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////

var DOM2=document.getElementById;
var faderdelay=0;
var index_heb=1;


/*Rafael Raposo edited function*/
//function to change content
function changecontent_heb(id_bloc_heb, compteur_heb){
  if (index_heb>compteur_heb)
    index_heb=1;
  id_suivant_heb = index_heb+1;
  if(id_suivant_heb > compteur_heb)
    id_suivant_heb = 1;
  id_precedent_heb = index_heb-1;
  if(id_precedent_heb == 0)
     id_precedent_heb = compteur_heb;

//alert("id_precedent_heb ==> "+id_bloc_heb+id_precedent_heb+" id_actuelle ==> "+id_bloc_heb+index_heb+" id_suivant_heb ==> "+id_bloc_heb+id_suivant_heb);

  if (DOM2){
    document.getElementById(id_bloc_heb+id_precedent_heb).className = document.getElementById(id_bloc_heb+id_precedent_heb).className.replace(/ visible/, "");
    document.getElementById(id_bloc_heb+index_heb).className =  document.getElementById(id_bloc_heb+index_heb).className + " visible";
    document.getElementById(id_bloc_heb+index_heb).style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
    if (fadelinks)
      linkcolorchange_heb(1, id_bloc_heb+index_heb);
    colorfade_heb(1, id_bloc_heb, compteur_heb, index_heb);
  }
  index_heb++
}

// colorfade_heb() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

function linkcolorchange_heb(step_heb, id_heb){
  var obj_heb=document.getElementById(id_heb).getElementsByTagName("A");
  if (obj_heb.length>0){
    for (i=0;i<obj_heb.length;i++)
      obj_heb[i].style.color=getstepcolor_heb(step_heb);
  }
}

/*Rafael Raposo edited function*/
var fadecounter_heb;
function colorfade_heb(step_heb,id_bloc_heb, compteur_heb, index_heb) {
  if(step_heb<=maxsteps) {	
    document.getElementById(id_bloc_heb+index_heb).style.color=getstepcolor_heb(step_heb);
    if (fadelinks)
      linkcolorchange_heb(step_heb, id_bloc_heb+index_heb);
    step_heb++;
    fadecounter_heb=setTimeout("colorfade_heb("+step_heb+", '"+id_bloc_heb+"', '"+compteur_heb+"', '"+index_heb+"')",stepdelay);
  }else{
    clearTimeout(fadecounter_heb);
    document.getElementById(id_bloc_heb+index_heb).style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
    setTimeout("changecontent_heb('"+id_bloc_heb+"', '"+compteur_heb+"')", delay);
	
  }   
}

/*Rafael Raposo's new function*/
function getstepcolor_heb(step_heb) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i<3;i++) {
    diff = (startcolor[i]-endcolor[i]);
    if(diff > 0) {
      newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step_heb);
    } else {
      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step_heb);
    }
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

function defilementOffresHeb(id_bloc_heb, id_box) {
  //identification du navigateur
    Nom = navigator.appName;
    Version = navigator.appVersion;
    
    Index = Version.indexOf("MSIE");
    if(Index>0){
      Version = Version.substr(Index+5, 1);
    }

    ie7 = (Nom == 'Microsoft Internet Explorer' && Version <= 7 ) ? 1:0

  var elts = document.getElementsByTagName('p');
  var elts_cnt   = (typeof(elts.length) != 'undefined') ? elts.length : 0;
  //on ajoute l'attribut id pour les éléments
  var compteur_heb =0;
  if(ie7){
    for (var i = 0; i < elts_cnt; i++) {
      if(elts[i].getAttribute("className") == id_bloc_heb){
        compteur_heb++;
        elts[i].id = id_bloc_heb + compteur_heb;
      }
    } // end for
  }else{
    for (var i = 0; i < elts_cnt; i++) {
      if(elts[i].getAttribute("class") == id_bloc_heb){
        compteur_heb++;
        elts[i].id = id_bloc_heb + compteur_heb;
      }
    } // end for
  }

	//si on a des éléments, on lance l'animation
  if(compteur_heb > 0){
    changecontent_heb(id_bloc_heb, compteur_heb);
  }
}
