function CheckRequiredFields(f) {
   var sFieldValue = "";
   var iIndex = 0;
   var iElement = 0;
   var iRadio = 0;
   var iCheck = 0;
   
   // Retrieve the list of field names and labels
   var aFieldList = f.valFieldList.value.split(",");
   
   // Loop through the list of fields
   for (iIndex = 0; iIndex < aFieldList.length; iIndex++) {
      
      // Inform the user of what's happening
      window.status = "Validating field " + aFieldList[iIndex + 1] + " ...";
      
      // Loop through all elements in the form to find the field
      for (iElement = 0; iElement < f.elements.length; iElement++) {
         // Check whether the selected element is a required field
         if (f.elements[iElement].name == aFieldList[iIndex]) {
            // Check whether the field contains a value or not
            switch (f.elements[iElement].type) {
               // Text fields
               case "text" :
                  sFieldValue = f.elements[iElement].value;
                  break;
               // Text areas
               case "textarea" :
                  sFieldValue = f.elements[iElement].value;
                  break;
               // Listboxes
               case "select-one" :
                  if (f.elements[iElement].selectedIndex == 0) {
                     sFieldValue = "";
                  } else {
                     sFieldValue = String(f.elements[iElement].selectedIndex);
                  }
                  break;
               // Checkboxes
               case "checkbox" :
                  for (iCheck = 0; iCheck < f.elements[aFieldList[iIndex]].length; iCheck++) {
                     if (f.elements[iElement + iCheck].checked == false) {
                        sFieldValue = "";
                     } else {
                        sFieldValue = String(f.elements[iElement + iCheck].value);
                        break;
                     }
                  }
                  break;
               // Radiobuttons
               case "radio" :
                  for (iRadio = 0; iRadio < f.elements[aFieldList[iIndex]].length; iRadio++) {
                     if (f.elements[iElement + iRadio].checked == false) {
                        sFieldValue = "";
                     } else {
                        sFieldValue = String(f.elements[iElement + iRadio].value);
                        break;
                     }
                  }
                  break;
            }

            // Warn the user that the selected field is a required field
            if (sFieldValue == "") {
               alert(aFieldList[iIndex+1] + " is a required field. Make sure that " +
               aFieldList[iIndex+1] + " and all other required fields are filled out before saving the document.");
               f.elements[iElement].focus();
               return false;
            }
            break;
         }
      }
      iIndex++;
   }
   return true;
}

function QuerySave(f){
return CheckRequiredFields(f);
}