﻿
(function() {
    jQuery.fn.print = function(title) {
        var html = "<html>\n<head>\n<title>" + (title ? title : $("title").text()) + "</title>\n" +
					$("head").html() + "\n</head>\n<body>\n";
        this.each(function(i, e) {
            var o = $(e).clone();
            html += "<div style='margin:20px;'>\n" + $("<div>").append(o).html() + "</div>\n";
        });
        html += "</body>\n</html>";
        var printWP = window.open(null,null,"directories=0,height=500,left=" + 0.5*(screen.width-560) + ",toolbar=0,top=" + 0.5*(screen.height-500) + ",width=560");
        printWP.document.open();
        printWP.document.write(html);
        printWP.document.close();
        printWP.focus();
        printWP.print();
        return this;
    };
})();
