﻿//Generating Pop-up Print Preview page
function getPrint(print_area) {
    //Creating new page
    var win = window.open('','PrintContent', 'height=600,width=600,status=yes,toolbar=no,menubar=no,resizable=yes');

    win.document.write('<HTML><HEAD><title>Print Content</title>')

    $("link[rel=stylesheet]").each(function() {
    win.document.write($('<div>').append($(this).clone()).remove().html());
    }
    );

    win.document.write('</HEAD>')
    

    //Adding Body Tag

    win.document.write('<body  text="#000000" MARGINWIDTH="0" MARGINHEIGHT="0" TOPMARGIN="0" LEFTMARGIN="0" >');
    
    win.document.write('<style type="text/css">' +
'@media print{' +
  '#printHeader{ visibility:hidden; }' +
'}'+
'</style>');

    //Creating two buttons Print and Close within a HTML table
    win.document.write('<script> function friendly_print(){ ' +
                        ' window.print(); } </script>' +
                         '<p id="printHeader" align="right" style="background-color:#999999" >' +
						   '<a href="javascript:friendly_print();" ><img src="/_layouts/images/beta1/nx_print_big.gif" align="ABSMIDDLE" border="0"></a>' +
						   '<a href="javascript:window.close()"><img src="/_layouts/images/beta1/nx_close_big.gif" align="ABSMIDDLE" border="0"></a>' +
				        '</p>');

    //Writing print area of the calling page
    win.document.write('<div id="printArea">');
    win.document.write(document.getElementById(print_area).innerHTML);
    win.document.write('</div>');
    //Ending Tag of </form>, </body> and </HTML>

    win.document.write('</body></HTML>');

    win.document.close();

}
