// @ SPW 2002 - All Rights Reserved
// You may not use this script or any part of it
// on any web site without
// proper license from SPW GmbH. 
// Email info@spw.info
// for purchase and licensing details.

// ******************************************************
// usage: 
// onmouseOver="ShowHelp('helptext',event.screenX,event.screenY);"
// onmouseout="HideHelp();"

var helpLoadingComplete;
var helpLayer;
var helpLayerObj;
var helpActivateTimeout;
var helpHideTimeout;
var helpShowAfter = 1000;
var helpHideAfter = 6000;
var	helpStandardTopModifier = 5;
var helpStandardLeftModifier = 5;
var helpTopModifier = helpStandardTopModifier;
var helpleftModifier = helpStandardLeftModifier;
var helpTopModifierBrowser = 0;
var helpleftModifierBrowser = 0;
var helpStandardHtolerance = 10;
var helpStandardVtolerance = 10;
var helpHtolerance = helpStandardHtolerance;
var helpVtolerance = helpStandardVtolerance;
var helpOldX = -500;
var helpOldY = -500;
var helpResetAfter = 200;
var helpResetTimeout;

if ((macOrWin == "Mac") && (browserName == "IE"))
{
	helpTopModifierBrowser = 7;
	helpleftModifierBrowser = 7;
}
else if ((macOrWin == "Mac") && (browserName == "Netscape6"))
{
	helpTopModifierBrowser = 5;
	helpleftModifierBrowser = 55;
}
else if ((macOrWin == "Win") && (browserName == "Netscape6"))
{
	helpTopModifierBrowser = 5;
	helpleftModifierBrowser = 55;
}
else
{
	helpTopModifierBrowser = 0;
	helpleftModifierBrowser = 0;
}

document.write ('<style type=\"text/css\">');
document.write ('#helpLayerStyle {');
document.write ('position: absolute;');
document.write ('left: 0;');
document.write ('top: 0;');
document.write ('width: 120;');
document.write ('height: 18;');
document.write ('visibility: hidden;');
document.write ('align: left;');
document.write ('z-Index: 200;');
document.write ('}');

document.write ('.helpFontStyle {font-size: 7pt;');
document.write ('font-family: Tahoma, Arial, sans-serif;');
document.write ('line-height: 8pt;');
document.write ('background-color : #EDFFFF;');
document.write ('border-width :1px;');
document.write ('border-style :solid;');
document.write ('border-color : #ED9999;');
document.write ('padding-left :3px;');
document.write ('padding-top :3px;');
document.write ('padding-right :3px;');
document.write ('padding-bottom :3px;');
document.write ('}');

document.write ('.helpFontStyleLarge {font-size: 7pt;');
document.write ('font-family: Tahoma, Arial, sans-serif;');
document.write ('line-height: 8pt;');
document.write ('background-color : #EEFFFF;');
document.write ('border-width :1px;');
document.write ('border-style :solid;');
document.write ('border-color : #ED9999;');
document.write ('padding-left :3px;');
document.write ('padding-top :3px;');
document.write ('padding-right :3px;');
document.write ('padding-bottom :3px;');
document.write ('}');
document.write ('</style>');
 
function InitSPWHelp()
{
	if (document.all)
	{
		helpLayer = helpLayerStyle.style;
		helpLayerObj = helpLayerStyle;
	}
	else if (document.getElementById)
	{
		helpLayer = document.getElementById('helpLayerStyle').style;
		helpLayerObj = document.getElementById('helpLayerStyle');
	}
	helpOldX = -500;
	helpOldY = -500;
	helpLoadingComplete = 1;

}

