//CrossTooltips v1.0
/*
Made by Steve Cobbaert
This script is FREEWARE, thank me by email: ikjop@yahoo.com
DO NOT CHANGE THE CODE BELLOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING...
*/
var ttCounter = 0;
if (navigator.appName == "Microsoft Internet Explorer") var ie = true;  //ie

function htmlOverlopen(domStart){
	var htmlElements = domStart.childNodes;
	for(var i = 0; i < htmlElements.length; i++){
	
		if(htmlElements[i].childNodes.length > 0){
			if(htmlElements[i].getAttribute("dir")) {
				checkTag(htmlElements[i]);
			}
			htmlOverlopen(htmlElements[i]);
		}  // einde if
		
	} // einde for
	
} // einde function

function checkTag(htmlTag){
	var dirTag = htmlTag.getAttribute("dir");
	if(dirTag.substr(0,8) == "tooltip:"){
		tagValue = htmlTag.getAttribute("dir").substr(8,htmlTag.getAttribute("dir").length);
		var arrTooltip = tagValue.split(";");
		var title = arrTooltip[0];
		var message = arrTooltip[1];
		var width = arrTooltip[2];
		var border = arrTooltip[3];
		var trans = arrTooltip[4];
		var delay = arrTooltip[5];
		createTooltip(htmlTag, title, message, width, border, trans, delay);
	}
	
}

function createTooltip(htmltag, title, message, width, border, trans, delay){
	ttCounter++;
	if(delay < 100) delay = 100;
	if(width == "")	width = 100;
	
	
	var ttDiv = document.createElement("div");
	var ttDivId = document.createAttribute("id");
	ttDivId.value = "tooltip" + ttCounter;
	ttDiv.setAttributeNode(ttDivId);

	var ttDivWidth = document.createAttribute("width");
	
	
	ttDivWidth.value = width;
	ttDiv.setAttributeNode(ttDivWidth);

	var ttTable = document.createElement("table");
	var ttTbody = document.createElement("tbody");
	
	if(title != ""){
		var ttTr = document.createElement("tr");
		var ttTd = document.createElement("td");
	}
	
	if(message != ""){
		var ttTr2 = document.createElement("tr");
		var ttTd2 = document.createElement("td");
	}
	
	ttDiv.appendChild(ttTable);
	ttTable.appendChild(ttTbody);

	ttTableWidth = document.createAttribute("width");
	ttTableWidth.value = width;
	ttTable.setAttributeNode(ttTableWidth);
	
	ttTableHeight= document.createAttribute("height");
	ttTableHeight.value = "10";
	ttTable.setAttributeNode(ttTableHeight);
	
	ttTable.style.backgroundColor = "#F2F5F9";			// TOOLTIP BGCOLOR
	ttTable.style.border = "solid";
	ttTable.style.borderWidth = border+"px";
	ttTable.style.borderColor = "#C7D6DC";
	
	if(ie){
		ttTable.style.filter = "alpha(opacity:"+trans+")";
	} else {
		ttTable.style.opacity = (trans/100);
	}
	if(title != ""){
	ttTbody.appendChild(ttTr);
	ttTr.appendChild(ttTd);
	ttTd.style.fontFamily = "verdana";		// TOOLTIP TITLE STYLE!!!!
	ttTd.style.fontSize = 10 + "px";
	ttTd.style.fontWeight = "bold";
	ttTd.style.color = "#2B3960";
	ttTd.innerHTML = title;
	}
	
	if(message != ""){
		ttTbody.appendChild(ttTr2);
		ttTr2.appendChild(ttTd2);
		ttTd2.style.fontFamily = "verdana";		// TOOLTIP BODY STYLE!
		ttTd2.style.fontSize = 9 + "px";
		ttTd2.style.color = "#496876";
		ttTd2.innerHTML = message;
	}
	
	document.body.appendChild(ttDiv);
	
	ttDiv.style.position = "absolute";
	ttDiv.style.display = "none";
	
	htmltag.onmouseover = function eventhandler(){ eval("over"+ttDiv.id+" = 1"); setTimeout("showDiv('" + ttDiv.id + "')",delay) };
	htmltag.onmouseout = function eventhandler2(){ eval("over"+ttDiv.id+" = 0"); setTimeout("hideDiv('" + ttDiv.id + "')",1) };
	htmltag.onmousemove = function eventhandler3(e){ followMouse(e,ttDiv,20); };
}

function showDiv(divObject){
	if (eval("over"+divObject) == 1){
	divObject = document.getElementById(divObject);
	divObject.style.display = "block";
	}
}

function hideDiv(divObject){
	divObject = document.getElementById(divObject);
	divObject.style.display = "none";
}

function followMouse(e, divObject, space){
	if (ie) {  //ie
		tempX = event.clientX + document.body.scrollLeft;
		tempY = (event.clientY + space) + document.documentElement.scrollTop;
	}
	else {  // firefox
		tempX = e.pageX + "px";
		tempY = (e.pageY + space) + "px";
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  
	
	divObject.style.left = tempX;
	divObject.style.top = tempY;
}

//document.body.onload = function bodyloadEvent(){ htmlOverlopen(document.documentElement,0); };
