function validateLogin() {
	if (document.login.username.value == '') {
		alert('Username is a required field.');
		document.login.username.focus();
		return false;
	}
	
	if (document.login.password.value == '') {
		alert('Password is a required field.');
		document.login.password.focus();
		return false;
	}
	return true;
}

function validateForgotPassword() {
	if (document.login.name.value == '') {
		alert('Name is a required field.');
		document.login.name.focus();
		return false;
	}
	
	if (document.login.emailAddress.value == '') {
		alert('E-mail Address is a required field.');
		document.login.emailAddress.focus();
		return false;
	}
	
	if (document.login.emailAddress.value != ''){
		if (checkEmail(document.login.emailAddress)){
		alert('The E-mail Address you entered is invalid.');
		document.login.emailAddress.focus();
		return false;
		}
	}
}

function validateAdminForm(whichForm) {
	theForm = whichForm;

	switch(whichForm.name){
		case "news_add":
			// Check Empty
			if (theForm.date.value		== '') { emptyFieldAlert(theForm,"date","Date");			return false;}
			if (theForm.startdate.value	== '') { emptyFieldAlert(theForm,"startdate","Start Date");	return false;}
			if (theForm.stopdate.value	== '') { emptyFieldAlert(theForm,"stopdate","Stop Date");	return false;}
			//if (theForm.author.value	== '') { emptyFieldAlert(theForm,"author","Author");		return false;}
			if (theForm.title.value		== '') { emptyFieldAlert(theForm,"title","Title");			return false;}
			//if (theForm.subhead.value	== '') { emptyFieldAlert(theForm,"subhead","Sub-Head");		return false;}
			if (theForm.summary.value	== '') { emptyFieldAlert(theForm,"summary","Summary");		return false;}
			if (theForm.override.checked == 0) {
				if (theForm.article.value	== '') { emptyFieldAlert(theForm,"article","Article");  return false;}
			}
			if (theForm.article.value	== '') {
				theForm.readmore.value = 0;
			} else {
				theForm.readmore.value = 1;
			}
			//if (theForm.link.value	== '') { emptyFieldAlert(theForm,"link","Link");			return false;}
			
			// Check Lengths
			if (theForm.author.value.length		> 50) { tooLongAlert(theForm,"author","Author","50");		return false;}
			if (theForm.title.value.length		> 100){ tooLongAlert(theForm,"title","Title","100");		return false;}
			if (theForm.subhead.value.length	> 100){ tooLongAlert(theForm,"subhead","Sub-Head","100");	return false;}
			if (theForm.summary.value.length	> 255){ tooLongAlert(theForm,"summary","Summary","255");	return false;}
			if (theForm.link.value.length		> 255){ tooLongAlert(theForm,"link","Link","255");			return false;}
			break;
	}
}
function emptyFieldAlert(whichForm,whichField,whichLabel) {
	alert('The ' + whichLabel + ' field is required.');
	whichForm[whichField].focus();
}
function tooLongAlert(whichForm,whichField,whichLabel,maxLength) {
	alert('The ' + whichLabel + ' field can only contain ' + maxLength + ' characters.\nIt currently contains: ' + whichForm[whichField].value.length + '.');
	whichForm[whichField].focus();
}
