﻿$(document).ready(function() {
    // watermarks and row highlights     
    $("[watermark]").each(function() {
        if (this.value === "") {
            this.value = $(this).attr("watermark");
            $(this).addClass("watermark");
        }
    })
    .focus(function() {
        if (this.value === $(this).attr("watermark")) {
            this.value = "";
            $(this).removeClass("watermark");
        }
    })
    .blur(function() {
        if (this.value === "") {
            this.value = $(this).attr("watermark");
            $(this).addClass("watermark");
        }
    });

    //remove watermark when form is submitted
    $("input:image, input:button, input:submit").click(function() {
        $("input[watermark], textarea[watermark]").each(function() {
            if (this.value === $(this).attr("watermark")) {
                this.value = "";
            }
        });
    });

    // tooltips
    $(":text[title], textarea[title]").focus(function() {
        var field = $(this);
        field.after("<p id='tooltip'>" + this.title + "</p>");
        var position = field.offset();
        $("#tooltip")
            .css("top", (position.top - 15) + "px")
            .css("left", (position.left + field.width() + 30) + "px")
            .fadeIn("slow");
    })
    .blur(function() {
        $("#tooltip").remove();
    });
});