
/***********************************************
* 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
***********************************************/

begintag_SP='<div class="specialPricesContents">'; //set opening tag, such as font declarations
closetag_SP='</div>';


var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.

var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay_SP=0;
var index_SP=0;
/*var fwidth_SP='100%'*/
/*var fheight_SP='60px'*/


/*Rafael Raposo edited function*/
//function to change content
function changecontent_SP(){
  if (index_SP>=fcontent_SP.length)
    index_SP=0
  if (DOM2){
    document.getElementById("fscroller_SP").style.color="rgb("+startcolor_SP[0]+", "+startcolor_SP[1]+", "+startcolor_SP[2]+")"
    document.getElementById("fscroller_SP").innerHTML=begintag_SP+fcontent_SP[index_SP]+closetag_SP
    if (fadelinks)
      linkcolorchange_SP(1);
    colorfade_SP(1, 15);
  }
  else if (ie4)
    document.all.fscroller_SP.innerHTML=begintag_SP+fcontent_SP[index_SP]+closetag_SP;
  index_SP++
}

// colorfade_SP() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

function linkcolorchange_SP(step){
  var obj=document.getElementById("fscroller_SP").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_SP;
function colorfade_SP(step) {
  if(step<=maxsteps_SP) {	
    document.getElementById("fscroller_SP").style.color=getstepcolor(step);
    if (fadelinks)
      linkcolorchange_SP(step);
    step++;
    fadecounter_SP=setTimeout("colorfade_SP("+step+")",stepdelay_SP);
  }else{
    clearTimeout(fadecounter_SP);
    document.getElementById("fscroller_SP").style.color="rgb("+endcolor_SP[0]+", "+endcolor_SP[1]+", "+endcolor_SP[2]+")";
    setTimeout("changecontent_SP()", delay_SP);
	
  }   
}

/*Rafael Raposo's new function*/
function getstepcolor(step) {
  var diff
  var newcolor=new Array(3);
  for(var i=0;i<3;i++) {
    diff = (startcolor_SP[i]-endcolor_SP[i]);
    if(diff > 0) {
      newcolor[i] = startcolor_SP[i]-(Math.round((diff/maxsteps_SP))*step);
    } else {
      newcolor[i] = startcolor_SP[i]+(Math.round((Math.abs(diff)/maxsteps_SP))*step);
    }
  }
  return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}

if (ie4||DOM2)
  document.write('<div id="fscroller_SP" style="border:0px solid black;width:'+fwidth_SP+';height:'+fheight_SP+'"></div>');

if (window.addEventListener)
window.addEventListener("load", changecontent_SP, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent_SP)
else if (document.getElementById)
window.onload=changecontent_SP
