/* SOURCE CODE from http://www.ozzu.com/ftopic34865.html */

/*##### In-page override & linking template
###### Make sure these are the LAST scripts declared in the page ####

This code has been customized for this site. 
Be sure to look at the original source code.

The following are overrides that can be 
written on a specific page instead of 
using the script's global defaults

# Example I:
<script type="text/javascript">
	var fadeTo = "";
	var fadeBy = 6;
	var speed = 15;
	var ignoreClasses = [];
	var ignoreColors = [];
</script>
<script type="text/javascript" src="fader2.js"></script>

# Example II:
<script type="text/javascript">
<!--
var fadeTo = "bbb";
var ignoreClasses = ["ignore", "ignore2"];
var ignoreColors = ["123456", "654321"];
-->
</script>



##### Default Settings in absence of overrides ################*/
/* Color to fade to (abcdef OR 000) */
if(!fadeTo)
	{
		var fadeTo = "FF3300";
	}
/* Fade colour increment/decrement by (higher is faster) */
if(!fadeBy)
	{
		var fadeBy = 4;
	}
/* Speed (lower is faster) */
if(!speed)
	{
		var speed = 20;
	}
/* Class names of links to ignore ["ignore", "thisTo"] */
if(!ignoreClasses)
	{
		var ignoreClasses = [];
	}
/* Colors to ignore (abcdef OR FFF) ["abcdef", "000"] */
if(!ignoreColors)
	{
		var ignoreColors = [];
	}	
/*##### Stop Editing Here #############################*/
sets={brow:3,fCol:h2RGB(fadeTo,true),iggyCols:[],colorList:[],
	cs:[["links[","].style.color"],["links[","].currentStyle.color"],
	["defaultView.getComputedStyle(document.links[","], '').getPropertyValue('color')"]]
};
if(navigator.userAgent.indexOf("Opera") != -1){sets.brow=0;}
else if(document.all && sets.brow!=0){sets.brow=1;}
else if(!document.all && document.getElementById){sets.brow=2;}

function overLoad(e,m,nF){
	var oFn=e[m].toString().split("");
	for(var fn=false;!fn;){var c=oFn.shift();if(c==")"){fn=true;}}
	e[m+"2"]=oFn.join("");e[m]=nF;
}

function h2RGB(col, asOBJ) {
	if(col.length>6){col=col.substring(1,7);}else if(col.length==3){col="#"+col;}
	if(col.length==4){col=col.substring(1,col.length).split("");
	col=""+col[0]+col[0]+col[1]+col[1]+col[2]+col[2];}
	var c=[parseInt(col.substring(0,2),16),
	parseInt(col.substring(2,4),16),
	parseInt(col.substring(4,6),16)];
	if(asOBJ){c={r:c[0], g:c[1], b:c[2]};}
	return c;
};for(var i=0;i<ignoreColors.length;i++){sets.iggyCols.push(h2RGB(ignoreColors[i],true));}

function startColor(index){
	var col=eval("document."+sets.cs[sets.brow][0]+index+sets.cs[sets.brow][1]);
	if(col.toLowerCase().indexOf("rgb") != -1){
		col=col.substring(4,col.length-1).split(",");
		col={r:parseInt(col[0]),g:parseInt(col[1]),b:parseInt(col[2])};}
	else{col=h2RGB(col,true);}
	return col;
}
 
function processColor(col){
	var dir={r:col.r>sets.fCol.r ? "-" : "+",
				g:col.g>sets.fCol.g ? "-" : "+",
				b:col.b>sets.fCol.b ? "-" : "+"},tP=[col],colInc={r:0,g:0,b:0},pInd,tmp;
	for(var d={r:0,g:0,b:0};3>((d.r+d.g)+d.b);){
		tmp={r:eval(tP[tP.length-1].r+dir.r+fadeBy),
		g:eval(tP[tP.length-1].g+dir.g+fadeBy),b:eval(tP[tP.length-1].b+dir.b+fadeBy)};
		if((dir.r=="-")&&(tmp.r<=sets.fCol.r)){tmp.r=sets.fCol.r;d.r=1;}
		else if((dir.r=="+")&&(tmp.r>=sets.fCol.r)){tmp.r=sets.fCol.r;d.r=1;}
		if((dir.g=="-")&&(tmp.g<=sets.fCol.g)){tmp.g=sets.fCol.g;d.g=1;}
		else if((dir.g=="+")&&(tmp.g>=sets.fCol.g)){tmp.g=sets.fCol.g;d.g=1;}
		if((dir.b=="-")&&(tmp.b<=sets.fCol.b)){tmp.b=sets.fCol.b;d.b=1;}
		else if((dir.b=="+")&&(tmp.b>=sets.fCol.b)){tmp.b=sets.fCol.b;d.b=1;}
		tP.push(tmp);
	};tP.push(sets.fCol);sets.colorList.push(tP);
}

function fadeCycle(tID,m,c){
	var tL=document.links[tID];
	if(tL.sN<0){tL.sN=0;}
	var cN=sets.colorList[tL.cID][tL.sN];
	tL.style.color="RGB("+cN.r+","+cN.g+","+cN.b+")";
	eval("tL.sN"+m);
	if(tL.sN==eval(c)){clearInterval(tL.cInt);}
}

function fadeIn(){
	if(this.cInt){clearInterval(this.cInt);}
	this.cInt=setInterval('fadeCycle('+this.lID+',"++","sets.colorList[tL.cID].length-1")',speed);
	eval(this.onmouseover2);
}

function fadeOut(){
	if(this.cInt){clearInterval(this.cInt);}
	this.cInt=setInterval('fadeCycle('+this.lID+',"--",0)',speed);
	eval(this.onmouseout2);
}

function linkFadeInit(){
	eval(window.onload2);
	var ig={cls:false,col:false},cCol,i,j,dLN;
	for(i=0;i<document.links.length;i++){
	dLN=document.links[i];ig.cls=ig.col=false;
		for(j=0;j<ignoreClasses.length;j++){if(dLN.className == ignoreClasses[j]){ig.cls=true;}}
		if(!ig.cls){cCol=startColor(i);
			for(j=0;j<sets.iggyCols.length;j++){
			if((cCol.r==sets.iggyCols[j].r)
			&&(cCol.g==sets.iggyCols[j].g)
			&&(cCol.b==sets.iggyCols[j].b)){ig.col=true;}}
			if(!ig.col){dLN.lID=i;dLN.sN=0;dLN.cInt=false;dLN.cID= -1;
				for(j=0;j<sets.colorList.length;j++){
				if((cCol.r==sets.colorList[j][0].r)
				&&(cCol.g==sets.colorList[j][0].g)
				&&(cCol.b==sets.colorList[j][0].b)){
				dLN.cID=j;j=sets.colorList.length;}}
				if(dLN.cID<0){dLN.cID=sets.colorList.length;processColor(cCol);}
				if(!dLN.onmouseover){dLN.onmouseover=fadeIn;dLN.onmouseover2=false;}
				else{overLoad(dLN,"onmouseover",fadeIn);}
				if(!dLN.onmouseout){dLN.onmouseout=fadeOut;dLN.onmouseout2=false;}
				else{overLoad(dLN,"onmouseout",fadeOut);}
			}
		}
	}
}

if(sets.brow<3){
	if(!window.onload){window.onload = linkFadeInit;window.onload2=false;}
	else{overLoad(window, "onload", linkFadeInit);}
}

