﻿
function textBoxWatermark(textBox, waterMark, className) {

    textBox.setAttribute("watermark", waterMark);
    textBox.value = waterMark;
    if (className) {
        textBox.className = className;
        textBox.setAttribute("watermarkClass", className);
        textBox.setAttribute("originalClass", this.className);
    }
    textBox.onblur = function() {
        var waterMark = this.getAttribute("waterMark");
        if (this.value == '' || this.value.length == 0) {
            this.value = waterMark;
            if (this.getAttribute("waterMarkClass"))
                this.className = this.getAttribute("waterMarkClass");
        }
    };

    textBox.onfocus = function() {
        var waterMark = this.getAttribute("waterMark");
        if (this.value == waterMark) {
            this.value = '';
            if (this.getAttribute("waterMarkClass"))
                this.className = this.getAttribute("originalClass");

        }
    };
}
