//|
//|  Adds/removes the default text from inputs and textareas
//|  @param options             Hash or String.  If a string is given, it is assigned as the 'initial' option
//|  @option initial            value of input when page is loaded (eg 'Type your name here')
//|  @option default_value      when focus is given, this value replaces the initial value
//|  @option onFocus            onFocus event handler
//|  @option onBlur             onBlur event handler
//|
jQuery.fn.toggleValue = function(options)
{
  if ( ! options )  return false;
  
  if (typeof options == 'string')
  {
    options = {initial: options};
  }
  
  var settings = jQuery.extend({
    initial: '',
    default_value: '',
    onFocus: null,
    onBlur: null
  }, options);
  
  //store this in local variable
  var $this = $(this);
  
  $this.focus(function()
              {
                if ($this.val()==settings.initial)  $this.val( settings.default_value );
                if (settings.onFocus)
                {
                  if ( ! $this.onFocus )  $this.onFocus = settings.onFocus;
                  $this.onFocus();
                }
              });
  
  $this.blur( function()
              {
                if ($this.val()==settings.default_value || $this.val()=='')  $this.val( settings.initial );
                if (settings.onBlur)
                {
                  if ( ! $this.onBlur )  $this.onBlur = settings.onBlur;
                  $this.onBlur();
                }
              });
};


