﻿
    $(document).ready(function () {

        (function ($) {
            $.fn.watermark = function (options) {
                opts = $.extend($.fn.watermark.defaults, options);

                $('form#form1').find('input[type="text"]').each(function () {
                    if ($(this).attr('title')) {
                        $(this).val($(this).attr('title'));
                        $(this).addClass(opts.cssClass);
                    }
                });
                $("input[type='text']").focus(function () {
                    if ($(this).val() == $(this).attr('title')) {
                        $(this).val('');
                        $(this).removeClass('water');
                    }
                });
                $("input[type='text']").blur(function () {
                    if ($(this).val() == '') {
                        $(this).val($(this).attr('title'));
                        $(this).addClass('water');
                    }
                });


                $('form#form1').find('input[type="password"]').each(function () {
                    if ($(this).attr('title')) {
                        $(this).val($(this).attr('title'));
                        $(this).addClass(opts.cssClass);
                    }
                });
                $("input[type='password']").focus(function () {
                    if ($(this).val() == $(this).attr('title')) {
                        $(this).val('');
                        $(this).removeClass('water');
                    }
                });
                $("input[type='password']").blur(function () {
                    if ($(this).val() == '') {
                        $(this).val($(this).attr('title'));
                        $(this).addClass('water');
                    }
                });


                
                $('input[type="submit"]').click(function () {
                    $("input[type='text']").each(function () {
                        if ($(this).val() == $(this).attr('title')) {
                            $(this).val('');
                        }
                    });

                    $("input[type='password']").each(function () {
                        if ($(this).val() == $(this).attr('title')) {
                            $(this).val('');
                        }
                    });

                });
            };

            $.fn.watermark.defaults = {
                cssClass: 'water'
            };

        })(jQuery);
        $('form').watermark();
    });

