/***********************************************
* 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 = 4000; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=100; // 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(24,31,103); // end color (red, green, blue)

var fcontent=new Array();
begintag='<div style="font-family: Arial Narrow,Arial,sans-serif;font-size: 12px;">'; //set opening tag, such as font declarations
fcontent[0]="\"Plus Four\'s in-depth knowledge aided us greatly in developing and implementing our research project\"<br><strong>- Paddy Power (Ire)</strong>";
fcontent[1]="\"Really helped us meet our own aims and objectives in a way that was cost effective, flexible and personal...We would highly recommend Plus 4 as a result\"<br><strong>- London Borough of Waltham Forest</strong>";
fcontent[2]="\"We often ask for data to be entered at short notice and they are always willing and able to help\"<br><strong>- National Savings \& Investments</strong>";
fcontent[3]="\"We found the approach, reporting and management of the project by Plus Four very competent\"<br><strong>- London Borough of Newham</strong>";
fcontent[4]="\"I am delighted with the quality of their work, the excellent and friendly service provided and the value for money we get from them\"<br><strong>- The National Trust</strong>";
fcontent[5]="\"Able to deliver this readers' survey well within the budget and gave us plenty of advice on how to construct it to get the most useful information\"<br><strong>- National Osteoporosis Society</strong>";
fcontent[6]="\"You were flexible and open at every step of the way, and did everything we wanted\"<br><strong>- Bank of Ireland</strong>";
fcontent[7]="\"The work you guys have done for Olive this year has been exemplary…so thanks a million\"<br><strong>- Olive Insight</strong>";
fcontent[8]="\"We found them to be responsive to our needs; thorough in their approach and consistent in meeting our deadlines\"<br><strong>- OUtlook Care</strong>";
fcontent[9]="\"Once again, I have found your service to be excellent with great attention to detail and particularly good customer contact\"<br><strong>- Kirklees Metropolitan Council</strong>";
closetag='</div>';

var fwidth='236px'; //set scroller width
var fheight='80px'; //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 align="center"><div id="fscroller" style="border:1px solid #C0C0C0;padding: 5px;margin-left:5px;width:'+fwidth+';height:'+fheight+'"></div></div>');

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