﻿// JScript File

function applyWatermark(elementSelector, watermarkClass, watermarkText)
{
    // Define what happens when the textbox comes under focus
    // Remove the watermark class and clear the box
    $(elementSelector).focus(function() {

        $(this).filter(function() {

            // We only want this to apply if there's not
            // something actually entered
            return $(this).val() == "" || $(this).val() == watermarkText

        }).removeClass(watermarkClass).val("");

    });

    // Define what happens when the textbox loses focus
    // Add the watermark class and default text
    $(elementSelector).blur(function() {

        $(this).filter(function() {

            // We only want this to apply if there's not
            // something actually entered
            return $(this).val() == ""

        }).addClass(watermarkClass).val(watermarkText);

    });
}
