/************************************************************************************************************ (C) www.dhtml.com, October 2005 This is a script from www.dhtml.com. You will find this and a lot of other scripts at our website. Updated: March, 11th, 2006 - Fixed positioning of tooltip when displayed near the right edge of the browser. April, 6th 2006, Using iframe in IE in order to make the tooltip cover select boxes. Terms of use: You are free to use this script as long as the copyright message is kept intact. However, you may not redistribute, sell or repost it without our permission. Thank you! www.dhtml.com Alf Magne Kalleland ************************************************************************************************************/ var dhtml_tooltip = false; var dhtml_tooltipShadow = false; var dhtml_shadowSize = 4; var dhtml_tooltipMaxWidth = 200; var dhtml_tooltipMinWidth = 100; var dhtml_iframe = false; var tooltip_is_msie = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('opera')==-1 && document.all)?true:false; function showTooltip(e,tooltipTxt) { var bodyWidth = Math.max(document.body.clientWidth,document.documentElement.clientWidth) - 20; if(!dhtml_tooltip){ dhtml_tooltip = document.createElement('DIV'); dhtml_tooltip.id = 'dhtml_tooltip'; dhtml_tooltipShadow = document.createElement('DIV'); dhtml_tooltipShadow.id = 'dhtml_tooltipShadow'; document.body.appendChild(dhtml_tooltip); document.body.appendChild(dhtml_tooltipShadow); if(tooltip_is_msie){ dhtml_iframe = document.createElement('IFRAME'); dhtml_iframe.frameborder='5'; dhtml_iframe.style.backgroundColor='#FFFFFF'; dhtml_iframe.src = '#'; dhtml_iframe.style.zIndex = 100; dhtml_iframe.style.position = 'absolute'; document.body.appendChild(dhtml_iframe); } } dhtml_tooltip.style.display='block'; dhtml_tooltipShadow.style.display='block'; if(tooltip_is_msie)dhtml_iframe.style.display='block'; var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop); if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; var leftPos = e.clientX; dhtml_tooltip.style.width = null; // Reset style width if it's set dhtml_tooltip.innerHTML = tooltipTxt; dhtml_tooltip.style.left = leftPos + 'px'; dhtml_tooltip.style.top = e.clientY + 10 + st + 'px'; dhtml_tooltipShadow.style.left = leftPos + dhtml_shadowSize + 'px'; dhtml_tooltipShadow.style.top = e.clientY + 10 + st + dhtml_shadowSize + 'px'; if(dhtml_tooltip.offsetWidth>dhtml_tooltipMaxWidth){ /* Exceeding max width of tooltip ? */ dhtml_tooltip.style.width = dhtml_tooltipMaxWidth + 'px'; } var tooltipWidth = dhtml_tooltip.offsetWidth; if(tooltipWidthbodyWidth){ dhtml_tooltip.style.left = (dhtml_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth)) + 'px'; dhtml_tooltipShadow.style.left = (dhtml_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth) + dhtml_shadowSize) + 'px'; } if(tooltip_is_msie){ dhtml_iframe.style.left = dhtml_tooltip.style.left; dhtml_iframe.style.top = dhtml_tooltip.style.top; dhtml_iframe.style.width = dhtml_tooltip.offsetWidth + 'px'; dhtml_iframe.style.height = dhtml_tooltip.offsetHeight + 'px'; } } function hideTooltip() { dhtml_tooltip.style.display='none'; dhtml_tooltipShadow.style.display='none'; if(tooltip_is_msie)dhtml_iframe.style.display='none'; }