/* obj.js
 * $Id: orb.js 46 2004-05-07 17:16:30Z davel $
 * (c) Dave Lambley 2004
 * <webmaster@davel.me.uk>
 * http://www.davel.me.uk/
 *
 * "I am the master of the Universe!" -- Hawkwind
 * "I am the master of JavaScript!" -- Davel
 *
 * Slightly convoluted to cope with Opera.
 *
 */

var arr = 0.05;
var gee = 0.00;
var bee = 1.00;

var fadeDelay = 50;
var fadeAmount = 0.85;

function doFade(o) {
	if (o.fading) {
		// Humans see logarithmically. Dunno what my screen does though.
		o.intensity = o.intensity * fadeAmount;
		
		var r = Math.round(arr * o.intensity * 255).toString(16);
		var g = Math.round(gee * o.intensity * 255).toString(16);
		var b = Math.round(bee * o.intensity * 255).toString(16);
		
		if ((r+g+b)==0) fading = false;
		                                                                                                                             
		if (r.length == 1) r = "0" + r;
		if (g.length == 1) g = "0" + g;
		if (b.length == 1) b = "0" + b;

		o.style.backgroundColor = "#"+r+g+b;
	} else {
		window.clearInterval(o.timerID);
	}
}

function inHandler(e) {
	var o;
	if (window.event) o=window.event.srcElement; else o = e.target;
	
	if (!o) return;
	if (o.tagName == "a" || o.tagName == "A") {
		if (o.timerID) window.clearInterval(o.timerID);
		o.fading = false;		
		o.style.backgroundColor = "#0c00ff";
	}
}

function outHandler(e) {
	var o;
	if (window.event) o=window.event.fromElement; else o = e.target;	
	
	if (!o) return;
	if (o.tagName == "a" || o.tagName == "A") {
		if (is_ie4 || is_ie5) {
			o.style.backgroundColor = "#000000";
		} else {
			o.intensity = 1;
			o.fading = true;
			o.timerID = window.setInterval(function () { doFade(o); }, fadeDelay);
		}
	}
}

if (document.addEventListener) {
	document.addEventListener("mouseover", inHandler, true);
	document.addEventListener("mouseout", outHandler, true);
} else if (document.attachEvent) {
	document.attachEvent("onmouseover", inHandler);
	document.attachEvent("onmouseout", outHandler);
}
