//
// The Links Effect .. :)
//

var rate = 2;		// fade amount
var Delay = 10;		// speed of fade 

if (document.getElementById)
window.onerror=new Function("return true")

var objActive;		// The object which event occured in
var act = 0;		// active
var word = 0;		// 2 bytes
var dir  = 1;		// direction of fade
var blueVal = 120;	// blue value
var clrOrg;			// The original link color 
var TimerID;		// Timer ID
var fsOld;			// Old font size ..
var Moz = 0;		// 1 If Mozilla / FireFox ..
var sHint = "..";	// Info text shown in status for IE ..

if (document.all) {
    document.onmouseover = doFadeLink;
    document.onmouseout = stopFadeLink;
	document.onmousemove = doFadeLink;
}
else if (document.getElementById) {
    document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT | Event.MOUSEMOVE | Event.FOCUS);
    document.onmouseover = Mozilla_doFadeLink;
    document.onmouseout = Mozilla_stopFadeLink;
	document.onmousemove = Mozilla_doFadeLink;
}


//=============================================================================

function doFadeLink()
{
    if (act == 0) {
        var obj = event.srcElement;
        while (obj.nodeName != 'A' && obj.nodeName != 'BODY') {
            obj = obj.parentElement;
            if (obj.nodeName == 'A' || obj.nodeName == 'BODY')
                break;
        }

        if (obj.nodeName == 'A' && obj.href != '') {
            objActive = obj;
            act = 1;
            clrOrg = objActive.style.color;
			fsOld = objActive.style.fontSize;
			// Take the text from Title for the MouseOver hint ..
			sHint = objActive.title;
			// clear Title value while active to avoid lag when tips appear ..
			objActive.title = "";
            TimerID = setInterval("ChangeColor()",Delay);
        }
    }
}


//=============================================================================

function stopFadeLink()
{
    if (act) {
        if (objActive.tagName == 'A') {
            objActive.style.color = clrOrg;
            clearInterval(TimerID);
			objActive.style.fontSize = fsOld;
			objActive.title = sHint;
            act = 0;
            dir = 1;
            blueVal = 120;
			window.status = " ";
        }
    }
}


//=============================================================================

function Mozilla_doFadeLink(e)
{
    if (act == 0) {
        obj = e.target;
        while (obj.nodeName != 'A' && obj.nodeName != 'BODY') {
            obj = obj.parentNode;
            if (obj.nodeName == 'A' || obj.nodeName == 'BODY')
                break;
        }

        if (obj.nodeName == 'A' && obj.href != '') {
            objActive = obj;
            act = 1;
			rate = 3;
			delay = 10;
			Moz = 1;
            clrOrg = obj.style.color;
			fsOld = obj.style.fontSize;
			TimerID = setInterval("ChangeColor()",Delay);
        }
    }
}


//=============================================================================

function Mozilla_stopFadeLink(e)
{
    if (act) {
        if (objActive.nodeName == 'A') {
            objActive.style.color = clrOrg;
            clearInterval(TimerID);
 			objActive.style.fontSize = fsOld;
            act = 0;
            dir = 1;
            blueVal = 120;
        }
    }
}


//=============================================================================

function ChangeColor()
{
	var s = "";
	// If the parent is a div then it's probably an anchor we want to change ..
	if (objActive.parentNode.nodeName == 'DIV') { 
		// Get 2 chars of blue value ..
    	word = Math.floor(blueVal).toString(16);
    	if (word.length == 1)    word = "0" + word;

		// Fade the colour ..
    	if (dir == 1) {
			// If fading up ..
			if (blueVal+rate >= 220) {
	    		blueVal = 220;
        		dir = 0;
			} else {
				blueVal = blueVal + rate;
			}
		} else {
			var a=120;
			// Bit smaller for dodgy FireFox mesurements ..
			if (Moz) a-=10;
			
			// If fading down ..
			if (blueVal-rate <= a) {
	    		blueVal = a;
	    		dir = 1;
        	} else {
				blueVal = blueVal - rate;
			}
		}

		// Set the new colour ..
		objActive.style.color = '#0000' + word;

		var a = blueVal;
		if (a > 220) a = 220;

		// Set the font size ..
		s = 12 + (a / 10);
		objActive.style.fontSize = s + "px"

		// If FireFox then we can't use status bar anyway, so don't even try ..
		if (Moz == 0) { 
			if (window.status != sHint) window.status = sHint;
		}
	} 
}


//=============================================================================

