// Validate fields on the My Preference 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.pref_form;
   var msg = "";
 
   if (f.Contact_Name.value == "") {
      badCount = badCount + 1;
	  msg = "Your Name";
   }
   if (f.Company.value == "") {
      badCount = badCount + 1;
	  if (msg =="") {
	     msg = "Company";
	  } else {
	    msg = msg + ", Company";
	  }
   }
   // check that one of the genders has been selected
   var i = getSelectedButton(f.contact_preference)
   if (i == 99) {
      badCount = badCount + 1;
	  if (msg =="") {
	     msg = "Your Preference";
   	  } else {
	    msg = msg + ", Your Preference";
	  }
   }		 

   
   if (badCount == 0) {
      return true;
    } else {
      alert ("Must enter all required fields: " + msg);
      return false;
     }
   
  }