function closeWindow(pw){
	pw.close();
}

function printWebPart(img){
    if (img) {
	    /*
	    img = img.replace("/view/", "/print/");
        //build html for print page
        var html = "<HTML>\n<HEAD>\n"+
            
            "\n</HEAD>\n<BODY>\n"+
            "<img src=" + img + ">"+
            "\n</BODY>\n</HTML>";
        //open new window
        var pw = window.open("about:blank", "_new");
        pw.document.open();
        pw.document.write(html);
        //pw.onafterprint = closeWindow(pw);
        pw.document.close();
        pw.print();
        
        */
        img = img.replace("/view/", "/print/");
        var win = window.open('', 'Image', 'resizable=yes,...');
        if (win) {
                win.document.writeln('<img src="' + img + '" alt="image">');
                win.document.close();
                win.focus();
                win.print();
        }

        return false;
        
        //pw.onafterprint = closeWindow(pw);
        /*
        var printWP = window.open("","printWebPart");
        printWP.document.open();
        //insert content
        printWP.document.write(html);
        
        //open print dialog
        printWP.print();
        //window.setTimeout(printWP.close(), 2000);
        printWP.close();
        */
    }
}
