(function ($) {
    $.fn.placeholderText = function () {

        return this.each(function () {

            var placeholderText;

            var $elem = $(this);

            function clearPlaceHolder() {
                if ($elem.hasClass('placeholder')) {
                    placeholderText = $elem.val();
                    $elem
                        .val('')
                        .removeClass('placeholder');
                }

                $elem.trigger('focusin');
            }


            $elem
                .focus(function () {
                    clearPlaceHolder();
                })
                .focusout(function (e) {
                    if ($.trim($elem.val()).length == 0) {
                        $elem
                            .addClass('placeholder')
                            .val(placeholderText);
                    }
                })
                .bind('setPlaceholderText', function (e) {
                    placeholderText = e.text;
                });

            if (this == document.activeElement) {
                setTimeout(function () { $elem.focus(); }, 0);
            }
        });
    }
})(jQuery);

    
    
