/**
 * smart_form_button plugin 1.0
 *
 * Displays form submit button when form changes
 *
 * Copyright (c)2009 Troy Kruthoff (http://blit.com/)
 * MIT license (blit.com/licenses/mit.html)
 */
 
jQuery.fn.smart_form_button = function() {
  function find_and_show(target) {
    var $target = jQuery(target);
    if ($target.closest('form').find('button.smart').show().length<1) {
      jQuery('button.smart').show();
    }
  } 
  
  return jQuery(this).find('input, textarea, select').each(function(){
    var $this = jQuery(this);
    if ($this.is('select')) {
      $this.one('change',function(){find_and_show(this)});
    } else {
      $this.one('keyup',function(){find_and_show(this)});
    }
  });
}
