﻿/*
* Initially pulled from: 
*
* ToggleFormText
*
* Author:   Grzegorz Frydrychowicz
* E-mail:   grzegorz.frydrychowicz@gmail.com
* Date:     16-11-2007
*
* Modified by Michael Paladino on 8/7/2009 to work remove unneccessary code and 
* provide compatibility with ASP.NET Validators.  removeWatermarks() must be called
* client-side before submitting
*
*
*/

$(document).ready(function() {
    $("input:text, textarea, input:password").each(function() {
        if (this.value == '') {
            this.value = this.title;
            $(this).addClass("watermark");
        } else { $(this).removeClass("watermark"); }
    });
    $("input:text, textarea, input:password").focus(function() {
        if (this.value == this.title) {
            this.value = '';
            $(this).removeClass("watermark");
        }
    });
    $("input:text, textarea, input:password").blur(function() {
        if (this.value == '') {
            this.value = this.title;
            $(this).addClass("watermark");
        } else { $(this).removeClass("watermark"); }
    });
    $("input:image, input:button, input:submit").click(function() {
        $(this.form.elements).each(function() {
            if (this.type == 'text' || this.type == 'textarea' || this.type == 'password') {
                if (this.value == this.title && this.title != '') {
                    this.value = '';
                }
            }
        });
    });
});

function removeWatermarks() {
    $("input:text, textarea, input:password").each(function() {
        if (this.value == this.title && this.title != '') {
            this.value = '';
        }
    });
}
