function openDateSelection(strFormElement, dteSelected)
{
	var calendarWindow = window.open('/includes/calendar/calendar.jsp?strFormElement=' + strFormElement + '&dteSelected=' + dteSelected, 'SelectDate', 'height=230,width=190');
	calendarWindow.focus();
}

function setDate(strFormElement, dteNew)
{
	document.getElementById(strFormElement).value = dteNew;
}

function clearDate(strFormElement)
{
	document.getElementById(strFormElement).value = '';
}

// the parameters passed should be references to the fields in the form, not the field values
function checkDates(dteStart, dteEnd)
{
	var startDate = new Date(dteStart.value);
	var endDate = new Date(dteEnd.value);

	if (startDate.getYear() > endDate.getYear() || (startDate.getYear() >= endDate.getYear() && startDate.getMonth() > endDate.getMonth()) || (startDate.getYear() >= endDate.getYear() && startDate.getMonth() >= endDate.getMonth() && startDate.getDate() > endDate.getDate()))
	{
		window.alert('The dates entered are invalid (the start date may fall after the\nend date), please change your selection and try again.');
		return false;
	}

	return true;
}

