﻿//Watermark.js
//To set watermark for the textbox
//Wherever we need the watermark for textbox, set watermark text as rel attribute
//And CSSClass as "watermarkExtender"

 $(document).ready(function() {
        var $watermarkTextBoxes = $('input.watermarkExtender');
        $watermarkTextBoxes.each(function() {
        var $watermarkTextbox = $(this);
            //If the value is empty, set the watermark text as value
            //And add the watermark css clas
            //else Remove the watermark css class
            if ($watermarkTextbox.attr('value') == "") {
                $watermarkTextbox.attr('value', $watermarkTextbox.attr('rel'));
                $watermarkTextbox.addClass("WaterMarkedTextBox");
            }
            
            else {
                $watermarkTextbox.removeClass("WaterMarkedTextBox");
            }
            //Focus and blur : Checks for the focus and if it is true , 
            //removes the text else adds the watermark text

            
                      
            $watermarkTextbox.bind('focus', function() {
                if ($(this).attr('value') == $(this).attr('rel')) {
                    $(this).attr('value','');
                    $(this).removeClass("WaterMarkedTextBox");
                }
            }).bind('blur', function() {
                if ($(this).attr('value') == "") {
                    $(this).attr('value',$(this).attr('rel'));
                    $(this).addClass("WaterMarkedTextBox");
                }
            });

        });
    });
