window.onerror = null;

expl = {
	attr_name: "expl",
	newline_entity: "  ",
	max_width: 0,
	delay: 120, 
	
	t: document.createElement("DIV"),
	c: null,
	g: false,

	m: function(e){
		if (expl.g){
			oCanvas = document.getElementsByTagName(
			(document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY"
			)[0];
			x = window.event ? event.clientX + oCanvas.scrollLeft : e.pageX;
			y = window.event ? event.clientY + oCanvas.scrollTop : e.pageY;
			expl.a(x, y);
		}
	},

	d: function(){
		expl.t.setAttribute("id", "expl");
		//expl.t.style.filter = "alpha(opacity=85)"; // buggy in ie5.0
		document.body.appendChild(expl.t);
		a = document.all ? document.all : document.getElementsByTagName("*");
		aLength = a.length;
		for (var i = 0; i < aLength; i++){

			//if (a[i].tagName == "A" || a[i].tagName == "BUTTON" || (a[i].tagName == "INPUT" && (a[i].type == "submit" || a[i].type == "button" || a[i].type == "reset"))) a[i].onclick = self.focus;

			if (!a[i]) continue;

			expl_alt = a[i].getAttribute("who");
	if(expl_alt){
				a[i].setAttribute(expl.attr_name, expl_alt);
				if (a[i].getAttribute(expl.attr_name)){
					a[i].removeAttribute("alt");
					expl.l(a[i], "mouseover", expl.s);
					expl.l(a[i], "mouseout", expl.h);
				}
	}else{
						a[i].removeAttribute("alt");
	}
		}
		document.onmousemove = expl.m;
		window.onscroll = expl.h;
		expl.a(-99, -99);
	},

	s: function(e){
		d = window.event ? window.event.srcElement : e.target;
		if (!d.getAttribute(expl.attr_name)) return;
		s = d.getAttribute(expl.attr_name);
		if (expl.newline_entity){
			expl.t.innerHTML = s;
		}else{
			if (expl.t.firstChild) expl.t.removeChild(expl.t.firstChild);
			expl.t.innerHTML = s;
		}
		expl.c = setTimeout("expl.t.style.visibility = 'visible';", expl.delay);
		expl.g = true;
	},

	h: function(e){
		expl.t.style.visibility = "hidden";
		if (!expl.newline_entity && expl.t.firstChild) expl.t.removeChild(expl.t.firstChild);
		clearTimeout(expl.c);
		expl.g = false;
		expl.a(-99, -99);
	},

	l: function(o, e, a){
		if (o.addEventListener) o.addEventListener(e, a, false); // was true--Opera 7b workaround!
		else if (o.attachEvent) o.attachEvent("on" + e, a);
			else return null;
	},

	a: function(x, y){
		oCanvas = document.getElementsByTagName(
		(document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY"
		)[0];
		
		w_width = oCanvas.clientWidth ? oCanvas.clientWidth + oCanvas.scrollLeft : window.innerWidth + window.pageXOffset;
		w_height = window.innerHeight ? window.innerHeight + window.pageYOffset : oCanvas.clientHeight + oCanvas.scrollTop; // should be vice verca since Opera 7 is crazy!

		expl.t.style.width = ((expl.max_width) && (expl.t.offsetWidth > expl.max_width)) ? expl.max_width + "px" : "auto";
		
		t_width = expl.t.offsetWidth;
		t_height = expl.t.offsetHeight;

		expl.t.style.left = x + 1 + "px";
		expl.t.style.top = y - t_height + "px";
		
//		if (x + t_width > w_width) expl.t.style.left = w_width - t_width + "px";
//		if (y + t_height > w_height) expl.t.style.top = w_height - t_height + "px";
	}
}

var root = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null;
if (root){
	if (root.addEventListener) root.addEventListener("load", expl.d, false);
	else if (root.attachEvent) root.attachEvent("onload", expl.d);
}
