/*
 
L E G A L N O T I C E
 
Copyright © 2001-2006 Protein Ltd, 10 St Catherines Road,
Hayling Island, PO11 0HE, Great Britain. All rights reserved.
 
CHROMO is patent pending: 0023451.8
 
CHROMO is a trademark of Protein Ltd.
 
PROTEIN is a registered trademark of Protein Ltd.
 
Contact: William Rowe - chromo@proteinos.com
 
Version: 2.1.1
 
Updated: 19.03.06
 
*/
 
 
 
 
var iArrColors = new Array(60);
iArrColors[0] = 0;
iArrColors[1] = 4;
iArrColors[2] = 8;
iArrColors[3] = 13;
iArrColors[4] = 17;
iArrColors[5] = 21;
iArrColors[6] = 26;
iArrColors[7] = 30;
iArrColors[8] = 34;
iArrColors[9] = 38;
iArrColors[10] = 43;
iArrColors[11] = 47;
iArrColors[12] = 51;
iArrColors[13] = 55;
iArrColors[14] = 60;
iArrColors[15] = 64;
iArrColors[16] = 68;
iArrColors[17] = 72;
iArrColors[18] = 76;
iArrColors[19] = 81;
iArrColors[20] = 85;
iArrColors[21] = 89;
iArrColors[22] = 93;
iArrColors[23] = 98;
iArrColors[24] = 102;
iArrColors[25] = 106;
iArrColors[26] = 110;
iArrColors[27] = 115;
iArrColors[28] = 119;
iArrColors[29] = 123;
iArrColors[30] = 128;
iArrColors[31] = 132;
iArrColors[32] = 136;
iArrColors[33] = 140;
iArrColors[34] = 145;
iArrColors[35] = 149;
iArrColors[36] = 153;
iArrColors[37] = 157;
iArrColors[38] = 161;
iArrColors[39] = 166;
iArrColors[40] = 170;
iArrColors[41] = 174;
iArrColors[42] = 178;
iArrColors[43] = 183;
iArrColors[44] = 187;
iArrColors[45] = 191;
iArrColors[46] = 195;
iArrColors[47] = 200;
iArrColors[48] = 204;
iArrColors[49] = 208;
iArrColors[50] = 213;
iArrColors[51] = 217;
iArrColors[52] = 221;
iArrColors[53] = 225;
iArrColors[54] = 230;
iArrColors[55] = 234;
iArrColors[56] = 238;
iArrColors[57] = 242;
iArrColors[58] = 247;
iArrColors[59] = 251;
iArrColors[60] = 255;
 
 
function getMinuteNow(){
var thetime=new Date();
atMin=(thetime.getHours() * 60) + thetime.getMinutes();
return atMin;
}
 
var loopID;
function cycle() {
var mm=getMinuteNow();
var mc=getColor(mm);
document.bgColor = mc;
if(loopID){ 
clearTimeout(loopID); 
}
loopID = setTimeout("cycle()",3000);
//alert ("h");
}
 
 
function doChromo() {
 
// *Qube removed screen.colorDepth >=24 && document.all conditional, that offended Firefox / IE6
 
cycle();
}
 
 
 
 
 
var bgcolor = "#000000";
var RGB = new Array(256);
var k = 0;
var hex = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
 
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
RGB[k] = hex[i] + hex[j];
k++;
}
}
 
function dropLeadingZeros(num){
while (num.charAt(0) == "0") {
newTerm = num.substring(1, num.length);
num = newTerm;
}
if (num == "")
num = "0";
return num;
}
 
function convert(iRed,iGreen,iBlue){
while ((iRed > 255) || (iRed < 0)) {
iRed = 0;
}
while ((iGreen > 255) || (iGreen < 0)) {
iGreen = 0;
 
}
while ((iBlue > 255) || (iBlue < 0)) {
form.blue.value = 0;
}
 
rr = RGB[iRed]
gg = RGB[iGreen]
bb = RGB[iBlue]
hexcolor = "#" + rr + gg + bb;
return hexcolor;
}
 
 
 
 
function getColor(m){
 
var iIndex=0;
var iRed=0;
var iGreen=0;
var iBlue=0;
 
if (m >= 0 && m < 239){
iRed = 0;
iGreen = 255;
iIndex = 60 - parseInt((m / 4));
iBlue = iArrColors[iIndex];
}else if (m == 240){ //04:00
iRed = 0;
iGreen = 255;
iBlue = 0;
}else if (m >= 241 && m <= 479){
iIndex = parseInt((m - 240) / 4);
iRed = iArrColors[iIndex];
iGreen = 255;
iBlue = 0;
}else if (m == 480){ //08:00
iRed = 255;
iGreen = 255;
iBlue = 0;
}else if (m >= 481 && m <= 719) {
iIndex = 60 - (parseInt((m - 480) / 4));
iRed = 255;
iGreen = iArrColors[iIndex];
iBlue = 0;
}else if (m == 720) { //12:00
iRed = 255;
iGreen = 0;
iBlue = 0;
}else if (m >= 721 && m <= 959){
iIndex = parseInt((m - 720) / 4);
iRed = 255;
iGreen = 0;
iBlue = iArrColors[iIndex];
}else if (m == 960) { //1600
iRed = 255;
iGreen = 0;
iBlue = 255;
}else if (m >= 961 && m <= 1199){
iIndex = 60 - (parseInt((m - 960) / 4));
iRed = iArrColors[iIndex];
iGreen = 0;
iBlue = 255;
}else if (m == 1200){ //2000
iRed = 0;
iGreen = 0;
iBlue = 255;
}else if (m >= 1201 && m <= 1439) {
iIndex = parseInt((m - 1200) / 4);
iRed = 0;
iGreen = iArrColors[iIndex];
iBlue = 255;
}
//alert ("Red: " + iRed + " Green: " + iGreen + " Blue: " + iBlue);
mcolor=convert(iRed,iGreen,iBlue);
return mcolor;
}