﻿(function($) {
    $.fn.StartMessage = function() {
        return this.each(function() {
            $(this).css("color", "#777");
            if ($(this).data("startMsg") == null) {
                $(this).data("startMsg", $(this).val());
                $(this).focus(function() {
                    if ($(this).val() == $(this).data("startMsg")) {
                        $(this).css("color", "#000000");
                        $(this).val('');
                    }
                });

                $(this).blur(function() {
                    if ($(this).val() == '') {
                        $(this).css("color", "#777");
                        $(this).val($(this).data("startMsg"));
                    }
                });
            }
            else {
                $(this).css("color", "#777");
                $(this).val($(this).data("startMsg"));
            }
        });
    };
    $.fn.ValidateStartMessage = function() {
        if ($(this).val() == '' || $(this).val() == $(this).data("startMsg")) {
            $(this).css("background-color", "#ffe2e2");
            $(this).focus();
            $(this).select();
            return false;
        }
        else {
            $(this).css("background-color", "#ffffff");
            return true;
        }
    };
    $.fn.ReturnToStartMessage = function() {
        return this.each(function() {
            $(this).val($(this).data("startMsg"));
        });
    };
})(jQuery);
