﻿
$(function () {
    //Check to see if browser supports onbeforeprint (IE6, IE7 and IE8)
    if (window.onbeforeprint !== undefined) {
        //Since the browser is IE, add event to append link text before print
        window.onbeforeprint = ShowLinks;

        //Remove the link text since the document has gone to the printer
        window.onafterprint = HideLinks;
    }
    else {
        //The browser is not IE so attach a print style to append the link's text when printed
        //$('head').append('<style type="text/css" media="print">.print_link:after { content: " (" attr(href) ")"; }</style>');
        $('head').append('<style type="text/css" media="print">.content-wrapper a:after { content: " (" attr(href) ")"; }</style>');
    }
});

function ShowLinks() {
    //$(".print_link").each(function() {
    $(".content-wrapper a").each(function () {
        //Store the link's original text in the jQuery data store               
        $(this).data("linkText", $(this).text());

        //Append the link to the current text
        $(this).append(" (" + $(this).attr("href") + ")");
    });
}

function HideLinks() {
    //$(".print_link").each(function() {
    $(".content-wrapper a").each(function () {
        //Restore the links text to the original value by pulling it out of the jQuery data store
        $(this).text($(this).data("linkText"));
    });
}         
