﻿<!--
//  Add a watermark to a text box.  Supply the ID, text to use and the CSS Class.
function AddWatermarkToTextbox(textBoxID, waterMarkText, waterMarkCSS, buttonID) {
    textBoxID = "#" + textBoxID;
    buttonID = "#" + buttonID;
    
    $(textBoxID).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(waterMarkCSS).val("");

    });

    // Define what happens when the textbox loses focus
    // Add the watermark class and default text
    $(textBoxID).blur(function() {

        $(this).filter(function() {
            // We only want this to apply if there's not
            // something actually entered
            return $(this).val() == ""

        }).addClass(waterMarkCSS).val(waterMarkText);

    });
    
    if (buttonID) {
		$(buttonID).click(function() {
			var box = $(textBoxID);
			
			if (box && box.val() == waterMarkText)
				return false;
		});
	}
    
    //  By default add the watermark text to the input...
    if ($(textBoxID).val() == "" || $(textBoxID).val() == waterMarkText) {
        $(textBoxID).addClass(waterMarkCSS);
    }
} 

//-->
