﻿/*
* jquery.smartval 1.0 - Smarter way to add default texbox values
* 
* 
* Copyright (c) 2009 Paul Vlasenko
* http://websiteman@gmail.com
*
* Dual licensed under MIT and GPL 2+ licenses
* http://www.opensource.org/licenses
* 
* -----
* 
* Build: Mon Jun 15, 2009
*/

(function($) {
  $.fn.smartval = function() {

    return this.each(function() {

      // only apply to textbox inputs
      tbox = $(this).filter(':text');
      if (tbox.length < 1) return true;

      tbox.data('originalval', tbox.val());
      tbox.focus(function() {
        if ($(this).val() == $(this).data('originalval')) {
          $(this).val("").addClass('changetext');
        }
      });
      tbox.blur(function() {
        if ($(this).val() == "") {
          $(this).val($(this).data('originalval')).removeClass('changetext');
        }
      });

    });
  };
})(jQuery);
