// JavaScript Document

function validateDate (element, field) {
	error = document.getElementById('error_msg');
	submit = document.getElementsByName('submit');
	month = eval('document.getElementById("' + element.name + '_month")');
	day = eval('document.getElementById("' + element.name + '_day")');
	year = eval('document.getElementById("' + element.name + '_year")');
	date_val = eval('document.getElementById("' + element.name + '")');
	
	date_val.value = year.value + "-";
	date_val.value += (month.value != "") ? month.value : "01";
	date_val.value += (day.value != "") ? day.value : "01";
	
	if (field == 'year') {
		if (year.value < 1900 || year.value > 3000) { // replace w/ this year . . .
			error.innerHTML = "ERROR! You must select a year";
			year.parentElement.style.background = "#9B1B1B";
			
			submit[0].style.borderColor = "#000000";
			submit[0].style.color = "#9B1B1B";
			submit[0].style.fontWeight = "bold";
	
			if (month.value == "") {
				error.innerHTML += "<br />ERROR! You must select a month";
				month.parentElement.style.background = "#9B1B1B";
				
				submit[0].style.borderColor = "#000000";
				submit[0].style.color = "#9B1B1B";
				submit[0].style.fontWeight = "bold";
					
				is_error = true;
			} else {
				error.innerHTML = "";
				element.parentElement.style.background = "#FFFFFF";
					
				submit[0].style.borderColor = "#F99D1C";
				submit[0].style.color = "#000000";
				submit[0].style.fontWeight = "normal";
					
				is_error = false;
			}
		}
	}
}
