if(document.all)
{
	//alert('IE');
	document.attachEvent('onmousemove',moveMouse);
}
else
{
	//alert('NN');
	document.addEventListener('mousemove',moveMouse,true);
}


var browser=navigator.userAgent;

//alert(browser);

var netscapeY = 0;
var netscapeX = 8;
var isNetscape = browser.split('Navigator');
if(isNetscape.length > 1 ) netscapeY = 25;

var safariY = 0;
var safariX = -7;
var isSafari = browser.split('AppleWebKit');
if(isSafari.length > 1 ) safariY = 50;

//alert('netscapeY = ' + netscapeY);

var toolTipVisible = false;
function toolTip(action, innerHTMLp)
{
	innerHTMLp = unescape(innerHTMLp);
	switch (action)
	{
		case 'on':
			toolTipVisible = true;
			//document.getElementById('toolTip_ShortDecription').style.visibility = 'visible';
			//alert(document.getElementById('toolTip').style.visible);
			//alert(toolTipVisible);
			break;
		case 'off':
			toolTipVisible = false;
			document.getElementById('toolTip_ShortDecription').style.visibility = 'hidden';
			//alert(document.getElementById('toolTip').style.visible);
			//alert(toolTipVisible);
			break;
	}
	if( innerHTMLp != '')
	{
			//alert(innerHTML);
			document.getElementById('toolTip_innerDiv').innerHTML = innerHTMLp;
	}
}
function highlight_over(id)
{
	document.getElementById('td_'+id).className = "cSmallPhoto_td_over";
	//alert(document.getElementById('td_'+id).className);
}
function highlight_out(id)
{
	document.getElementById('td_'+id).className = "cSmallPhoto_td";
	//alert(document.getElementById('td_'+id).className);
}

var xPos = 10;
var yPos = 10;
var padding = 20;
function moveMouse(e) 
{
	if(toolTipVisible)
	{
		
		if(document.getElementById('toolTip_ShortDecription').style.visibility == 'hidden') document.getElementById('toolTip_ShortDecription').style.visibility = 'visible';
		
		if (document.all) 
		{
			//document.body.clientWidth 												- browser width
			//document.getElementById('toolTip_ShortDecription').offsetWidth 			- width of toolTip
			//document.getElementById('toolTip_ShortDecription').offsetLeft 			- xPosition of toolTip
			
			
			//
			if(document.getElementById('toolTip_ShortDecription').offsetWidth + window.event.x >= document.body.clientWidth) //Check if toolTip goes outside of the screen
			{
				document.getElementById('toolTip_ShortDecription').style.left = window.event.x - document.getElementById('toolTip_ShortDecription').offsetWidth - xPos - padding; 
			}
			else
			{
				document.getElementById('toolTip_ShortDecription').style.left = window.event.x + xPos;
			}
			if( (window.event.y + document.body.scrollTop) + document.getElementById('toolTip_ShortDecription').offsetHeight > document.body.clientHeight + document.body.scrollTop - padding)
			{
				document.getElementById('toolTip_ShortDecription').style.top = document.body.clientHeight + document.body.scrollTop - document.getElementById('toolTip_ShortDecription').offsetHeight - 10 - padding;
			}
			else
			{
				document.getElementById('toolTip_ShortDecription').style.top = window.event.y + document.body.scrollTop;
			}
			
			//***************
			//document.getElementById('tooltip_trace').innerHTML = "toolTip.x = " + document.getElementById('toolTip_ShortDecription').offsetLeft + "<BR>" 
//															   + "toolTip.width = " + document.getElementById('toolTip_ShortDecription').offsetWidth + "<BR>"
//															   + "browser width = " + document.body.clientWidth + "<BR>"
//															   + "netscapeY = " + netscapeY + "<BR>" 
//															   + "safariY = " + safariY + "<BR>" 
//															   + "e.screenX = " + e.screenX + "<BR>"														  
															   
		}
		else
		{
			if( (e.screenX - window.screenX + xPos + safariX + netscapeX) + document.getElementById('toolTip_ShortDecription').offsetWidth > window.innerWidth - padding )
			{
				document.getElementById('toolTip_ShortDecription').style.left = e.screenX - window.screenX - document.getElementById('toolTip_ShortDecription').offsetWidth - xPos - padding;
			}
			else
			{
				document.getElementById('toolTip_ShortDecription').style.left = e.screenX - window.screenX + xPos + safariX + netscapeX;
			}

			
			if( e.clientY + document.body.scrollTop +  document.getElementById('toolTip_ShortDecription').offsetHeight >  window.innerHeight + document.body.scrollTop - padding            )
			{
				document.getElementById('toolTip_ShortDecription').style.top = window.innerHeight + document.body.scrollTop - document.getElementById('toolTip_ShortDecription').offsetHeight - 10 - padding;
			}
			else
			{
				document.getElementById('toolTip_ShortDecription').style.top = e.clientY + document.body.scrollTop;
			}
			
			//***************
			//document.getElementById('tooltip_trace').innerHTML = "toolTip.x = " + document.getElementById('toolTip_ShortDecription').offsetLeft + "<BR>" 
//															     + "toolTip.width = " + document.getElementById('toolTip_ShortDecription').offsetWidth + "<BR>"
//															     + "browser width = " + window.innerWidth + "<BR>"
//															     + "netscapeY = " + netscapeY + "<BR>" 
//			 												     + "safariY = " + safariY + "<BR><BR>"
//																 + "window.screenX = " + window.screenX + "<BR>"
//																 + "window.screenY = " + window.screenY + "<BR>"
//																 + "e.screenX = " + e.screenX + "<BR>"
//																 + "e.screenY = " + e.screenY + "<BR>"
//																 + "e.clientY = " + e.clientY + "<BR>"
//																 + "window.screenX = " + window.screenX + "<BR>"
//																 + "window.screenY = " + window.screenY + "<BR>"
//																 + "window.outerWidth = " + window.outerWidth + "<BR>"
//																 + "window.innerWidth = " + window.innerWidth + "<BR>"
//																 + "document.body.clientHeight = " + document.body.clientHeight + "<BR><BR>"
//																 
//																 + "e.screenY = " + e.screenY + "<BR>"
//																 + "window.screenY = " + window.screenY + "<BR>"
//																 + "document.body.innerY = " + document.body.innerY + "<BR>"
//																 + "window.outerHeight = " + window.outerHeight + "<BR>"
//																 + "window.innerHeight = " + window.innerHeight + "<BR>"
//															     + "window.pageYOffset = " + window.pageYOffset + "<BR>"
//																 + "document.body.scrollTop = " + document.body.scrollTop + "<BR><BR>"
//																 + "val1= " + (e.clientY + document.body.scrollTop +  document.getElementById('toolTip_ShortDecription').offsetHeight) + "<BR>"
//																 + "val2= " + (window.innerHeight) + "<BR>"
//																 //+ "document.getElementById('toolTip_ShortDecription').offsetWidth = " + document.getElementById('toolTip_ShortDecription').offsetWidth + "<BR>"
		}														 
	}
}