﻿

/***********************************************
* 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 delay2 = 8000; //set delay between message change (in miliseconds)
var maxsteps2=30; // number of steps to take to change from start color to endcolor
var stepdelay2=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor2= new Array(255,255,255); // start color (red, green, blue)
var endcolor2=new Array(0,0,0); // end color (red, green, blue)

var fcontent2=new Array();
begintag2='<div style="font: normal 12px Arial;color:#663300;padding-top:10px">'; //set opening tag, such as font declarations

fcontent2[0] = "<b>Mayor Tony Santos</b><br>San Leandro, CA";
fcontent2[1] = "<b>Mayor Sami Barile</b><br>Morristown, TN";
fcontent2[2] = "<b>Mayor Jim Miron</b><br>Stratford, CT";
fcontent2[3] = "<b>Mayor Gabriel Campana</b><br>Williamsport, PA";
fcontent2[4] = "<b>Mayor Bill White</b><br>Houston, TX";
fcontent2[5] = "<b>Mayor Heather Hudson</b><br>Greenville, MS";
fcontent2[6] = "<b>Dr. Ian Smith</b><br>Founder, The Challenge";

closetag2='</div>';

var fwidth2 = '200px'; //set scroller width
/*var fheight2='190px'; //set scroller height */
var fheight2='150px'; //set scroller height

var fadelinks2=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.

///No need to edit below this line/////////////////


var ie42=document.all&&!document.getElementById;
var DOM22=document.getElementById;
var faderdelay2=0;
var index2=0;


/*Rafael Raposo edited function*/
//function to change content
function changecontent2(){
  if (index2>=fcontent2.length)
    index2=0
  if (DOM22){
    document.getElementById("fscroller2").style.color="rgb("+startcolor2[0]+", "+startcolor2[1]+", "+startcolor2[2]+")"
    document.getElementById("fscroller2").innerHTML=begintag2+fcontent2[index2]+closetag2
    if (fadelinks2)
      linkcolorchange2(1);
    colorfade2(1, 15);
  }
  else if (ie42)
    document.all.fscroller2.innerHTML=begintag2+fcontent2[index2]+closetag2;
  index2++
}

// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

function linkcolorchange2(step){
  var obj2=document.getElementById("fscroller2").getElementsByTagName("A");
  if (obj2.length>0){
    for (i=0;i<obj2.length;i++)
      obj2[i].style.color=getstepcolor2(step);
  }
}

/*Rafael Raposo edited function*/
var fadecounter2;
function colorfade2(step) {
  if(step<=maxsteps2) {	
    document.getElementById("fscroller2").style.color=getstepcolor2(step);
    if (fadelinks2)
      linkcolorchange2(step);
    step++;
    fadecounter2=setTimeout("colorfade2("+step+")",stepdelay2);
  }else{
    clearTimeout(fadecounter2);
    document.getElementById("fscroller2").style.color="rgb("+endcolor2[0]+", "+endcolor2[1]+", "+endcolor2[2]+")";
    setTimeout("changecontent2()", delay2);
	
  }   
}

/*Rafael Raposo's new function*/
function getstepcolor2(step) {
  var diff2
  var newcolor2=new Array(3);
  for(var i=0;i<8;i++) {
    diff2 = (startcolor2[i]-endcolor2[i]);
    if(diff2 > 0) {
      newcolor2[i] = startcolor2[i]-(Math.round((diff2/maxsteps2))*step);
    } else {
      newcolor2[i] = startcolor2[i]+(Math.round((Math.abs(diff2)/maxsteps2))*step);
    }
  }
  return ("rgb(" + newcolor2[0] + ", " + newcolor2[1] + ", " + newcolor2[2] + ")");
}

if (ie42||DOM22)
  document.write('<div id="fscroller2" style="width:'+fwidth2+';height:'+fheight2+';text-align:right"></div>');

if (window.addEventListener)
window.addEventListener("load", changecontent2, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent2)
else if (document.getElementById)
window.onload=changecontent2

