﻿if (window.jQuery) {	
	(function ($) {
		$.fn.defaultValue = function (options) {
			options = $.extend(true, { propertyName: 'value' }, options);
			return $(this).each(function () {
				var input = $(this);
				if (!input.is('input[type="text"]'))
					return;
				var defValue = input.attr(options.propertyName);
				var orgValue = input.val();
				input.focus(function () {
					if (input.val() == defValue)
						input.val(orgValue);
				});
				input.blur(function () {
					if (input.val().replace(/^\s|\s$/, '').length == 0)
						input.val(defValue);
				});
				input.parents("form").submit(function () {
					if (input.val() == defValue)
						input.val(orgValue);
				});
				input.val(defValue);
			});
		}
	})(jQuery)
}
