﻿(function ($) {
    $.fn.jqprint = function (options) {
        var $element = (this instanceof jQuery) ? this : $(this);

        var sOption = "toolbar=yes,location=no,directories=yes,menubar=yes,";
        sOption += "scrollbars=yes,width=855,height=500,left=100,top=25, status=yes";

        var tab = window.open("", "", sOption);
        tab.document.open();

        var doc = tab.document;

        doc.write("<html>");
        doc.write("<body onLoad='self.print()'>");

        $("title").each(function () {
            doc.write("<title>" + $(this).html() + "</title>");
        });

        doc.write("<link type='text/css' rel='stylesheet' href='../css/print.css' />");

        doc.write($('#companylogo').html());

        doc.write("<div style='margin-top:30px; margin-bottom:40px;'>");
        $element.each(function () { doc.write($(this).html()); });
        doc.write("</div>");

        doc.write($('#copyright').html());

        doc.write('</body></html>');

        doc.close();
        doc.focus();
    }
})(jQuery);
