// Nav and Cal Functions

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEUP)
document.onmouseup = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
//alert("inside getMouseXY");
if (IE) { // grab the x-y pos.s if browser is IE
//alert("IE");
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else {  // grab the x-y pos.s if browser is NS
//alert("netscape");
tempX = e.pageX;
tempY = e.pageY;
}  
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}  
document.mouseX = tempX;
document.mouseY = tempY;
return true;
}

var cnnCurrentVisibleCalId = ''; // The name of the current visible navbar
var cnnTimeOverCal = -1; // Amount of time over nav

function cnnDelayedCalShow(calId, calLeftPos, calWidth)
{
	//alert("Inside cnnDelayedCalShow...");
	if(cnnCurrentDelayTimeOutPtr)
	{
		window.clearTimeout(cnnCurrentDelayTimeOutPtr);
	}
	
	cnnTimeOverCal = new Date().getTime();
	cnnCurrentDelayTimeOutPtr = window.setTimeout("cnnCalShow('"+calId+"')",250);
}

function cnnDetectCalPanelMouseOut(event, obj, calId)
{
	var current, related;
	if (window.event)
	{
		current = obj;
		related = window.event.toElement;
	}
	else
	{
		current = event.currentTarget;
		related = event.relatedTarget;
	}
	if (current != related && !cnnNodeContains(current, related))
	{
		cnnCalHide(calId);
	}
}

function cnnCalShow(calId)
{
         // Show the calendar

	//alert("Inside cnnCalShow... cnnCurrentVisibleCalId[" + cnnCurrentVisibleCalId + "], calId[" + calId + "]");
	if ( cnnCurrentVisibleCalId && (cnnCurrentVisibleCalId != calId) )
	{
		//alert("Call cnnCalHide to hide currently visible calendar...");
		cnnCalHide( cnnCurrentVisibleCalId );
	}

	//var calWidth = cnnGetDhtmlCalWidth( menu );
	var calLeftPos = document.mouseX;
	var calTopPos = document.mouseY;
	var subnav = cnnGetObject( calId + 'SubNav' );

	if(subnav && subnav.style)
	{
		//alert("calLeftPos[" + calLeftPos + "], calTopPos[" + calTopPos + "]");

		subnav.style.left = calLeftPos - 20;// + window.document.body.scrollLeft;
		subnav.style.top = calTopPos + 10;// + window.document.body.scrollTop;

		subnav.style.visibility = 'visible';
	}

	cnnCurrentVisibleCalId = calId;
}

function cnnCalHide(calId)
{
// hide the calendar
        
	var subnav = cnnGetObject( calId + 'SubNav' );
	if(subnav)
	{
		subnav.style.visibility = 'hidden';
		subnav.style.width = '0px';
		cnnAlterAllSelects('visible')
	}
	

}
