var gAutoPrint = true;

function processPrint(){

if (document.getElementById != null){

var html = '<HTML>\n<HEAD>\n';

if (document.getElementsByTagName != null){

var headTags = document.getElementsByTagName("head");

if (headTags.length > 0) html += headTags[0].innerHTML;

}

html += '\n</HE' + 'AD>\n<BODY>\n';

var printReadyElem = document.getElementById("body");

if (printReadyElem != null) html += printReadyElem.innerHTML;

else{

alert("Error, no contents.");

return;

}

html += '\n</BO' + 'DY>\n</HT' + 'ML>';

var printWin = window.open("","processPrint");

printWin.document.open();

printWin.document.write(html);

printWin.document.close();

if (gAutoPrint) printWin.print();

} else alert("Browser not supported.");

}

var w;
function printImage ( img_id ) {

img = document.getElementById( img_id ).src;
  if (w && !w.closed)
    w.close();
  w = open ('', 'imagePrint', 
       'menubar=1,locationbar=0,statusbar=0,resizable=1'
       + ',scrollbars=1,width=800');
  var html = '';
  html += '<HTML><BODY ONLOAD="if (window.print) window.print(); '
           + 'setTimeout(\'window.close()\', 10000);">';
  html += '<IMG SRC="' + img + '">';
  html += '<\/BODY><\/HTML>';
  w.document.open();
  w.document.write(html);
  w.document.close();
}

