﻿$(document).ready(function() {
    $("body").click(function(event) {
        if ($(event.target).is('a') || $(event.target).parent('a').size() > 0) {
            var anchor;
            if ($(event.target).is('a')) {
                anchor = $(event.target);
            }
            else {
                anchor = $(event.target).parent('a');
            }
            if (anchor[0].hostname !== location.hostname &&  !($(anchor).hasClass('internal'))) {
                window.open(anchor[0].href);
                return false;
            }
        }
    });
    // add "opens in new window" to external links
    $("a[href*='http']:not([href*='"+location.hostname+"'])").each(
        function() {
            var title = $(this).attr("title");
            var titleNewWindow = title + " - opens in new window";
            $(this).attr("title", titleNewWindow);
        });

});