
;(function($) {
/**
 * Clear input and textarea placeholder values on focus in and replaces them on focus out if no edit was made
 *
 * @example jQuery("input").placeholder();
 *
 * @lastmod 2011-01-12 23.40
 *
 * @name placeholder
 * @type jQuery
 * @param Object	settings (not used yet)
 *								
 * @return jQuery
 * @author Dharma Ferrari (http://www.dharmaferrari.com)
 */
$.fn.placeholder = function(settings)
{  
	settings = $.extend({}, $.fn.placeholder.defaults, settings);
	
	return this.each(function() {
  	var $this = $(this);
    $this.addClass(settings.cssClass);
  	
    $this.data('old', $this.val());
	
    // On focus in
    $this.focusin(function() {
      if($this.data('old') == $this.val()) {
        $this.val('');
        $this.removeClass(settings.cssClass);
      }
    });
    
    // On focus out
    $this.focusout(function() {
      if('' == $this.val()) {
        $this.val($this.data('old'));
        $this.addClass(settings.cssClass);
      }
    });
    
  });
  
}

$.fn.placeholder.defaults = {
	cssClass : 'placeholder_in'
};

})(jQuery);