function ShowHelp(thehelptext,xcoord,ycoord)
{
	if ((!(document.layers)) && (helpLoadingComplete == 1))
	{
		var x;
		var y;
		if (document.all)
		{
		x= event.clientX;
		y= event.clientY;
		}
		else if (document.getElementById)
		{
		x= xcoord;
		y= ycoord;
		}
		/*
		var helpHtolerance = 0;
		var helpVtolerance = 0;
		var helpOldX = -500;
		var helpOldY = -500;
		*/
		
		var enoughVMovement = (Math.abs(y-helpOldY) > helpVtolerance) ? true : false;
		var enoughHMovement = (Math.abs(x-helpOldX) > helpHtolerance) ? true : false;
		if ((enoughVMovement)||(enoughHMovement))
		{
		clearTimeout(helpHideTimeout);
		clearTimeout(helpActivateTimeout);
		var fontStyleSize="";
		if ((macOrWin == "Mac") && (browserName == "IE"))
		{fontStyleSize="Large";}
		helpLayerObj.innerHTML = '<p class=\"helpFontStyle'+fontStyleSize+'\">' + thehelptext + '</p>';
		helpActivateTimeout = setTimeout('ShowHelpLayer('+x+','+y+');',helpShowAfter);
		helpHideTimeout = setTimeout('HideHelpLayer();',helpHideAfter);
		
		
		var newhelpPosX = x;
		var newhelpPosY = y;
		
		if (document.all)
		{
			newhelpPosX = newhelpPosX + document.body.scrollLeft;
			newhelpPosY = newhelpPosY + document.body.scrollTop;
		}
		else if (document.getElementById)
		{
			var spaceUsedVertical = parseInt(window.screen.availHeight) - parseInt(window.innerHeight);
			var spaceUsedHorizontal = parseInt(window.screen.availWidth) - parseInt(window.innerWidth);
			//if (spaceUsedHorizontal > 600)
			//{spaceUsedHorizontal = spaceUsedHorizontal - 600;} // Safari OSX 10.4 Behavior
			newhelpPosX = newhelpPosX + window.pageXOffset - spaceUsedHorizontal;
			newhelpPosY = newhelpPosY + window.pageYOffset - spaceUsedVertical;
		}
		newhelpPosX = newhelpPosX + helpleftModifier;
		newhelpPosY = newhelpPosY + helpTopModifier;
		newhelpPosX = newhelpPosX + helpleftModifierBrowser;
		newhelpPosY = newhelpPosY + helpTopModifierBrowser;
		helpLayer.left = parseInt(newhelpPosX);
		helpLayer.top = parseInt(newhelpPosY);
		
				
		//helpLayerObj.innerHTML = helpLayerObj.innerHTML + navigator.appVersion;
		//helpLayerObj.innerHTML = helpLayerObj.innerHTML + navigator.appName;
		if (navigator.appVersion.indexOf("Safari") > -1)
			{
			  //helpLayerObj.innerHTML = helpLayerObj.innerHTML + 'Saf';
				helpLayer.left = parseInt(x) - 15 + parseInt(document.body.scrollLeft) - parseInt(window.screenLeft);
				helpLayer.top = parseInt(y) - 75 + parseInt(document.body.scrollTop) - parseInt(window.screenTop);
				

			}
		else if (navigator.appVersion.indexOf("Macintosh") > -1)
			{
				if (navigator.appName.indexOf("Netscape") > -1)
				{
					helpLayer.left = parseInt(x) - 15 + parseInt(document.body.scrollLeft) - parseInt(window.screenX);
					helpLayer.top = parseInt(y) - 75 + parseInt(document.body.scrollTop) - parseInt(window.screenY);
				}
			}
		else if (navigator.appName.indexOf("Netscape") > -1)
			{
				helpLayer.left = parseInt(x) - 15 + parseInt(document.body.scrollLeft) - parseInt(window.screenX);
				helpLayer.top = parseInt(y) - 75 + parseInt(document.body.scrollTop) - parseInt(window.screenY);
			}
			
		//else
			//{
				//helpLayer.left = helpLayer.left + 30;
				//helpLayer.top = helpLayer.top + 30;
			//}
	
		if (helpLayer.visibility == 'visible')
		{
			helpLayer.visibility = 'hidden';// redraw bug in IE :)
			helpLayer.visibility = 'visible';// redraw bug in IE :)
		}
		helpOldX = x;
		helpOldY = y;
		helpVtolerance = 10;
		helpHtolerance = 10;
		}// enough movement check END
		
	}
	else // not finished loading
	{
	helpOldX = -500;
	helpOldY = -500;
	}
}


function ShowHelpLayer (xcoord,ycoord)
{
	if (!(document.layers))
	{
		if (!(document.all))// redraw bug in Netscape6 :)
		{helpLayer.left = parseInt(helpLayer.left)+1;} // redraw bug in Netscape6 :)
		
		helpLayer.visibility = 'visible';
	}
}

function HideHelpLayer ()
{
	if (!(document.layers))
	{
	helpLayerObj.innerHTML = ' ';
	helpLayer.visibility = 'hidden';
	}
}

function HideHelp()
{
	if (!(document.layers))
	{
	clearTimeout(helpActivateTimeout);
	helpResetTimeout = setTimeout("ResetSPWHelp()",helpResetAfter);
	}
}

function InitSPWHelpBody()
{
	if (!(document.layers))
	{
	document.write('<div id=\"helpLayerStyle\">helptext</div>');
	}
}

function ResetSPWHelp()
{
	helpOldX = -500;
	helpOldY = -500;
	helpTopModifier = helpStandardTopModifier;
    helpleftModifier = helpStandardLeftModifier;
}

// to use the menus, insert onload="InitSPWHelp();" into the body tag
// and a javascript containing
// InitSPWHelpBody();
// into the body itself */

// @ SPW 2002 - All Rights Reserved
// You may not use this script or any part of it
// on any web site without
// proper license from SPW GmbH. 
// Email info@spw.info
// for purchase and licensing details.
