﻿
var FORM_METHODS =
{
  readonly: function(form)
  {
    var items = $(form).getElements();

    items.each(function(item)
    {
      if (item.type)
      {
        switch (item.type)
        {
          case 'hidden':
          case 'button':
            break;

          default:
            item.readonly();
        }
      }
    });
  },
  readwrite: function(form)
  {
    var items = $(form).getElements();

    items.each(function(item)
    {
      if (item.type)
      {
        switch (item.type)
        {
          case 'hidden':
          case 'button':
            break;

          default:
            item.readwrite();
        }
      }
    });
  }
};

var INPUT_METHODS =
{
  readonly: function(input)
  {
    PIE.readonly.disable(input);
  },
  readwrite: function(input)
  {
    PIE.readonly.enable(input);
  }
};

if (this.Element && this.Element.addMethods)
{
  this.Element.addMethods('FORM', FORM_METHODS);
  this.Element.addMethods(['INPUT', 'SELECT', 'OPTION', 'TEXTAREA', 'CHECKBOX'], INPUT_METHODS);
}
