/***********************************************
* 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=60; // 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(241,237,224); // start color (red, green, blue)
var endcolor=new Array(89,85,74); // end color (red, green, blue)

var fcontent=new Array();
begintag='<div>'; //set opening tag, such as font declarations
fcontent[0]="<p>U.S. fire departments respond to nearly 2 million fires, with three-quarters of them occurring in residences. Fire costs our national billions of dollars every year in property loss and thousands of lives lost.</p>";
fcontent[1]="<p>From 1992 to 1996, an annual average of 97,300 cooking fires caused 310 civilian deaths, 4,830 civilian injuries and almost $400 million in direct property damage.</p>";
fcontent[2]="<p>Water damage and freezing pipes made up over 21% of ALL insurance claims in 2003.</p>";
fcontent[3]="<p>One quarter of home-fire victims die from burns; seven out of 10 die from breathing poisonous gases produced by the fire.</p>";
fcontent[4]="<p>The 2005 Atlantic hurricane season was the most active since record keeping began in 1851 with 27 named storms. The 2006 hurricane season was close to average with nine named storms.</p>";
fcontent[5]="<p>The most common deadly gas produced by a fire is carbon monoxide (produced by all burning items). Other significant gases include hydrogen cyanide, hydrogen chloride and carbon dioxide.</p>";
fcontent[6]="<p>A small water pipe leak inside a wall or under a slab may go undetected for months. In contrast, an 1/8-inch crack in a pipe can release up to 250 gallons of water a day.</p>";
fcontent[7]="<p>Heating equipment causes over 70,000 fires a year. Arson or suspected arson causes over 50,000 fires a year. Other (or unspecified) household equipment causes over 40,000 fires a year.</p>";
fcontent[8]="<p>The majority of fatal home fires that occur happen at night, when most people are asleep. Smoking is the #1 cause of fatal home fires. Smoking caused an average of 850 deaths per year from 1992 to 1996.</p>";
fcontent[9]="<p>Flash flooding is the leading cause of weather-related deaths in the U.S.- approximately 200 deaths per year. Over 50% of flood-related drownings are vehicle-related.</p>";
fcontent[10]="<p>Deaths from fires and burns are the fifth most common cause of unintentional injury deaths in the United States (CDC 2005) and the third leading cause of fatal home injury (Runyan 2004).</p>";
fcontent[11]="<p>Conditions for mold increase when you have water damage in your house due to a burst pipe, a roof leak or a heavy summer storm. Damp wood and sheetrock provide excellent conditions for toxic mold.</p>";
fcontent[12]="<p>In 2003, there were 388,500 reported home fires in the United States, resulting in 3,145 deaths, 13,650 injuries and $5.9 billion in direct property damage. In the US, someone dies from a home fire roughly every three hours.</p>";
closetag='</div>';

var fwidth='224px'; //set scroller width
var fheight='115px'; //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]+")"
    document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
    if (fadelinks)
      linkcolorchange(1);
    colorfade(1, 15);
  }
  else if (ie4)
    document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
  index++
}

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

function linkcolorchange(step){
  var obj=document.getElementById("fscroller").getElementsByTagName("A");
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color=getstepcolor(step);
  }
}

/*Rafael Raposo edited function*/
var fadecounter;
function colorfade(step) {
  if(step<=maxsteps) {	
    document.getElementById("fscroller").style.color=getstepcolor(step);
    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]+")";
    setTimeout("changecontent()", delay);
	
  }   
}

/*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="width:'+fwidth+';height:'+fheight+'"></div>');

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent

