(function($) {
    $.fn.watermark = function(css, text) {
        return this.each(function() {
            var i = $(this), w;
            i.focus(function() {
                w && !(w = 0) && i.removeClass(css).data('w', 0).val('');
            })
			.blur(function() {
			    (!i.val() || i.val() == text) && (w = 1) && i.addClass(css).data('w', 1).val(text);
			})
			.closest('form').submit(function() {
			    w && i.val('');
			});
            i.blur();
        });
    };
    $.fn.removeWatermark = function() {
        return this.each(function() {
            $(this).data('w') && $(this).val('');
        });
    };
})(jQuery);

//REGISTER WATERMARKS
jQuery(document).ready(function() {
    //watermarkClass
    var textBoxWatermark = jQuery("input[id$='textBoxWatermark']");
    jQuery.each(textBoxWatermark, function(index, value) {
        jQuery(value).watermark('watermark', jQuery(jQuery(value)).attr('watermark'));
    });
});

function RemoveWatermarksClick() {
    var textBoxWatermark = jQuery("input[id$='textBoxWatermark']");
    jQuery.each(textBoxWatermark, function(index, value) {
        jQuery(value).removeWatermark();
    });
    return false;
}
jQuery.fn.InputHide = function() {
    return this.focus(function() {
        if (jQuery(this).data("temp") == null) jQuery(this).attr("temp", this.value);
        this.value = "";
    }).blur(function() { if (this.value == "") { this.value = jQuery(this).attr("temp"); } else { jQuery(this).attr("temp", this.value); } });
}
jQuery.fn.EnterSubmit = function(_options) {
    var defaults = {
        button: ""
    };
    var options = jQuery.extend(defaults, _options);
    this.data('SubmitButton', options.button);
    this.keypress(function(event) {
        if (event.keyCode == '13') {
            var button = jQuery(this).data('SubmitButton');
            return jQuery("#" + button).focus().click();
            return false;
        } return true;
    });
}  /*sample:$("#inp").EnterSubmit({ button: "btn1" ,check:"false"});*/
