function checkForm(form) {
	var incomplete=0;
	var alertMsg = "The following fields are required:\n";

	if(allTrim(form.fname.value) == "" || allTrim(form.lname.value) == "") {
			incomplete++;
			alertMsg = alertMsg +"Name\n";
		}

	if(allTrim(form.company.value) == "") {
			incomplete++;
			alertMsg = alertMsg +"Company\n";
		}

	if(allTrim(form.telephone.value) == "") {
			incomplete++;
			alertMsg = alertMsg +"Telephone Number\n";
		}

	if(allTrim(form.email.value) == "") {
			incomplete++;
			alertMsg = alertMsg +"Email Address\n";
		}
	if(allTrim(form.abstract.value) == "") {
			incomplete++;
			alertMsg = alertMsg +"ER Subject (Short Description)\n";
		}
	if(allTrim(form.enhancement_description.value) == "") {
			incomplete++;
			alertMsg = alertMsg +"Enhancement Description\n";
		}
	if(allTrim(form.benefit_description.value) == "") {
			incomplete++;
			alertMsg = alertMsg +"Benefit Description\n";
		}

	if (incomplete > 0){
		alert(alertMsg);
		return false;
	}

	if (checkEmail(form.email.value) == false) {
			form.email.focus();
			return false;
	}

		
}

function checkEmail(addr) {
//  Will check for @, period after @ and text in between
	
	var in_space = addr.indexOf(" ");
	if (in_space != -1)
	{ alert ("Email address should contain no spaces and be of the form jdoe\@aol.com");
			return false;  }

	var len = addr.length;
	var alpha = addr.indexOf("@");
	var last_alpha = addr.lastIndexOf("@");

	if (alpha != last_alpha)
	 {  alert ("Bad email address. Should contain only one @ and be of the form jdoe\@aol.com");
			 return false; }

	// No @, in first position, or name too short
	if (alpha == -1 || alpha == 0 || len<6 )
	 {  alert ("Bad email address. Should contain an @ and be of the form jdoe\@aol.com");
			 return false; }

	var last_p = addr.lastIndexOf(".");
			// Be sure period at least two spaces after @, but not last char.
			
	if (last_p - alpha < 2 || last_p == (len - 1) )
		{  alert ("Bad email address. Should contain a period after the @ and be of the form jdoe\@aol.com");
				return false; }
				
	return true;
}

function allTrim(cValue){
  var lDone=false;
  while (lDone==false){
    if (cValue.length==0) {return cValue;}
    if (cValue.indexOf(' ')==0){cValue=cValue.substring(1);lDone=false; continue;}
    else {lDone=true;}
    if (cValue.lastIndexOf(' ')==cValue.length-1){cValue=cValue.substring(0, cValue.length-1);lDone=false;continue;}
    else {lDone=true;}
  }
  return cValue;
}