var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.CLICK)
var tempX = 0;
var tempY = 0;
var offsetX = 0;
var offsetY = 0;

function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.screenX;
		tempY = event.screenY;
		offsetX	= event.offsetX;
		offsetY = event.offsetY;
	}
	else {  // grab the x-y pos.s if browser is NS
		tempX = this.pageX;
		tempY = this.pageY;
	}  
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}  

	return true;
}

function loadCalendar(targetCtl, curDate) {
    calculateXY();
    var cWin = window.open("includes/Calendar.aspx?nulls=0&formname=" + targetCtl + "&curDate=" + escape(curDate), "calendar_win", "width=200,height=208,top=" + tempY + ",left=" + tempX + ",resizable=yes,toolbar=no,titlebar=no,status=no,alwaysRaised");
    return false; 
    
}	

function loadCalendarAllowNulls( targetCtl, curDate ) {
	calculateXY();
	var cWin = window.open("includes/Calendar.aspx?nulls=1&formname=" + targetCtl + "&curDate=" + escape(curDate), "calendar_win", "width=210,height=208,top=" + tempY + ",left=" + tempX + ",resizable=yes,toolbar=no,titlebar=no,status=no,alwaysRaised");
	return false;

}

function calculateXY()
{

	getMouseXY();
		
	if( ((tempX+210) > window.screen.width) || ((tempY+208) > window.screen.height) )
	{
		tempX = (tempX - 210);
		tempY = (tempY - 208 - 22);
	}
	else
	{
		tempX = (tempX - offsetX + 22);
		tempY = (tempY - offsetY);
	}
	
}