/***********************************************
* 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 = 5000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=20; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(206,217,229); // start color (red, green, blue)
var endcolor=new Array(234,95,0); // end color (red, green, blue)

var fcontent=new Array();
begintag='<div style="font: normal 14px Arial; padding: 5px;">'; //set opening tag, such as font declarations
begintag=''; // PSR

// fcontent[0]="<b>What\'s new?</b><br>New scripts added to the Scroller category!<br><br>The MoreZone has been updated. <a href='../morezone/index.htm'>Click here to visit</a>";
// fcontent[1]="Dynamic Drive has been featured on Jars as a top 5% resource, and About.com as a recommended DHTML destination.";
// fcontent[2]="Ok, enough with these pointless messages. You get the idea behind this script.</a>";

// fcontent[0]=document.getElementById("infoflash_n0").innerHTML;
// fcontent[1]=document.getElementById("infoflash_n1").innerHTML;
// fcontent[2]=document.getElementById("infoflash_n2").innerHTML;
// fcontent[3]=document.getElementById("infoflash_n3").innerHTML;

// fcontent[2]="2_Ok, enough with these pointless messages. You get the idea behind this script.</a>";
// fcontent[3]="3_Ok, enough with these pointless messages. You get the idea behind this script.</a>";
// fcontent[4]="4_Ok, enough with these pointless messages. You get the idea behind this script.</a>";

// PSR ADD_CODE : Init content  ->
for (i=0;i<infoCounter;i++)
  fcontent[i]=document.getElementById("infoflash_n"+i).innerHTML;
// PSR ADD_CODE <-
      
      



closetag='</div>';
 closetag='';// PSR

var fwidth='150px'; //set scroller width
var fheight='150px'; //set scroller height

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 ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=0;


/*Rafael Raposo edited function*/
//function to change content
function changecontent(){
  if (index>=fcontent.length)
    index=0
  if (DOM2){

    // document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")" // PSR
    document.getElementById("infoflash_n0").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")";  // PSR
    // document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag  // PSR
    document.getElementById("infoflash_n0").innerHTML=begintag+fcontent[index]+closetag;  // PSR

    if (fadelinks)
      linkcolorchange(1);

    colorfade(1, 15); // PSR
    // colorfade(0, 15); // PSR

  }
  else if (ie4) {
    // document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;  // PSR
    document.all.infoflash_n0.innerHTML=begintag+fcontent[index]+closetag;  // PSR
  }
  index++
}

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

function linkcolorchange(step){
  // var obj=document.getElementById("fscroller").getElementsByTagName("A"); // PSR
 var obj=document.getElementById("infoflash_n0").getElementsByTagName("A");  // PSR

  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

function resetColor() {
    // Ajouter pour probleme de couleur de debut a la valeur de celle de fin
    document.getElementById("infoflash_n0").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")";  // PSR
}
function resetLinkColor() {
    // Ajouter pour probleme de couleur de debut a la valeur de celle de fin
  var obj=document.getElementById("infoflash_n0").getElementsByTagName("A");  // PSR
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")";
  }
}




/*Rafael Raposo edited function*/
var fadecounter;
var fadecounter1;
var fadecounter2;
var fadecounter3;

function colorfade(step) {
  if(step<=maxsteps) {
     // document.getElementById("fscroller").style.color=getstepcolor(step); // PSR
     document.getElementById("infoflash_n0").style.color=getstepcolor(step);   // PSR
    if (fadelinks)
      linkcolorchange(step);
    step++;
    fadecounter=setTimeout("colorfade("+step+")",stepdelay);
  }else{

    clearTimeout(fadecounter);

    // document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")"; // PSR
    document.getElementById("infoflash_n0").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";  // PSR

    if(infoCounter>1) {
      fadecounter1=setTimeout("changecontent()", delay);
      fadecounter2=setTimeout("resetColor()", 4900);
      fadecounter3=setTimeout("resetLinkColor()", 4900); // fonctionne pas compltement Ajout couleur start dans CSS
    }  
  }
}


var flagRestart;
var restartcounter;

function stopChangecontent () {
  // alert('stopChangecontent');

  clearTimeout(fadecounter);
  document.getElementById("infoflash_n0").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";  // PSR
  clearTimeout(fadecounter1);
  clearTimeout(fadecounter2);
  clearTimeout(fadecounter3);
  clearTimeout(restartcounter);
  // flagRestart=0;
}

function armRestart() {
    flagRestart = 1;
    restartcounter=setTimeout("restartChangecontent()", 1000);
}


function restartChangecontent() {
    // alert('restartChangecontent');
    // if (flagRestart) {
      // alert('restartChangecontent');

      // index++;
      fadecounter1=setTimeout("changecontent()", 500);
      fadecounter2=setTimeout("resetColor()", 400);
      fadecounter3=setTimeout("resetLinkColor()", 400); // fonctionne pas compltement Ajout couleur start dans CSS
    // }
}



/*Rafael Raposo's new function*/
function getstepcolor(step) {
  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);
    } else {
      newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
    }
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

if (ie4||DOM2) {
  // document.write('<div id="fscroller" style="border:1px solid black;width:'+fwidth+';height:'+fheight+'"></div>'); // PSR
}

if (window.addEventListener) {
  window.addEventListener("load", changecontent, false)
  // window.addEventListener("mouseover", stopChangecontent, false)
  // window.addEventListener("mouseout", armRestart, false)

}
else if (window.attachEvent) {
  window.attachEvent("onload", changecontent)
  // window.attachEvent("onmouseover", stopChangecontent)
}
else if (document.getElementById) {
  window.onload=changecontent
  // window.onmouseover=stopChangecontent
}

document.getElementById('infoflash_n0').onmouseover = stopChangecontent ;
document.getElementById('infoflash_n0').onmouseout = armRestart ;