
// ***********************************************************************
// Submit Form
// Set all hidden fields to visible, hide the submit button and submit the form
// ***********************************************************************

function submitForm(form, text)
{ 

// Search for submit buttons, replace the text and disable

  for(i=0;i<form.elements.length;i++) 
  {
    elm = form.elements[i];
    if (elm.type == 'submit')
    { elm.value = text;
      elm.disabled = true;
    }
  }

// Enable all fields except 'submit'

  for (i=0;i<form.elements.length;i++)
  { if (typeof form.elements[i].disabled != 'undefined' && form.elements[i].type != 'submit')
      form.elements[i].disabled = false;
  }

// Submit the form
  
  form.submit();
  return false;
}

// ***********************************************************************
// Submit form and redirect to specified page handle
// ***********************************************************************

function submitFormFrame(form, text, phandle)
{ 
  form.elements["page"].value=phandle;
  return submitForm(form, text);
}

// ***********************************************************************
// Switch the field editability on/off depending on enable
// Set focus to the field if focus==true
// ***********************************************************************

function toggleField(field, enable, focus) 
{ if (typeof field.disabled != 'undefined') 
  { if (enable)
    { field.disabled = false;
      if (focus) 
      { field.focus();
        field.select();
      }
    }
    else
      field.disabled = true;
  }
  else 
  { if (enable)
    { field.onfocus = null;
      if (focus) 
      { field.focus(); 
        field.select();
      }
    }
  }
}

