document.onmouseover = hideEvents;
document.onclick = hideEvents;

function showEvent(where,whatBox,eventObj,direction)
{
	hideEvents();
	eventObj.cancelBubble = true;
  var styleObject = getStyleObject(whatBox);
  if(styleObject) 
	{
		var cords = findPos(where);
		var xPos = (cords[0]);
		var yPos = cords[1];
		var objBox = document.getElementById(whatBox);
		if(typeof(window.innerWidth) == 'number')
		{
			var docWidth = window.innerWidth;
			var boxHeight = objBox.height;
			var dayHeight = where.height;
		}
		if(typeof(document.body.offsetWidth) == 'number')
		{
			var docWidth = document.body.offsetWidth - 10;
			var boxHeight = objBox.offsetHeight;
			var dayHeight = where.offsetHeight;
		}
		if ((xPos + 340) > docWidth)
		{
			xPos = docWidth - 340;
		}
		else
		{
			xPos -= 20;
		}
		var ScrollTop = document.body.scrollTop;
		if (ScrollTop == 0)
		{
	    if (window.pageYOffset)
			{
				ScrollTop = window.pageYOffset;
			}
    	else
			{
        ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
			}
		}
		//if(boxHeight > 300){boxHeight = 335;}
		if(direction > 0)
		{
			boxHeight -= 10;
			yPos -= boxHeight;
			if(yPos < ScrollTop){yPos = ScrollTop;}
		}
		else
		{
			yPos += (dayHeight-5);
			var docHeight = getHeight();
			var docBottom = ScrollTop + docHeight;
			if((yPos + boxHeight) > docBottom){yPos = (docBottom - boxHeight);}
		}
		//alert('yPos:'+yPos+', boxHeight:'+boxHeight);
		//alert(boxHeight);
		xPos += 'px';
		yPos += 'px';
		//alert(yPos);
		styleObject.left = xPos;
		styleObject.top = yPos;
		styleObject.visibility = 'visible';
		styleObject.zIndex = 10;
		//alert(styleObject.visibility);
		return true;
	} 
	else 
	{
		return false;
  }
}
function hideEvents()
{
	for(i=0;i<eventCount;i++)
	{
		var whatBox = 'event' + i;
		changeObjectVisibility(whatBox,'hidden',1);
	}
}