﻿$(document).ready(function () {
    // footer hover
    $("footer div.socialmedia a img").hover(
        function () {
            hoversocialFooterGrow($(this));
        },
        function () {
            hoversocialFooterShrink($(this));
        }
    );

    function hoversocialFooterGrow(img) {
        img.addClass("hover");
    }

    function hoversocialFooterShrink(img) {
        img.removeClass("hover");
    }

    // hover for images with class hoverable
    $(".page").delegate("img.hoverable", "mouseenter", function () {
        HoverOver($(this));
    });

    $(".page").delegate("img.hoverable", "mouseleave", function () {
        HoverOut($(this));
    });

    function HoverOver(img) {
        // add Hover
        var src = img.attr('src').replace('.', 'Hover.');
        img.attr('src', src);
    }

    function HoverOut(img) {
        var src = img.attr('src').replace('Hover.', '.');
        img.attr('src', src);
    }

    // keep social sharing buttons vertically aligned
    var $scrollingDiv = $("#sharesocialmedia");

    $(window).scroll(function () {
        $scrollingDiv
				.stop()
				.animate({ "marginTop": ($(window).scrollTop() + 0) + "px" }, 500);
    });
});
