// Text Fader JavaScript
// (c) 2002 Premshree Pillai
// http://www.qiksearch.com
// qiksearch@rediffmail.com

//modified by Roger Mathisen (2005)
//now works with css and not the font tag..
//internal support for bold and italic removed...

var TF_hexChars=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");

function TF_dec2hex(decVal)
{
 return(TF_hexChars[decVal>>4]+TF_hexChars[decVal&15]);
}

function TF_hex2dec(hexVal)
{
 return(parseInt(hexVal,16))
}

function TextFade(TF_text,TF_font,TF_fontSize,intColor,finalColor)
{
 var TF_text_arr=TF_text.split("");
 var rVal=TF_hex2dec(intColor.slice(1,3));
 var gVal=TF_hex2dec(intColor.slice(3,5));
 var bVal=TF_hex2dec(intColor.slice(5,7));
 var r_step=Math.ceil((TF_hex2dec(finalColor.slice(1,3))-rVal)/(TF_text_arr.length));
 var g_step=Math.ceil((TF_hex2dec(finalColor.slice(3,5))-gVal)/(TF_text_arr.length));
 var b_step=Math.ceil((TF_hex2dec(finalColor.slice(5,7))-bVal)/(TF_text_arr.length));
 for(var i=1; i<=TF_text_arr.length; i++)
 {
  document.write('<span style="color:#' + TF_getColor(rVal,gVal,bVal,r_step,g_step,b_step) + '; font-family:' + TF_font + '; font-size:' + TF_fontSize + ';">' + TF_text_arr[i-1] + '</span>');
  if(TF_text_arr[i]!=" ")
  {
   rVal+=r_step;
   gVal+=g_step;
   bVal+=b_step;
  }
 }
}

function TF_getColor(rcol,gcol,bcol,rstep,gstep,bstep)
{
 rcol+=rstep;
 gcol+=gstep;
 bcol+=bstep;
 return(TF_dec2hex(rcol)+TF_dec2hex(gcol)+TF_dec2hex(bcol));
}

