/** jsToolTip * * $Id: jstooltip.js,v 1.17 2001/12/07 22:55:07 rainwater Exp $ * * Copyright (c) 2001 Robert Rainwater * Distributed Under the Terms of the GNU Lesser General Public License *********************************************************** * * I make some changes in this source for adding RTL support and Caption * This changes optimized for this site and may cause some errors in your * site!!! * * Ali Amirnezhad * ali@webilix.com */ _ie = document.getElementById&&document.all; _mz = document.getElementById&&!_ie; jsToolTipHandler = { mousemove : function(e){ jsToolTip.x = e.clientX; jsToolTip.y = e.clientY; }, mouseover : function(e){ var fromEl = jsToolTip.getNode(e.relatedTarget||e.fromElement); var toEl = jsToolTip.getNode(e.target||e.toElement); if (!fromEl||!toEl) return; if (toEl.getAttribute("tooltip") && toEl!=fromEl) jsToolTip.showToolTip(toEl); }, mouseout : function(e){ var fromEl = jsToolTip.getNode(e.target||e.fromElement); var toEl = jsToolTip.getNode(e.relatedTarget||e.toElement); if (!fromEl||!toEl) return; if (fromEl.getAttribute("tooltip") && toEl!=fromEl) jsToolTip.hideToolTip(fromEl); } } jsToolTip = { getNode: function(obj) { if (!obj||_ie) return obj; while (obj.nodeType!=1) obj=obj.parentNode; return obj; }, showToolTip : function(src) { if (src._timeoutshow) return; if (src._timeoutfade) { window.clearTimeout(src._timeoutfade); src._timeoutfade=null; } if (!src._tip) { src._tip = document.createElement("DIV"); document.body.appendChild(src._tip); } src._cfg = jsToolTipConfig.all[src.getAttribute("tooltip").match(/\|.*\|/)||"|DefaultConfig|"]; src._tip.className = src._cfg.className; if (src.getAttribute("caption")) { src._tip.innerHTML = "
" + src.getAttribute("caption").replace(/\|.*\|/,'') + "
" + src.getAttribute("tooltip").replace(/\|.*\|/,'') + "
"; } else { src._tip.innerHTML = "
" + src.getAttribute("tooltip").replace(/\|.*\|/,'') + "
"; } jsToolTip._setOpacity(src._tip,0); var offsetX = window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft; var offsetY = window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop; showLeft = jsToolTip.x - (src._tip.offsetWidth / 2) + offsetX; if ((showLeft + src._tip.offsetWidth + 30) > screen.width) { showLeft = screen.width - src._tip.offsetWidth - 30; } if (showLeft < 10) { showLeft = 10; } src._tip.style.left = showLeft + "px"; src._tip.style.top = jsToolTip.y + 15 + offsetY + "px"; src._tip.style.visibility = "visible"; src._timeoutshow = window.setTimeout(function () { jsToolTip._showToolTip(src,1) }, src._cfg.showTimeout); src._timeoutfade = window.setTimeout(function () { jsToolTip._hideToolTip(src,1) }, 10000); }, _showToolTip : function(src,c) { if (c<=src._cfg.showSteps) { jsToolTip._setOpacity(src._tip,Math.ceil(src._cfg.opacity/src._cfg.showSteps)*c); src._timeoutshow = window.setTimeout(function () { jsToolTip._showToolTip(src,c+1) }, src._cfg.inTimeout); return; } src._timeoutshow = null; }, hideToolTip : function(src) { src._timeoutfade = window.setTimeout(function () { jsToolTip._hideToolTip(src,1) }, src._cfg.hideTimeout); }, _hideToolTip : function(s,c) { if (s._tip) { if (c<=s._cfg.fadeSteps) { jsToolTip._setOpacity(s._tip,s._cfg.opacity-(Math.floor(s._cfg.opacity/s._cfg.fadeSteps*c))); s._timeoutfade = window.setTimeout(function () { jsToolTip._hideToolTip(s,c+1) }, s._cfg.fadeTimeout); return; } s._tip.style.visibility = "hidden"; s._timeoutfade = null; } }, _setOpacity : function(s,o) { if (_ie) s.style.filter = "alpha(opacity="+o+")"; else s.style.MozOpacity = o/100; } } function jsToolTipConfig() { this.id = arguments[0]; this.hideTimeout = arguments[1]||0; this.fadeTimeout = arguments[2]||0; this.showTimeout = arguments[3]||0; this.inTimeout = arguments[4]||0; this.fadeSteps = arguments[5]||1; this.showSteps = arguments[6]||1; this.opacity = arguments[7]||100; this.className = arguments[8]||"cTooltip"; jsToolTipConfig.all["|"+this.id+"|"] = this; } jsToolTipConfig.all = []; _jsToolTipDefaultConfig = new jsToolTipConfig("DefaultConfig"); if (_ie) { document.attachEvent("onmousemove", jsToolTipHandler.mousemove); document.attachEvent("onmouseover", jsToolTipHandler.mouseover); document.attachEvent("onmouseout", jsToolTipHandler.mouseout); } else if (_mz) { document.addEventListener("mousemove", jsToolTipHandler.mousemove, false); document.addEventListener("mouseover", jsToolTipHandler.mouseover, false); document.addEventListener("mouseout", jsToolTipHandler.mouseout, false); } function WRD_HighlightWord(node, strWord, strCaption, strTooltip) { // Iterate into this nodes childNodes if (node.hasChildNodes) { var hi_cn; for (hi_cn=0;hi_cn 0) { WRD_HighlightWord(document.getElementsByTagName('body')[0], spWords[0][0], spWords[0][1], spWords[0][2]); spWords.splice(0, 1); window.setTimeout('WRD_SetData()', 10); } } window.setTimeout('WRD_SetData()', 2500);