/**
 * Class Tooltip handles the Tooltip over the Productsmenu
 * For example:
 * toolTip = new Tooltip("productsmenu","tooltip");
 *
 * @author  Dirk Ginader für Bartenbach & Co. Agentur für Kommunikation GmbH & Co. KG [www.bartenbach.de]
 * @version 1.1
 * @param activeAreaID      the ID of the Element to trigger the onmousemove events
 * @param targetID        	the ID of the Container (normally a <div>) to represent the ToolTip
 * 
 * Version History
 * * 1.0 Initial Version
 * * 1.1 Fixed Issue of IE6 in Standartsmode (document.documentElement.scrollTop instead of document.body.scrollTop)
 */
Tooltip =  function(activeAreaID,targetID){
	this.activeAreaID = activeAreaID;
	this.activeAreaObj = document.getElementById(activeAreaID);
	this.targetID = targetID;
	this.targetObj = document.getElementById(targetID);
	this.mouseX = 0;
	this.mouseY = 0;
	this.init();
}
o = Tooltip.prototype;
o.init = function(){
	this.activeAreaObj.tooltipInstance = this;
	this.activeAreaObj.onmousemove = function(e){
		posx=0; posy=0;
		if (!e) e=window.event;
		if (e.pageX && e.pageY) {
			posx=e.pageX;
			posy=e.pageY;
		}else if (e.clientX && e.clientY){
			if (document.compatMode && document.compatMode=="CSS1Compat") {
				posx=e.clientX + document.documentElement.scrollLeft;
				posy=e.clientY + document.documentElement.scrollTop;
			} else {
				posx=e.clientX + document.body.scrollLeft;
				posy=e.clientY + document.body.scrollTop;
			}
		}
		this.tooltipInstance.setMousePosition(posx,posy);
	}
}
o.applyToObj = function(obj){
	if(obj.title){
		obj.tooltip = this;
		obj.tooltiptext = obj.title;
		obj.title = "";
		obj.onmouseover = function(){
			this.tooltip.show(this.tooltiptext);
		}
		obj.onmouseout = function(){
			this.tooltip.hide();
		}
	}
}
o.show = function(txt){
	this.targetObj.innerHTML = this.convertLineBreaks(txt);
	this.targetObj.style.display = "block";
}
o.hide = function(){
	this.targetObj.innerHTML = "&nbsp;";
	this.targetObj.style.display = "none";
}
o.convertLineBreaks = function(txt){
	var tmp = txt.split("|");
	tmp = tmp.join("<br />");
	return tmp;
}
o.setMousePosition = function(x,y){
	this.mouseX = x;
	this.mouseY = y;
	this.refreshTooltipPosition();
}
o.refreshTooltipPosition = function(){
	this.targetObj.style.top = this.mouseY+10+"px";
	this.targetObj.style.left = this.mouseX+10+"px";
}
