function doCalculate()
{
	elDay = document.getElementById('day');
	elMonth = document.getElementById('month');
	elYear = document.getElementById('year');
	errorMessage = document.getElementById('eMessage');

	recordDay = document.getElementById('day').value;
	recordMonth = document.getElementById('month').value;
	recordYear = document.getElementById('year').value;

	elDay.style.color = "";
	elMonth.style.color = "";
	elYear.style.color = "";
	errorMessage.style.display = "none";

	if (recordDay < 1) {
		elDay.style.color = "red";
	}

	if (recordMonth < 0)  {
		elMonth.style.color = "red";
	}

	if (recordYear < 1) {
		elYear.style.color = "red";
	}

	if ((recordDay < 1) || (recordMonth < 0) || (recordYear < 1)) {
		document.getElementById('result1').style.display = "none";
		document.getElementById('result2').style.display = "none";
		errorMessage.style.display = "block"
	} else {
		document.getElementById('result1').style.display = "";
		document.getElementById('result2').style.display = "";
		dateRec = new Date(recordYear,recordMonth,recordDay);
		dateRec.setDate(dateRec.getDate( ) + 45);
		document.getElementById('day45').firstChild.nodeValue = dateRec.toDateString();
		dateRec.setDate(dateRec.getDate( ) + 180 - 45);
		document.getElementById('day180').firstChild.nodeValue = dateRec.toDateString();
	}

	return true;
}

function loadCurrentDate()
{
	today = new Date();

	document.getElementById('year').selectedIndex = today.getYear - 2007;
	document.getElementById('month').selectedIndex = today.getMonth();
	document.getElementById('day').selectedIndex = today.getDate() - 1;
}


if (window.addEventListener) {
	window.addEventListener("load", loadCurrentDate, false);
} else if (window.attachEvent) {
	window.attachEvent("onload", loadCurrentDate);
}

