﻿(function ($) {
    $.fn.textboxhint = function (userOptions) {
        var options = $.extend({}, $.fn.textboxhint.defaults, userOptions);
        var txt;
        return $(this).filter(':text,textarea').each(function () {
            txt = $(this);
            if ($(this).val() == '') {
                $(this).focus(function () {
                    if ($(this).attr('typedValue') == '') {
                        $(this).removeClass(options.classname).val('');
                    }
                }).blur(function () {
                    $(this).attr('typedValue', $(this).val());
                    if ($(this).val() == '') {
                        $(this).addClass(options.classname).val(options.hint);
                    }
                }).blur();
            }
            $('#' + options.IDBtnS).click(function () {
                if (txt.val() == '' || txt.val() == options.hint) {
                    return false;
                }
            });
        });

    };

    $.fn.textboxhint.defaults = {
        hint: 'Please enter a value',
        classname: 'hint',
        IDBtnS: 'btn_search'
    };
})(jQuery);
