var str = document.title;//The string to print
var ilen=str.length;
var R=64,G=63,B=15;//your base color to start at

//setup the color increments
var seedR=Math.round((255-R)/ilen);
var seedG=Math.round((255-G)/ilen);
var seedB=Math.round((255-B)/ilen);

//converts the decimal RGB values into hex
function GetRGB(R,G,B)
{
    var s,k;
    k=R.toString(16);
    ((k.length<2)?s="0"+k:s=k);
    k=G.toString(16);    
    ((k.length<2)?s=s+"0"+k:s=s+k);
    k=B.toString(16);    
    ((k.length<2)?s=s+"0"+k:s=s+k); 
    return(s);
}

//gets the next color in the sequence
function NextColor(clr)
{
    return(GetRGB(clr*seedR+R,clr*seedG+G,clr*seedB+B));
}

//writes the string to the document
function colorit()
{
    var j=0;
    for(i=0;i<str.length;i++)
    {
        switch(str.charAt(i))
        {
            case ' ' ://spaces aren't colored so skip them 
                document.write('&nbsp;&nbsp;');            
                break;

            case '<' ://allow html tags
                do
                {
                    document.write(str.charAt(i));            
                    i++;
                }while(str.charAt(i)!='>');
                document.write(str.charAt(i));
                break;
               
            default :        
                j++;
                document.write('<FONT FACE="Lydian,MS Sans Serif,Arial" SIZE="8" COLOR="#'+NextColor(j)+'"><b>'+str.charAt(i)+'</B></FONT>');
        }
    }
}
colorit();
