// CREDITS:
// Scrollbar Fader, full control
// By Peter Gehrig
// Copyright (c) 2002 Peter Gehrig. 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
// 8/31/2002

// IMPORTANT:
// If you add this script to a script-library or script-archive
// you have to add a highly visible link to
// http://www.24fun.com on the webpage
// where this script will be featured

// CONFIGURATION:
// Go to http://www.24fun.com
// and create your own text animation
// with our new Text Factory.

var colorhexafrom=new Array()
colorhexafrom[0]="#000000"
colorhexafrom[1]="#00ff00"
colorhexafrom[2]="#0070A6"
colorhexafrom[3]="#E600E6"
colorhexafrom[4]="#000000"
colorhexafrom[5]="#000000"
var colorhexato=new Array()
colorhexato[0]="#e4007f"
colorhexato[1]="#ffffff"
colorhexato[2]="#FF0000"
colorhexato[3]="#ffffff"
colorhexato[4]="#ffffff"
colorhexato[5]="#000000"
var pausebetweencolors=500
var i_loopmax=9999999999
var i_stepmax=20
var backcolor=new Array()
var hexc=new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F')
var redcol_1
var redcol_2
var greencol_1
var greencol_2
var bluecol_1
var bluecol_2
var rgbredfrom=new Array()
var rgbgreenfrom=new Array()
var rgbbluefrom=new Array()
var rgbredto=new Array()
var rgbgreento=new Array()
var rgbblueto=new Array()
var rgbrednow=new Array()
var rgbgreennow=new Array()
var rgbbluenow=new Array()
var i_step=1
var i_loop=0

function translateintorgb() {
	for (i=0;i<=5;i++) {
		var hexa=colorhexafrom[i]
		var hexared=hexa.substring(1,3)
		var hexagreen=hexa.substring(3,5)
		var hexablue=hexa.substring(5,7)
		rgbredfrom[i]=parseInt("0x"+hexared)
		rgbgreenfrom[i]=parseInt("0x"+hexagreen)
		rgbbluefrom[i]=parseInt("0x"+hexablue)
		rgbrednow[i]=rgbredfrom[i]
		rgbgreennow[i]=rgbgreenfrom[i]
		rgbbluenow[i]=rgbbluefrom[i]
		var hexa=colorhexato[i]
		var hexared=hexa.substring(1,3)
		var hexagreen=hexa.substring(3,5)
		var hexablue=hexa.substring(5,7)
		rgbredto[i]=parseInt("0x"+hexared)
		rgbgreento[i]=parseInt("0x"+hexagreen)
		rgbblueto[i]=parseInt("0x"+hexablue)
	}
	changefromto()
}

function changefromto() {
	if (i_step<=i_stepmax) {
		for (i=0;i<=5;i++) {
			rgbrednow[i]=rgbrednow[i]-((rgbredfrom[i]-rgbredto[i])/i_stepmax)
			rgbgreennow[i]=rgbgreennow[i]-((rgbgreenfrom[i]-rgbgreento[i])/i_stepmax)
			rgbbluenow[i]=rgbbluenow[i]-((rgbbluefrom[i]-rgbblueto[i])/i_stepmax)
			if (rgbrednow[i]>255) {rgbrednow[i]=255}
			if (rgbrednow[i]<0) {rgbrednow[i]=0}
			if (rgbgreennow[i]>255) {rgbgreennow[i]=255}
			if (rgbgreennow[i]<0) {rgbgreennow[i]=0}
			if (rgbbluenow[i]>255) {rgbbluenow[i]=255}
			if (rgbbluenow[i]<0) {rgbbluenow[i]=0}
      		redcol_1=hexc[Math.floor(rgbrednow[i]/16)];
     		redcol_2=hexc[Math.floor(rgbrednow[i])%16];
	 		greencol_1=hexc[Math.floor(rgbgreennow[i]/16)];
      		greencol_2=hexc[Math.floor(rgbgreennow[i])%16];
			window.status=rgbgreennow[i]
	  		bluecol_1=hexc[Math.floor(rgbbluenow[i]/16)];
      		bluecol_2=hexc[Math.floor(rgbbluenow[i])%16];
	  		backcolor[i]="#"+redcol_1+redcol_2+greencol_1+greencol_2+bluecol_1+bluecol_2 
		}
		document.body.style.scrollbarShadowColor=backcolor[0] 
		document.body.style.scrollbarHighlightColor=backcolor[1] 
		document.body.style.scrollbarFaceColor=backcolor[2] 
		document.body.style.scrollbar3dLightColor=backcolor[3] 
		document.body.style.scrollbarArrowColor=backcolor[4] 
		document.body.style.scrollbarDarkShadowColor=backcolor[5] 

		var timer=setTimeout("changefromto()",50);
		i_step++
    } 
  	else {
  		clearTimeout(timer)
		i_step=1
		i_loop++
		if (i_loop<i_loopmax) {var timer=setTimeout("changetofrom()",pausebetweencolors);}
  	}
}

function changetofrom() {
	if (i_step<=i_stepmax) {
		for (i=0;i<=5;i++) {
			rgbrednow[i]=rgbrednow[i]-((rgbredto[i]-rgbredfrom[i])/i_stepmax)
			rgbgreennow[i]=rgbgreennow[i]-((rgbgreento[i]-rgbgreenfrom[i])/i_stepmax)
			rgbbluenow[i]=rgbbluenow[i]-((rgbblueto[i]-rgbbluefrom[i])/i_stepmax)
			if (rgbrednow[i]>255) {rgbrednow[i]=255}
			if (rgbrednow[i]<0) {rgbrednow[i]=0}
			if (rgbgreennow[i]>255) {rgbgreennow[i]=255}
			if (rgbgreennow[i]<0) {rgbgreennow[i]=0}
			if (rgbbluenow[i]>255) {rgbbluenow[i]=255}
			if (rgbbluenow[i]<0) {rgbbluenow[i]=0}
      		redcol_1=hexc[Math.floor(rgbrednow[i]/16)];
     		redcol_2=hexc[Math.floor(rgbrednow[i])%16];
	 		greencol_1=hexc[Math.floor(rgbgreennow[i]/16)];
      		greencol_2=hexc[Math.floor(rgbgreennow[i])%16];
	  		bluecol_1=hexc[Math.floor(rgbbluenow[i]/16)];
      		bluecol_2=hexc[Math.floor(rgbbluenow[i])%16];
	  		backcolor[i]="#"+redcol_1+redcol_2+greencol_1+greencol_2+bluecol_1+bluecol_2 

		}
		document.body.style.scrollbarShadowColor=backcolor[0] 
		document.body.style.scrollbarHighlightColor=backcolor[1] 
		document.body.style.scrollbarFaceColor=backcolor[2] 
		document.body.style.scrollbar3dLightColor=backcolor[3] 
		document.body.style.scrollbarArrowColor=backcolor[4] 
		document.body.style.scrollbarDarkShadowColor=backcolor[5] 
		var timer=setTimeout("changetofrom()",30);
		i_step++
    } 
  	else {
  		clearTimeout(timer)
		i_step=1
		i_loop++
		if (i_loop<i_loopmax) {var timer=setTimeout("changefromto()",pausebetweencolors);}
  	}
}
window.onload=translateintorgb
