// Validate fields on the registration form 
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

function getSelectedButton(buttonGroup){
	for (var i = 0; i < buttonGroup.length; i++) {
	 
		if (buttonGroup[i].checked) {
			return i
		}
	}
	return 99
}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

function checkfrm() {
   var badCount = 0;
   var f = document.corpform;
   var msg = "";
 
   if (f.f_company.value == "") {
      badCount = badCount + 1;
	  msg = "Company";
   }
   if (f.f_name.value == "") {
      badCount = badCount + 1;
	  if (msg =="") {
	     msg = "Name";
	  } else {
	    msg = msg + "\nName";
	  }
   }
     if (f.f_title.value == "") {
      badCount = badCount + 1;
	  if (msg =="") {
	     msg = "Title";
	  } else {
	    msg = msg + "\nTitle";
	  }
   }
   if (f.f_dept.value == "") {
      badCount = badCount + 1;
	  if (msg =="") {
	     msg = "Department";
	  } else {
	    msg = msg + "\nDepartment";
	  }
   }
   if (f.f_phone.value == "") {
      badCount = badCount + 1;
	  if (msg =="") {
	     msg = "Contact's Phone";
	  } else {
	    msg = msg + "\nContact's Phone";
	  }   
   }
   if (f.f_your_name.value == "") {
      badCount = badCount + 1;
	  if (msg =="") {
	     msg = "Your Name";
	  } else {
	    msg = msg + "\nYour Name";
	  }
   }
   if (f.f_your_phone.value == "") {
      badCount = badCount + 1;
	  if (msg =="") {
	     msg = "Your Phone";
	  } else {
	    msg = msg + "\nYour Phone";
	  }
   }
   
   //check that one of the referrer options has been selected
   var i = getSelectedButton(f.f_referrer)
   if (i == 99) {
      badCount = badCount + 1;
      if (msg =="") {
	     msg = "Referrer Option";
	  } else {
	     msg = msg + "\nReferrer Option";
	  }
   } 
   
   
   if (badCount == 0) {
      return true;
    } else {
      alert ("Must enter all required fields: \n" + msg);
      return false;
     }
   
  }