/***********************************************
* 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=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(143,178,1); // start color (red, green, blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)

var fcontent=new Array();
begintag='<div class="text">'; //set opening tag, such as font declarations
fcontent[0]='Our experience working with Hidden Brains has been nothing but extraordinary. We had envisioned a highly sophisticated interactive website which the staff members of Hidden Brains ..... We could not be happier with the process, service, suggestions and advice received from Hidden Brains.<div class="dr">Amy - USA based client</div>';
fcontent[1]='We are very pleased with the results of our recent project  Hiddenbrains worked with us on. This was a very complicated undertaking and  their developers were able to deliver it on time and on budget. Their staff  worked tirelessly to meet our timelines. We can&acute;t wait to work with them again!<div class="dr">Jon - USA based client</div>'
fcontent[2]='The service provided by Hidden Brains was not only professional, but friendly and courteous... the service provided exceeded our expectations... They were supportive, open minded, great communicators and very easy to deal with. Would recommend Hiddenbrains to any organization...<div class="dr">Ryan - Australia  based Company Owner</div>';
fcontent[3]='It was a pleasure working with Hiddenbrains. Their service  is very good and we are very happy with the application they built for us! Will  definitely use their service again in the future!<div class="dr">Rizger - Switzerland  based Customer</div>';
fcontent[4]='I appreciate the support working time with your team and the  dynamic, autonomy and fast thinking way of Dave and colleagues.<div class="dr">- Gilbert, Europe Based  Hotel Company Owner</div>';
fcontent[5]='During my research to find a company to develop my product I contacted 7 different companies... and the one that was more attentive, accurate with the scope of my project, and responsive were you guys...thank you very much for the SUPERB CUSTOMER SERVICE...<div class="dr">- Alex - USA based client</div>';

closetag='</div>';

var fwidth='204px'; //set scroller width
var fheight=''; //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="border:none;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
