/*
formfunctions.js - library
	showSection(sectionId)
	hideSection(sectionId)
*/

function showSection(sectionId) {
	elem = document.getElementById(sectionId);
	elem.style.display = "block";
};

function hideSection(sectionId) {
	elem = document.getElementById(sectionId);
	elem.style.display = "none";
};

/********************************
	editCalendarForm functions
*********************************/

function updateEnrollmentDates( form ) {
	if ( form.cal_enrollment.value = "true" ) {
		if ( formValidator.isNotEmptyOptional( form.cal_date ) ) {
			var curDate		= form.cal_date.value;
			var eventDate	= new Date();
			var tempDate		= new Date();
			eventDate.setFullYear(curDate.substr(0,4));
			eventDate.setMonth(curDate.substr(5,2));
			eventDate.setDate(curDate.substr(8,2));
			/*calculate default deadline date */
			tempDate.setFullYear(eventDate.getFullYear());
			tempDate.setMonth(eventDate.getMonth());
			tempDate.setDate(eventDate.getDate() - 1);
			if (!formValidator.isNotEmptyOptional( form.cal_deadline ) ) {
			/* Insert value in field */
				form.cal_deadline.value	= (tempDate.getFullYear() + "-" + tempDate.getMonth() + "-" + tempDate.getDate());
			}
			/* calculate default enrollment start date */
			tempDate.setFullYear(eventDate.getFullYear());
			tempDate.setMonth(eventDate.getMonth());
			tempDate.setDate(eventDate.getDate() - 14);
			if (!formValidator.isNotEmptyOptional( form.cal_enroll_start ) ) {
			/* Insert value in field */
				form.cal_enroll_start.value	= (tempDate.getFullYear() + "-" + tempDate.getMonth() + "-" + tempDate.getDate());
			}
		}
	}
};

