// Plugin to make default hint fields easy
(function($) {
	$.fn.defaultValueActsAsHint = function() {
		$(this).attr("default", $(this).val());
		$(this).addClass('hint')

		// if ($(this).attr("type") == "password") {
		// 	clone = $(this).clone(true).attr("type", "text").attr("name", "").attr("clone", "true").attr("id", $(this).attr("id") + "_clone");
		// 	$(this).before(clone);
		// 	$(this).css("display", "none");
		// 	$(clone).defaultValueActsAsHint();
		// }

		$(this).focus(function() {
			if ($(this).attr("clone") == "true") {
				original = $(this).attr("id").replace("_clone", "");
				$(this).hide();
				$("#" + original).show();
				$("#" + original).focus();
			}

			if ($(this).val() == $(this).attr("default")) {
				$(this).val('');
				$(this).removeClass('hint')
			}
		});

		$(this).blur(function() {
			if ($(this).attr("type") == "password" && $(this).val() == "") {
				clone = $("#" + $(this).attr("id") + "_clone");
				$(this).hide();
				$(clone).val($(this).attr("default"));
				$(clone).addClass('hint')
				$(clone).show();
			}

			if ($.trim($(this).val()) == "") {
				$(this).val($(this).attr("default"));
				$(this).addClass('hint')
			}
		});
	};
})(jQuery);
