/**
 * @fn calendar(url, input, showTime)
 * @brief Open the calendar in a new popup window.
 * @param[in] url URL to the HTML part of the calendar.
 * @param[in] input Name of the @<INPUT@> tag where the calendar should write the date to.
 * @param[in] showTime If true, there will be also place to write time in the calendar.
 * @param[in] evn Onclick (or other event) that triggered the function.
 */ 
function showCalendarWindow(url, input, showTime, evn) {
	window.calendarData = new Object();
	window.calendarData.input = input;
	window.calendarData.showTime = showTime;
	var width = 350;
	var height = showTime ? 230 : 190;
	var left = evn.clientX - width - 25;
	var topOffset = isNaN(window.outerHeight - window.innerHeight) ? window.screenTop : window.outerHeight - window.innerHeight;
	var top = evn.clientY + topOffset - height - 30;
	left = left > 0 ? left : 0;
	top = top > 0 ? top : 0;
	window.open(url, 'Calendar', 'toolbar=0,location=0,scrollbars=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',top='+top+',left='+left);
}

function changeMultipleVisibility(action, baseID, startID, endID) {
	var visibility;
	switch (action.toLowerCase()) {
		case 'expand':
			visibility = '';
			break;
		case 'collapse':
			visibility = 'none';
			break;
		default:
			return;
	}
	var element;
	for (var i=startID; i<=endID; i++) {
		element = returnObjectById(baseID + i);
		if (element) {
			element.style.display = visibility;
		}
	}
}
