<!-- Begin
// This code fades the background color of a page.
// It is only complex because it allows you to specify the color in decimal.
// half the code is only there to convert the decimal value to hex.
// Try and rewite it so that you specify the color in hex - see how few lines of code
// are needed to get the same effect.



// Set up an array and fill it with zeros

function makearray(n) {
this.length = n;
for(var i = 1; i <= n; i++)
this[i] = 0;
return this;
}


// Put the right values in the array, so that we can use it to convert // decimal to hex

hexa = new makearray(16);
for(var i = 0; i < 10; i++)
hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";
function hex(i) {
if (i < 0)
return "00";
else if (i > 255)
return "ff";
else
return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}


// Take Red Green Blue in decimal and convert calues to Hex 
// Then set the background color of the document

function setbgColor(r, g, b) {
var hr = hex(r); var hg = hex(g); var hb = hex(b);
document.bgColor = "#"+hr+hg+hb;
}



// The actual function that we call
// sr,sg,sb are the red, green and blue start values
// er,eg,eb are the red, green and blue end values
// step is the number of steps - the bigger the value the slower and 
// smoother the fade

function fade(sr, sg, sb, er, eg, eb, step) {
for(var i = 0; i <= step; i++) {
setbgColor(
Math.floor(sr * ((step-i)/step) + er * (i/step)),
Math.floor(sg * ((step-i)/step) + eg * (i/step)),
Math.floor(sb * ((step-i)/step) + eb * (i/step)));
   }
}


// Actually calling the function
// start at 255,255,255 which is white
// fade to 0,200,255 which is a nice blue
// in 100 steps - which looks OK in explorer, but a bit fast in
// netscape




// End -->
