// The javascript presents here comes from MyCalendar 2.2.6 from MojavLinux

var agt = navigator.userAgent.toLowerCase();
var createdChildren = new Array();

function createTitle(which, string, x, y, width) 
{
	x = document.all ? (event.clientX + document.documentElement.scrollLeft) : x;
	y = document.all ? (event.clientY + document.documentElement.scrollTop) : y;
	element = document.createElement('div');
	element.style.top = '-1000px'; // prohibits flashing in upper left corner of document
	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 > 0 ? 'width="' + width + '" ' : '') + 'cellspacing="0" cellpadding="0" border="0"><tr><td><table width="100%"><tr><td><span class="gen">' + 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
	overFlowY = y + renderedHeight + excessHeight - window.innerHeight - window.pageYOffset;
	y = overFlowY > 0 ? y - renderedHeight - 30 : 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';
	}
	createdChildren.push(renderedElement);
}

function destroyTitle() 
{
	if (createdChildren.length > 0) {
		document.body.removeChild(createdChildren.pop());
	}
}
