// JavaScript Document
function validate() {
	x=document.frmDonate
	email=x.Email.value
	AtPos = email.indexOf("@");
	StopPos = email.lastIndexOf(".");
	name=x.Name.value
	type=x.Type
	amount=x.Amount.value
	comments=x.Donation.value
	submitOK="True"
	
	//clear all fields
	document.getElementById("emailError").innerHTML="";
	document.getElementById("nameError").innerHTML="";
	document.getElementById("typeError").innerHTML="";
	document.getElementById("commentsError").innerHTML="";
	document.getElementById("amountError").innerHTML="";
	
	//validate fields
	if (email.length<1) {
		document.getElementById("emailError").innerHTML="Error: No Information";
		submitOK="False"
	} else if (AtPos == -1 || StopPos == -1 || StopPos - AtPos == 1) {
		document.getElementById("emailError").innerHTML="Error: Invalid Email Address";
		submitOK = "False";
	}
	if (name.length<1) {
		document.getElementById("nameError").innerHTML="Error: No Information";
		submitOK="False"
	}
	myOption = -1;
	for (i=type.length-1; i > -1; i--) {
		if (type[i].checked) {
			myOption = i;
			theType = type[i].value
		}
	}
	if (myOption == -1) {
		document.getElementById("typeError").innerHTML="Error: Make a Selection";
		submitOK="False"
	} else {
		//if they selected items or time
		if (theType == 'Item' || theType == 'Time') {
			if (comments.length<1) {
				document.getElementById("commentsError").innerHTML="Error: No Information";
				submitOK="False"
			}
		} else {
			if (amount.length<1 || amount == '$') {
				document.getElementById("amountError").innerHTML="Error: No Amount";
				submitOK="False"
			}
		}		
	}
	if (submitOK=="False") {
		return false
	}
}