String.prototype.trim = function() 
{
    return this.replace(/\s+/g, "");
}
    
function AddWatermark( txt, waterMarkText )
{
    var color = "#999";
    var defaultColor = $("#" + txt).css("color");
    
    if ( $("#" + txt).val().trim().length <= 0 )
    {
        $("#" + txt).css("color",   color); 
        $("#" + txt).val( waterMarkText );
    }
    
    $("#" + txt).focus
    (
        function ()
        {
            if ( $(this).val().trim().length <= 0  )
            {
                $(this).css("color",  color);
            }
            else if ( $(this).val() == waterMarkText )
            {
                $(this).css("color",  defaultColor );
                $(this).val("");
            }
        }
    );
    $("#" + txt).blur
    (
        function ()
        {
            if ( $(this).val() == waterMarkText || $(this).val().trim().length <= 0  )
            {
                $(this).css("color",  color);
                $("#" + txt).val( waterMarkText );
            }
        }
    );
    $("#" + txt).keydown
    (
        function ()
        {
            if (  $(this).val().trim().length > 0  )
            {
                $(this).css("color",  defaultColor);
            }
        }
    );
    $("form").submit
    (
        function() 
        {
            if ( $("#" + txt).val() == waterMarkText )
            {
                $("#" + txt).val("");
            }
        }
    );
}

    
