/** ffFormSupport

    JavaScript functions for dealing with Form objects.

*/

function validateRequiredTextInput(textInput,labelString) {
  if (textInput.value == ''){
    alert('"'+labelString + '" is a required field and must be filled out.');
    textInput.focus();
    return false;
  }
  return true;
}

function validateRequiredOptionInput(selectControl,labelString) {
  if (selectControl.value == ''){
    alert('"'+labelString + '" is a required field and must be filled out.');
    selectControl.focus();
    return false;
  }
  return true;
}

function findSelectedValue(selectControl,value) {
  for (i=0;i<selectControl.length;i++)
    if (selectControl.options[i].value == value)
      return i;
  return -1;
}

function addOption(selectControl,value,name,defaultSelected,selected) {
  if (defaultSelected == null)
    defaultSelected = false;
  if (selected == null)
    selected = false;
  selectControl.options[selectControl.options.length] =  new Option(name, value, defaultSelected, selected);
}





