//
// Use this plugin to convert typical input elements (text, password and textarea)
// to a custom-designed element
//
(function($) {

$.fn.jforms = function(options) {

  // Extend the default options with the ones that were passed in
  var opts = $.extend({}, $.fn.jforms.defaults, options);

  // add a class to the body tag to let the CSS know that jforms
  // is being applied
  $("body").addClass("jforms");

  return this.each(function() {

    // keep a reference to the old select before we replace it
    var $this = $(this);

    // Build element specific options
    var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

    // Help IE6 with lack of attribute selectors by adding classes instead
    if ($this.attr("type") == 'text') {
      $this.addClass(o.textFieldClass);
    } else if ($this.attr("type") == 'password') {
      $this.addClass(o.passwordFieldClass);
    }

    // For each element chosen, wrap the necessary markup around each,
    // and if it's a textarea, wrap a slightly different set of markup
    if ($this.is("textarea")) {
      $this.wrap('<div class="input-outerarea"><div class="input-innerarea"></div></div>');
    } else {
      $this.wrap('<div class="input-outer"><div class="input-inner"></div></div>');
    }
    

  });

};

$.fn.jforms.defaults = {
  textFieldClass: 'textfield',
  passwordFieldClass: 'passwordfield'
};

})(jQuery);