/************************************************************************************************************
(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

Note by DFF: I modified this to take the actual tooltip text from an array, to avoid embedding all those
big chunks of text within the link anchors.... It's much easier to update now, of course.

************************************************************************************************************/	
var dhtmlgoodies_tooltip = false;
var dhtmlgoodies_tooltipShadow = false;
var dhtmlgoodies_shadowSize = 4;
var dhtmlgoodies_tooltipMaxWidth = 200;
var dhtmlgoodies_tooltipMinWidth = 100;
var dhtmlgoodies_iframe = false;
var tooltip_is_msie = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('opera')==-1 && document.all)?true:false;

var tooltip_text = new Array(
							 'Dummy text for position zero....',
							 'This page describes our Business Card products.',
							 'This page describes our Letterhead &amp; Stationery products.',
							 'This page describes our Envelopes products.',
							 'This page describes our Wine &amp; Product Labels products.',
							 'This page describes our Presentation Folders products.',
							 'This page describes our Forms products.',
							 'This page describes our Brochures &amp; Flyers products.',
							 'This page describes our Newsletter products.',
							 'This page describes our Posters &amp; Art Print products.',
							 'This page describes our Books &amp; Catalogs products.',
							 'This page describes our Postcard &amp; Rack Card products.',
							 'This page describes our Notecards products.',
							 'This page talks about using Special Sizes &amp; Papers.',
							 'Need Something Else? If you haven&rsquo;t found what you need, we can help design what you want!',
							 'This page describes our Copy &amp; Fax Services.',
							 'This page describes our Scanning Services.',
							 'This page describes our Creative Design services.',
							 'This page describes our Bindery Services.',
							 /* top nav items */
							 'Welcome to the Mendo Litho Home Page.',
							 'Get a Quote on a Copier or Print Job.',
							 'Be awed by the pieces of equipment that Phil has gathered!',
							 'Read about Phil and Grace Sharples, founders of Mendo Litho.',
							 'Contact info for Mendo Litho.',
							 'This page describes the other products and services that we offer.'
							 ); 


function showTooltip(e,index)
{
	
	var tooltipTxt = tooltip_text[index];
	var bodyWidth = Math.max(document.body.clientWidth,document.documentElement.clientWidth) - 20;

	if (!dhtmlgoodies_tooltip)
	{
		dhtmlgoodies_tooltip = document.createElement('DIV');
		dhtmlgoodies_tooltip.id = 'dhtmlgoodies_tooltip';
		dhtmlgoodies_tooltipShadow = document.createElement('DIV');
		dhtmlgoodies_tooltipShadow.id = 'dhtmlgoodies_tooltipShadow';
		
		document.body.appendChild(dhtmlgoodies_tooltip);
		document.body.appendChild(dhtmlgoodies_tooltipShadow);	
		
		if (tooltip_is_msie)
		{
			dhtmlgoodies_iframe = document.createElement('IFRAME');
			dhtmlgoodies_iframe.frameborder='5';
			dhtmlgoodies_iframe.style.backgroundColor='#FFFFFF';
			dhtmlgoodies_iframe.src = '#'; 	
			dhtmlgoodies_iframe.style.zIndex = 100;
			dhtmlgoodies_iframe.style.position = 'absolute';
			document.body.appendChild(dhtmlgoodies_iframe);
		}
	}
	
	dhtmlgoodies_tooltip.style.display='block';
	dhtmlgoodies_tooltipShadow.style.display='block';
	if (tooltip_is_msie) dhtmlgoodies_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;
	
	dhtmlgoodies_tooltip.style.width = null;	// Reset style width if it's set 
	dhtmlgoodies_tooltip.innerHTML = tooltipTxt;
	dhtmlgoodies_tooltip.style.left = leftPos + 'px';
	dhtmlgoodies_tooltip.style.top = e.clientY + 10 + st + 'px';

	
	dhtmlgoodies_tooltipShadow.style.left =  leftPos + dhtmlgoodies_shadowSize + 'px';
	dhtmlgoodies_tooltipShadow.style.top = e.clientY + 10 + st + dhtmlgoodies_shadowSize + 'px';
	
	if (dhtmlgoodies_tooltip.offsetWidth>dhtmlgoodies_tooltipMaxWidth) 
	{	/* Exceeding max width of tooltip ? */
		dhtmlgoodies_tooltip.style.width = dhtmlgoodies_tooltipMaxWidth + 'px';
	}
	
	var tooltipWidth = dhtmlgoodies_tooltip.offsetWidth;		
	if (tooltipWidth<dhtmlgoodies_tooltipMinWidth) tooltipWidth = dhtmlgoodies_tooltipMinWidth;
	
	
	dhtmlgoodies_tooltip.style.width = tooltipWidth + 'px';
	dhtmlgoodies_tooltipShadow.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
	dhtmlgoodies_tooltipShadow.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';		
	
	if ((leftPos + tooltipWidth)>bodyWidth)
	{
		dhtmlgoodies_tooltip.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - 
																((leftPos + tooltipWidth)-bodyWidth)) + 'px';
		dhtmlgoodies_tooltipShadow.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - 
																			((leftPos + tooltipWidth)-bodyWidth) + dhtmlgoodies_shadowSize) + 'px';
	}
	
	if (tooltip_is_msie)
	{
		dhtmlgoodies_iframe.style.left = dhtmlgoodies_tooltip.style.left;
		dhtmlgoodies_iframe.style.top = dhtmlgoodies_tooltip.style.top;
		dhtmlgoodies_iframe.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
		dhtmlgoodies_iframe.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';
	}
}

function hideTooltip()
{
	dhtmlgoodies_tooltip.style.display='none';
	dhtmlgoodies_tooltipShadow.style.display='none';		
	if (tooltip_is_msie) dhtmlgoodies_iframe.style.display='none';		
}
	
