tr=0; tg=102; tb=204;

function ini() {
 setInterval('rot();',50);
}

function rot() {
 tr++; if (tr>304) tr=0;
 tg++; if (tg>304) tg=0;
 tb++; if (tb>304) tb=0;
 changecss(grgb(tr),grgb(tg),grgb(tb));
}

function grgb(ax) {
 var ar, ag, ab;
 if (ax<51)       { ar=255;       ag=ax*4;    ab=0; }
 else if (ax<102) { ar=510-5*ax;  ag=204;      ab=0; }
 else if (ax<153) { ar=0;         ag=204;      ab=5*ax-510; }
 else if (ax<204) { ar=0;         ag=816-4*ax; ab=255; }
 else if (ax<255) { ar=5*ax-1020; ag=0;        ab=255; }
 else             { ar=255;       ag=0;        ab=1525-5*ax; }
 return 'rgb('+ar+','+ag+','+ab+')';
}

function changecss(ared,agreen,ablue) {
 var CSSRules
 if (document.all) CSSRules = 'rules';
 else if (document.getElementById) CSSRules = 'cssRules';
 else return;
 for (var i = 0; i < document.styleSheets[1][CSSRules].length; i++) {
  if (document.styleSheets[1][CSSRules][i].selectorText == '.red')
	document.styleSheets[1][CSSRules][i].style.color = ared;
  if (document.styleSheets[1][CSSRules][i].selectorText == '.gre')
	document.styleSheets[1][CSSRules][i].style.color = agreen;
  if (document.styleSheets[1][CSSRules][i].selectorText == '.blu')
	document.styleSheets[1][CSSRules][i].style.color = ablue;
 }	
}
 
