//window.onerror			= null;

// hack-o-mat tooltip-class-begrenzung, Lars Tewes <javascript@transfer-failed.com>

d						= document
ttDivClassNameArr		= ['mytitle', 'weitererClassName']

function ttOnlySelectedDivs() {
	var aNodesArr = [], currDivNodeArr;
	// executed only if Browsers is not IE (!window.external)
	if (!window.external) {
		for (var n=0, nL=ttDivClassNameArr.length; n < nL; n++) {
			currDivNodeArr = dgEBCN(ttDivClassNameArr[n])
			for(var nA=0, nAL=currDivNodeArr.length; nA < nAL; nA++) {
				newAArr = currDivNodeArr[nA].getElementsByTagName('*');
				for(var aA=0, aAL=newAArr.length; aA < aAL; aA++)
					aNodesArr[aNodesArr.length] = newAArr[aA]
			}
		}
	}
	tooltip.d(aNodesArr)
}

function dgEBI(what) {
	return d.getElementById(what);
}

function dgEBTN(what) {
	return d.getElementsByTagName(what);
}

function dgEBCN(searchedClassName, searchOnlyIn) { // document.getElementsByClassName
	var resArr	= [], testStr;
	var cN		= searchOnlyIn && dgEBI(searchOnlyIn).getElementsByTagName('*') || dgEBTN('*')
	for (var i=0, j=cN.length; i<j; i++) {
		if (cN[i].className.indexOf(searchedClassName) != -1) {
			var testStr = ',' + cN[i].className.split(' ').join(',') + ',';
			if (testStr.indexOf(',' + searchedClassName + ',') != -1)
				resArr.push(cN[i]);
		}
	}
	return resArr
}

// push for IE5 [quirksmode.org]

function Array_push() {
	var Ap = 0
	for (Ap = 0; Ap < arguments.length; Ap++) {
		this[this.length] = arguments[Ap]
	}
	return this.length
}

if (typeof Array.prototype.push == "undefined") {
	Array.prototype.push = Array_push
}

/*
originally written by paul sowden <paul@idontsmoke.co.uk> | http://idontsmoke.co.uk
modified and localized by alexander shurkayev <alshur@narod.ru> | http://htmlcoder.visions.ru
*/

tooltip = {

	attr_name: "tooltip",			// Kennzechnung des Tooltips
	blank_text: "Externer Link: ", 	// Text für aufruf in neuer Seite target="_blank"
	newline_entity: "  ", 			// den Sinn habe ich noch nicht verstanden
	max_width: 0,  				// maximale Breite des Tooltips (0=keine Begrenzung)
	delay: 70, 					// Verzögerung bis zur Anzeige

	t: document.createElement("DIV"),
	c: null,
	g: false,

	m: function(e){
		if (tooltip.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;
			tooltip.a(x, y);
		}
	},

	d: function(a){

		tooltip.t.setAttribute("id", "tooltip");
		document.body.appendChild(tooltip.t);

		for (var i = 0; i < a.length; i++){
			if (!a[i]) continue;
			tooltip_title = a[i].getAttribute("title");
			tooltip_alt = a[i].getAttribute("alt");
			tooltip_blank = a[i].getAttribute("target") && a[i].getAttribute("target") == "_blank" && tooltip.blank_text;
			if (tooltip_title || tooltip_blank){
// executed only if Browsers is not IE (!window.external)
				a[i].setAttribute(tooltip.attr_name, tooltip_blank ? (tooltip_title ? tooltip.blank_text + " " + tooltip_title : tooltip.blank_text) : tooltip_title);

				if (a[i].getAttribute(tooltip.attr_name)){
					a[i].removeAttribute("title");
					if (tooltip_alt && a[i].complete) a[i].removeAttribute("alt");
					tooltip.l(a[i], "mouseover", tooltip.s);
					tooltip.l(a[i], "mouseout", tooltip.h);
				}
			}else if (tooltip_alt && a[i].complete){
				a[i].setAttribute(tooltip.attr_name, tooltip_alt);
				if (a[i].getAttribute(tooltip.attr_name)){
					a[i].removeAttribute("alt");
					tooltip.l(a[i], "mouseover", tooltip.s);
					tooltip.l(a[i], "mouseout", tooltip.h);
				}
			}
			if (!a[i].getAttribute(tooltip.attr_name) && tooltip_blank){
			}
		}

	document.onmousemove = tooltip.m;
	window.onscroll = tooltip.h;
	tooltip.a(-99, -99);
	},

	s: function(e){
		d = window.event ? window.event.srcElement : e.target;
		if (!d.getAttribute(tooltip.attr_name)) return;
		s = d.getAttribute(tooltip.attr_name);
		if (tooltip.newline_entity){
			s = s.replace(/\&/g,"&amp;");
			s = s.replace(/\</g,"&lt;");
			s = s.replace(/\>/g,"&gt;");
			s = s.replace(eval("/" + tooltip.newline_entity + "/g"), "<br />");
			tooltip.t.innerHTML = s;
		}else{
			if (tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
			tooltip.t.appendChild(document.createTextNode(s));
			//tooltip.t.innerText = s;
		}
		tooltip.c = setTimeout("tooltip.t.style.visibility = 'visible';", tooltip.delay);
		tooltip.g = true;
	},

	h: function(e){
		tooltip.t.style.visibility = "hidden";
		if (!tooltip.newline_entity && tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
		clearTimeout(tooltip.c);
		tooltip.g = false;
		tooltip.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!
		tooltip.t.style.width = ((tooltip.max_width) && (tooltip.t.offsetWidth > tooltip.max_width)) ? tooltip.max_width + "px" : "auto";
		t_width = tooltip.t.offsetWidth;
		t_height = tooltip.t.offsetHeight;
		tooltip.t.style.left = x + 8 + "px";
		tooltip.t.style.top = y + 8 + "px";
		if (x + t_width > w_width) tooltip.t.style.left = w_width - t_width + "px";
		if (y + t_height > w_height) tooltip.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", ttOnlySelectedDivs, false);
	else if (root.attachEvent) root.attachEvent("onload", ttOnlySelectedDivs);
}

