﻿$(document).ready(function() {
    $('#srch input[type=text]').watermark();
});

jQuery.fn.watermark = function() {
    this.each(function() {
        var input = $(this);
        input.click(function() {
            removeWatermark(input);
        });
        input.blur(function() {
            addWatermark(input);
        });
        input.parent("form").submit(function() {
            removeWatermark(input);
        });
        addWatermark(input);
    });

    function removeWatermark(input) {
        if (input.attr("value") == input.attr("title"))
            input.attr("value", "");
    }

    function addWatermark(input) {
        if (input.attr("value") === "")
            input.attr("value", input.attr("title"));
    }
    return this;
};
