
var agt = navigator.userAgent.toLowerCase();
var originalFirstChild;

function createTitle(which, string, x, y)
{
	// record the original first child (protection when deleting)
	if (typeof(originalFirstChild) == 'undefined')
	{
		originalFirstChild = document.body.firstChild;
	}



	x = document.all ? (event.clientX + document.body.scrollLeft) : x;
//	y = document.all ? (event.clientY + document.body.scrollTop) : y;
	y = document.all ? (event.clientY + document.documentElement.scrollTop) : y;
	element = document.createElement('div');
  element.style.position = 'absolute';
	element.style.zIndex = 1000;
	element.style.visibility = 'hidden';
	excessWidth = 0;
	if (document.all)
	{
		excessWidth = 50;
	}
	excessHeight = 20;
	element.innerHTML = '<div class="bodyline"><table width="400" cellspacing="0" cellpadding="3" border="2"><tr><td><table width="100%" bgcolor="#FFFFEE" cellspacing="0" cellpadding="4" ><tr><td><span style="FONT-SIZE: 8pt">' + string + '</span></td></tr></table></td></tr></table></div>';
	renderedElement = document.body.insertBefore(element, document.body.firstChild);
	renderedWidth = renderedElement.offsetWidth;
	renderedHeight = renderedElement.offsetHeight;

	// fix overflowing off the right side of the screen
	overFlowX = x + renderedWidth + excessWidth - document.body.offsetWidth;
	x = overFlowX > 0 ? x - overFlowX : x;

	// fix overflowing off the bottom of the screen

/* var scrollTop;
if (window.pageYOffset){  
	scrollTop = window.pageYOffset 
} else if(document.documentElement && document.documentElement.scrollTop){ 
	scrollTop = document.documentElement.scrollTop; 
} else if(document.body){ 
	scrollTop = document.body.scrollTop; 
} 
*/

/*
if(window.pageXOffset){ 
	scrollLeft=window.pageXOffset 
} else if(document.documentElement && document.documentElement.scrollLeft){ 
	scrollLeft=document.documentElement.scrollLeft; 
} else if(document.body){ 
	scrollLeft=document.body.scrollLeft; 
}


var windowWidth,windowHeight; // frame width & height

if(window.innerWidth){ 
	windowWidth=window.innerWidth; 
} else if(document.documentElement && document.documentElement.clientWidth){ 
	windowWidth=document.documentElement.clientWidth; 
} else if(document.body){ 
	windowWidth=document.body.offsetWidth; 
} 

if(window.innerHeight){ 
	windowHeight=window.innerHeight; 
} else if(document.documentElement && document.documentElement.clientHeight){ 
	windowHeight=document.documentElement.clientHeight; 
} else if(document.body){ 
	windowHeight=document.body.clientHeight; 
} */

	    overFlowY = y + renderedHeight + excessHeight - window.innerHeight - window.pageYOffset;
	   //overFlowY = y + renderedHeight + excessHeight - window.innerHeight - document.documentElement.scrollTop;
     y = overFlowY > 0 ? y - overFlowY : y;
      

	renderedElement.style.top = (y + 15) + 'px';
	renderedElement.style.left = (x + 15) + 'px';

	// windows versions of mozilla are like too fast here...we have to slow it down
	if (agt.indexOf('gecko') != -1 && agt.indexOf('win') != -1)
	{
		setTimeout("renderedElement.style.visibility = 'visible'", 1);
	}
	else
	{
		renderedElement.style.visibility = 'visible';
	}
}

function destroyTitle()
{
	// make sure we don't delete the actual page contents (javascript can get out of alignment)
	if (document.body.firstChild != originalFirstChild)
	{
		document.body.removeChild(document.body.firstChild);
	}
}