/***********************************************
* 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
***********************************************/

/* Edited by Tim Withers on 2/09/06 for horsefinders.com */

var delay = 5500; //set delay between message change (in miliseconds)
var maxsteps=50; // number of steps to take to change from start color to endcolor
var stepdelay=50; // 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(110,110,110); // end color (red, green, blue)

var fcontent=new Array();
begintag='<div style="font: bold 16px Arial;">'; //set opening tag, such as font declarations
	fcontent[0]="buy, sell, dream";
	fcontent[1]="to buy or to sell that is the question";
	fcontent[2]="buy a horse a day, that's all we ask";
	fcontent[3]="we find horses and we're good";
	fcontent[4]="more horses, more places, more fun";
	fcontent[5]="I dream horses";
	fcontent[6]="pferde, cavallo, paard, cheval, лошадь, all good";
	fcontent[7]="so many horses, so little time";
	fcontent[8]="\"hello four legs\", \"hello two legs\"";
	fcontent[9]="I ride therefore I am";
	fcontent[10]="have you hugged your horse today?";
	fcontent[11]="make peace with the world, then go ride your horse";
	fcontent[12]="the outside of a horse is good for the inside of a person";
	fcontent[13]="I'd rather be dumped by a horse than dumped by a man!";
	fcontent[14]="show me your horse and I will tell you what you are";
	fcontent[15]="there are fools, damn fools, and those who remount in a steeplechase";
	fcontent[16]="carrots, carrots and more carrots";
	fcontent[17]="I whisper to my horse, but he never listens!";
	fcontent[18]="a mule is just like a horse, but even more so";
	fcontent[19]="the hardest thing about learning to ride is the ground!";
	fcontent[20]="I live in a house but my home is in the stable";
	fcontent[21]="been There... Jumped That!";
	fcontent[22]="when in doubt, leave one stride out!";
	fcontent[23]="it is the difficult horses that have the most to give you";
	fcontent[24]="whinnying is everything";
	fcontent[25]="may the horse be with you";
	fcontent[26]="the horse wrote history";
	fcontent[27]="be wary of the horse with a sense of humour";
	fcontent[28]="horses give us the wings we lack";
	fcontent[29]="may a horse touch your heart";

closetag='</div>';

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"></div>');
*/

if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent