// CREDITS:
// Background Random Fader
// by Urs Dudli and Peter Gehrig 
// Copyright (c) 2001 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.24fun.com
// info@24fun.com
// 10/1/2001

// IMPORTANT: 
// If you add this script to a script-library or a script-archive 
// you are required to insert a highly visible link to http://www.24fun.com
// right into the webpage where the script
// will be displayed.

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION STARTS HERE
///////////////////////////////////////////////////////////////////////////

// Choose a fade effect by configuering the variable  fade_effect below:
// Set 1 if the background should fade from dark to medium and back to dark
// Set 2 if the background should fade from light to medium and back to light
// Set 3 if the background should fade from light to dark and back to light
// Set 4 if the background should fade from light to very light and back to light
// Set 5 if the background should fade from dark to very dark and back to dark
var fade_effect=6

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION ENDS HERE
///////////////////////////////////////////////////////////////////////////


var darkmax=120
var lightmax=200

var hexc = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F')

var greenrgb=lightmax

var greencol_1 
var greencol_2 
 
var stepmax=3
var stepgreen=Math.ceil(stepmax*Math.random())

function setrandomstep() {
	stepgreen=Math.ceil(stepmax*Math.random())
}

function makedarker() {
	greenrgb-=stepgreen
	if (greenrgb<darkmax) {greenrgb=darkmax}
	if (greenrgb>darkmax) {
	 	greencol_1 = hexc[Math.floor(greenrgb/16)];
      	greencol_2 = hexc[greenrgb%16];
	  	var backcolor="#7f"+greencol_1+greencol_2+"4d";
	  	document.bgColor=backcolor 
		var timer=setTimeout("makedarker()",100);
    } 
  	else {
  		clearTimeout(timer)
		setrandomstep()
		setTimeout("makelighter()",2000)
  	}
}

function makelighter() {
	greenrgb+=stepgreen
	if (greenrgb>=lightmax) {greenrgb=lightmax}
	
	if (greenrgb<lightmax) {
	 	greencol_1 = hexc[Math.floor(greenrgb/16)];
      	greencol_2 = hexc[greenrgb%16];
	  	var backcolor="#7f"+greencol_1+greencol_2+"4d";
	  	document.bgColor=backcolor 
		var timer=setTimeout("makelighter()",100);
    } 
  	else {
  		clearTimeout(timer)
		setrandomstep()
		setTimeout("makedarker()",2000)
  	}
}
makedarker()
