function getQueryParameter(key) 
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    
    for (var i = 0; i < vars.length; i++) 
    {
        var pair = vars[i].split("=");
        if (pair[0] == key)
            return decodeURIComponent(pair[1] + '');
    }
    
    return(false);
}

$(function () {
    var section = getQueryParameter("section");
    if (!section) {
        return;
    }
    
    if (section == "all") {
        // Show all sections
        $(".print-section").show();
    }
    else {	
        // Show only the specified section
        $(".print-section-" + section).show();
    }

    window.onafterprint = function(event) {
        window.close();
    }
    
    window.print();
});