$(document).ready(function() {

    // Comment form
    // Name
    $("#author").focus(function() {
        if ($(this).val() == "Name") {
            $(this).val("");
        };
        $(this).addClass("focus");
    });
    $("#author").blur(function() {
        if ($(this).val() == "") {
            $(this).val("Name");
        };
        $(this).removeClass("focus");
    });

    // E-mail
    $("#email").focus(function() {
        if ($(this).val() == "E-mail") {
            $(this).val("");
        };
        $(this).addClass("focus");
    });
    $("#email").blur(function() {
        if ($(this).val() == "") {
            $(this).val("E-mail");
        };
        $(this).removeClass("focus");
    });

    // Web site
    $("#url").focus(function() {
        if ($(this).val() == "Web site") {
            $(this).val("");
        };
        $(this).addClass("focus");
    });
    $("#url").blur(function() {
        if ($(this).val() == "") {
            $(this).val("Web site");
        };
        $(this).removeClass("focus");
    });

    // Comment
    $("#comment").focus(function() {
        if ($(this).val() == "Comment") {
            $(this).val("");
        };
        $(this).addClass("focus");
    });
    $("#comment").blur(function() {
        if ($(this).val() == "") {
            $(this).val("Comment");
        };
        $(this).removeClass("focus");
    });

    // Button
    $("#submit").focus(function() {
        $(this).attr("src", "/blog/wp-content/themes/sandbox/assets/imgs/post-button-on.png");
    });
    $("#submit").blur(function() {
        $(this).attr("src", "/blog/wp-content/themes/sandbox/assets/imgs/post-button-off.png");
    });
    $("#submit").hover(
    function() {
        $(this).attr("src", "/blog/wp-content/themes/sandbox/assets/imgs/post-button-on.png");
    },
    function() {
        $(this).attr("src", "/blog/wp-content/themes/sandbox/assets/imgs/post-button-off.png");
    }
    );
    $("#submit").click(function() {
        if (($("#author").val() == "Name") || ($("#email").val() == "E-mail")) {
            return false;
        };
        if ($("#url").val() == "Web site") {
            $("#url").val("");
        };
    });

    // Summary paragraphs
    $(".entry-content").each(function() {
        $(this).children("p:not(:has(img, a.more-link, object))").eq(0).addClass("summary");
    });

    // First word
    $("p.summary").each(function() {
        $(this).html($(this).html().replace(/^(“*|<a href="http:\/\/[a-zA-Z\-\.\/]+">)(\s*[a-zA-Z\.’\-]+)/, '$1<strong>$2</strong>'));
    });

    // Insert e-mail address
    $("#email-link").attr("href", "mailto:" + "hello" + "@" + "contrast.ie");
    $("#email-link").text("hello" + "@" + "contrast.ie");

});