/*** 2010-08-27 AmigoJack ***/
function shiftColors( sID, iMS ) {
	var eP= document.getElementById( 'rainbow'+ sID );
	var s0= eP.childNodes[0].style.color;
	for( var i= 0; i< eP.childNodes.length- 1; i++ ) eP.childNodes[i].style.color= eP.childNodes[i+ 1].style.color;
	eP.childNodes[eP.childNodes.length- 1].style.color= s0;
	window.setTimeout( 'shiftColors( \''+ sID+ '\', '+ iMS+ ' )', iMS );
}
function parseColors( sC ) {
	if( sC.length== 3 ) sC= sC.substr( 0, 1 )+ sC.substr( 0, 2 )+ sC.substr( 1, 2 )+ sC.substr( 2, 1 );
	return new Array( parseInt( sC.substr( 0, 2 ), 16 ), parseInt( sC.substr( 2, 2 ), 16 ), parseInt( sC.substr( 4, 2 ), 16 ) );
}
function textRainbow( sID, iMS ) {
	var eP= document.getElementById( 'rainbow'+ sID );
	var s= eP.childNodes[0].nodeValue;
	while( eP.hasChildNodes() ) eP.removeChild( eP.childNodes[0] );

	var i, iPS, iPL, iS, iC, iRGB, sC;
	var aC= sID.split( '-' );
	if( aC.length< 2|| s.length== 0 ) return;
	for( i= 0; i< aC.length; i++ ) aC[i]= parseColors( aC[i] );

	var fP= s.length/ ( aC.length- 1 );
	for( iS= 0; iS< aC.length- 1; iS++ ) {
		iPS= Math.round( fP* iS );
		iPL= Math.round( fP* ( iS+ 1 ) );

		for( iC= iPS; iC< iPL; iC++ ) {
			sC= '#';
			for( iRGB= 0; iRGB<= 2; iRGB++ ) {
				i= Math.round( aC[iS][iRGB]+ ( ( aC[iS+ 1][iRGB]- aC[iS][iRGB] )/ ( iPL- iPS- 1 ) )* ( iC- iPS ) );
				sC+= ( i< 16? '0': '' )+ i.toString( 16 );
			}

			eC= document.createElement( 'span' );
			eC.appendChild( document.createTextNode( s.substr( iC, 1 ) ) );
			eC.style.color= sC;
			eP.appendChild( eC );
		}
	}

	if( iMS>= 50 ) shiftColors( sID, iMS );
}

