function validateText(whichField) {
	if (whichField.value.length <= 0) { return false; }
	return true;
}

function validateTextInteger(whichField) {
	if (whichField.value.length <= 0) { return false; }
	var num = parseInt(whichField.value);
	if (isNaN(num)) {
		return false;
	}
	return true;
}

function validateTextFloat(whichField) {
	if (whichField.value.length <= 0) { return false; }
	var num = parseFloat(whichField.value);
	if (isNaN(num)) {
		return false;
	}
	return true;
}

function validateMultipleSelect(whichField) {
	for (var count = 0; count < whichField.options.length; count++) {
		if (whichField.options[count] != null && whichField.options[count].selected == true) {
			if (whichField.options[count].values != "" && whichField.options[count].values != "Make a selection") {
				return true;
			}
		}
	}
	return false;
}

function validateSelect(whichField) {
	if (whichField.selectedIndex <= 0) {
		return false;
	}
	if (whichField.options == null || whichField.options[whichField.selectedIndex] == null) {
		return false;
	}
	if (whichField.options[whichField.selectedIndex].value == "" || whichField.options[whichField.selectedIndex].value == "null") {
		return false;
	}
	return true;
}

function validateRadio(whichField) {
	if (whichField.length == null) {
		return whichField.checked;
	} else {
		for (var count = 0; count < whichField.length; count++) {
			if (whichField[count].checked == true) {
				return true;
			}
		}
	}
	return false;
}

function checkMonthDays(monthNum,dayNum,errorString) {
	if (dayNum <= 0 || dayNum > 31) {
		alert(errorString + " Day must be between 1 and 31");
		return false;
	}
	if (monthNum < 0 || monthNum > 12) {
		alert(errorString + " Month must be between 1 and 12");
		return false;
	}
	
	if (dayNum <= 28) {
		return true;
	}

	if (monthNum == 2 && dayNum > 28) {
		alert(errorString + " February only has 28 days.");
		return false;
	}
	if (monthNum == 4 	&& dayNum > 30) {
		alert(errorString + " April only has 30 days.");
		return false;
	}
	if (monthNum == 6 	&& dayNum > 30) {
		alert(errorString + " June only has 30 days.");
		return false;
	}
	if (monthNum == 9 	&& dayNum > 30) {
		alert(errorString + " September only has 30 days.");
		return false;
	}
	if (monthNum == 11	&& dayNum > 30) {
		alert(errorString + " November only has 30 days.");
		return false;
	}
	return true;
}

function parseDateSelect(monthSelect,daySelect,yearSelect,errorString) {
	var monthSelected = monthSelect.selectedIndex;
	if (monthSelected <= 0) { return null; }
	var daySelected = daySelect.selectedIndex;
	if (daySelected <= 0) { return null; }
	var yearSelected = yearSelect.selectedIndex;
	if (yearSelected <= 0) { return null; }
	var year = yearSelect.options[yearSelected].value;	
	var month = monthSelect.options[monthSelected].value;
	var day = daySelect.options[daySelected].value;
	if (checkMonthDays(month,day,errorString) == false) {
		return null;
	}
	return new Date(year,(month-1),day);
}