﻿
jQuery.fn.inputHintOverlay = function (topNudge, leftNudge) {

    return this.each(function () {

        jQuery(this).submit(function () {
            jQuery(this).find("input[type=text], textarea").each(function () {

                var title = jQuery(this).attr('title');
                var input = jQuery(this);

                if (input.val() == title) {
                    input.val("");
                }
            });
        });


        jQuery(this).find("input[type=text], textarea").each(function () {

            var title = jQuery(this).attr('title');
            var input = jQuery(this);

            if (input.val() == "") {
                input.val(title);
                jQuery(this).addClass('blurred')
            }

            jQuery(this).focus(function () {
                if (input.val() == title) {
                    input.val("");
                    jQuery(this).removeClass('blurred')
                }
            });

            jQuery(this).blur(function () {
                if (input.val() == "" || input.val() == title) {
                    input.val(title);
                    jQuery(this).addClass('blurred')
                } else {
                    jQuery(this).removeClass('blurred')
                }
            });
        });

    });

}
