	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005

	This is a script from www.dhtmlgoodies.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.dhtmlgoodies.com
	Alf Magne Kalleland

	************************************************************************************************************/
	var dg_tooltip = false;
	var dg_tooltipShadow = false;
	var dg_shadowSize = 4;
	var dg_tooltipMaxWidth = 200;
	var dg_tooltipMinWidth = 100;
	var dg_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(!dg_tooltip){
			dg_tooltip = document.createElement('DIV');
			dg_tooltip.id = 'dg_tooltip';
			dg_tooltipShadow = document.createElement('DIV');
			dg_tooltipShadow.id = 'dg_tooltipShadow';

			document.body.appendChild(dg_tooltip);
			document.body.appendChild(dg_tooltipShadow);

			if(tooltip_is_msie){
				dg_iframe = document.createElement('IFRAME');
				dg_iframe.frameborder='5';
				dg_iframe.style.backgroundColor='#FFFFFF';
				dg_iframe.src = '#';
				dg_iframe.style.zIndex = 100;
				dg_iframe.style.position = 'absolute';
				document.body.appendChild(dg_iframe);
			}

		}

		dg_tooltip.style.display='block';
		dg_tooltipShadow.style.display='block';
		if(tooltip_is_msie)dg_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 + 10;

		dg_tooltip.style.width = null;	// Reset style width if it's set
		dg_tooltip.innerHTML = tooltipTxt;
		dg_tooltip.style.left = leftPos + 'px';
		dg_tooltip.style.top = e.clientY + 10 + st + 'px';


		dg_tooltipShadow.style.left =  leftPos + dg_shadowSize + 'px';
		dg_tooltipShadow.style.top = e.clientY + 10 + st + dg_shadowSize + 'px';

		if(dg_tooltip.offsetWidth>dg_tooltipMaxWidth){	/* Exceeding max width of tooltip ? */
			dg_tooltip.style.width = dg_tooltipMaxWidth + 'px';
		}

		var tooltipWidth = dg_tooltip.offsetWidth;
		if(tooltipWidth<dg_tooltipMinWidth)tooltipWidth = dg_tooltipMinWidth;


		dg_tooltip.style.width = tooltipWidth + 'px';
		dg_tooltipShadow.style.width = dg_tooltip.offsetWidth + 'px';
		dg_tooltipShadow.style.height = dg_tooltip.offsetHeight + 'px';

		if((leftPos + tooltipWidth)>bodyWidth){
			dg_tooltip.style.left = (dg_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth)) + 'px';
			dg_tooltipShadow.style.left = (dg_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth) + dg_shadowSize) + 'px';
		}

		if(tooltip_is_msie){
			dg_iframe.style.left = dg_tooltip.style.left;
			dg_iframe.style.top = dg_tooltip.style.top;
			dg_iframe.style.width = dg_tooltip.offsetWidth + 'px';
			dg_iframe.style.height = dg_tooltip.offsetHeight + 'px';

		}

	}

	function hideTooltip()
	{
		dg_tooltip.style.display='none';
		dg_tooltipShadow.style.display='none';
		if(tooltip_is_msie)dg_iframe.style.display='none';
	}
