<script language="JavaScript">

<!--
/*************************************************************
 *Fade script By Boris Da Spider
*Java Rocks!!
*Please check out my Mommys site at
*http://www.thelawyerssolution.com
 */

function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

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];
}

function setbgColor(r, g, b) {
    var hr = hex(r); var hg = hex(g); var hb = hex(b);
    document.bgColor = "#"+hr+hg+hb;
}

var sr, sg, sb, er, eg, eb, step;
var i, delayval, timerid;

function fade(_sr, _sg, _sb, _er, _eg, _eb, _step, _delay)
{
    sr = _sr;
    sg = _sg;
    sb = _sb;
    er = _er;
    eg = _eg;
    eb = _eb;
    step = _step;
    i = 0;
    delayval = _delay;
    fadehelp();
}
 

function fadehelp()
{
//    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)));
 
     i++;

     if (i == step)
     {
          clearTimeout(timerid);
          return;
     }
     else
     {
          timerid = setTimeout('fadehelp()', delayval);
     }

//    }
}

/* Usage:
 *   fade(inr,ing,inb, outr,outg,outb, step, msdelay);
 * example.
 *   fade(0,0,0, 255,255,255, 255);
 * fade from black to white with very slow speed.
 *   fade(255,0,0, 0,0,255, 50);
 *   fade(0xff,0x00,0x00, 0x00,0x00,0xff, 50); // same as above
 * fade from red to blue with fast speed.
 * step 2 is very fast and step 255 is very slow.
 *
 */

/*

  NOTES FROM BORIS

The last parameter supplied is the delay, in milliseconds, between
"steps" of the fade.  This allows it to be more consistent across
Javascript implementations because it depends on the speed of the
clock instead of the processor.  A value of 10ms seems to work well on
Windows/NT running Navigator 3.0. Thankyou Rocky for pointing that out.

 
*/

function fadein() {
    fade(0,0,0, 255,255,255, 64, 10);
}

function fadeout() {
    fade(255,255,255, 0,0,0, 64, 10);
}

/* do fadein */
fadein();

/***** end fade script *****/
/************************************************************/

// -->

</script>