//You are free to use this code in your website provided you contact me and ask my permission.  My e-mail address is
//benjamingarrison@juno.com.

var IE4=document.all;
var r=0;
var link;


function gradient(startColor, endColor, dispText)
//This function makes a string of text( dispText ) change from startColor to endColor from beginning to end.
//Start color and endcolor are 3 byte hex strings.
{
	var returnString="";
	var red, green, blue;

	var sRed=dec(startColor.substring(0,2));
	var sGreen=dec(startColor.substring(2,4));
	var sBlue=dec(startColor.substring(4,6));

	var eRed=dec(endColor.substring(0,2));
	var eGreen=dec(endColor.substring(2,4));
	var eBlue=dec(endColor.substring(4,6));

	for(i=0;i<dispText.length;i++)
	{
		red=Math.round(sRed+(eRed-sRed)*i/dispText.length);
		green=Math.round(sGreen+(eGreen-sGreen)*i/dispText.length);
		blue=Math.round(sBlue+(eBlue-sBlue)*i/dispText.length);
		returnString+="<font color=\"#"+hex(red)+hex(green)+hex(blue)+"\">"+dispText.substring(i,i+1)+"</font>";
	}
	return returnString;
}


function hex(value)
//This function takes a value from 0 to 256 and converts it into a 1 byte hex string.
{
	var str1,str2;
	if(value<10) return "0"+value;
	if(value<160)	var str1=""+Math.floor(value/16);
	else
	{
		v1=Math.floor(value/16);
		if(v1==10) str1="A";
		if(v1==11) str1="B";
		if(v1==12) str1="C";
		if(v1==13) str1="D";
		if(v1==14) str1="E";
		if(v1==15) str1="F";
	}
	if((value/16-Math.floor(value/16))*16<10) str2=""+((value/16-Math.floor(value/16))*16);
	else
	{
		v2=(value/16-Math.floor(value/16))*16;
		if(v2==10) str2="A";
		if(v2==11) str2="B";
		if(v2==12) str2="C";
		if(v2==13) str2="D";
		if(v2==14) str2="E";
		if(v2==15) str2="F";
	}
	return str1+str2;
}


function dec(hexString)
//This function is the opposite of hex()...it takes a 1 byte hexstring and converts it into a number.
{
	var dec;
	if(hexString.substring(0,1)=="A") dec=160;
	else if(hexString.substring(0,1)=="B") dec=176;
	else if(hexString.substring(0,1)=="C") dec=192;
	else if(hexString.substring(0,1)=="D") dec=208;
	else if(hexString.substring(0,1)=="E") dec=224;
	else if(hexString.substring(0,1)=="F") dec=240;
	else dec=parseInt(hexString.substring(0,1))*16;

	if(hexString.substring(1,2)=="A") dec+=10;
	else if(hexString.substring(1,2)=="B") dec+=11;
	else if(hexString.substring(1,2)=="C") dec+=12;
	else if(hexString.substring(1,2)=="D") dec+=13;
	else if(hexString.substring(1,2)=="E") dec+=14;
	else if(hexString.substring(1,2)=="F") dec+=15;
	else dec+=parseInt(hexString.substring(1,2));
	return dec;
}


function red()
//This function begins the link change, which is completed by lower_red().  To get the fading link effect, add the CHANGE attribute to a link.
{
	var lnk=event.srcElement;
	link=lnk;
	if(IE4 && (lnk.getAttribute("CHANGE") != null))
	{
		lnk.style.color="#FF0000";
		r=255;
		setTimeout("lower_red()",350);
	}
}

function lower_red()
//Lowers the red content of the link color, and raises the blue content
{
	if(IE4) {
		r-=5;
		if(r>0)link.style.color="#"+hex(r)+"00"+hex(255-r);
		if(r>5) setTimeout("lower_red()", 0);
	}
}


function blue()
//Returns link to normal color.
{
	var lnk=event.srcElement;
	if(IE4 && (lnk.getAttribute("CHANGE") != null))
	{
		r=0;
		lnk.style.color="#0000FF";
	}
}

//Event handlers
document.onmouseover=red;
document.onmouseout=blue;