
/************************************************************************/
/*	This script is designed to handle a print page in I.E. and Netscape */
/*  It has been tested in I.E. 4.0 and higher.							*/
/*	It has been tested in Netscape 4.08 and higher						*/
/************************************************************************/

if (!window.print){window.print = printFrame;}

/************************************************************************/
function printFrame(frame,onfinish) {
  if (!frame){frame=window;}

  if(frame.document.readyState !== "complete" 
     && !confirm("The document to print is not downloaded yet! Continue with printing?"))
  	{
		if(onfinish){onfinish();}
    return;
  }

  var eventScope = printGetEventScope(frame);
  var focused = document.activeElement;

    window.printHelper = function() {
    execScript("on error resume next: printWB.ExecWB 6, 1", "VBScript");
    printFireEvent(frame, eventScope, "onafterprint");
    printWB.outerHTML = "";
    if (onfinish)onfinish();
    if (focused && !focused.disabled) focused.focus();
    window.printHelper = null;
  }

  document.body.insertAdjacentHTML("beforeEnd","<object id=\"printWB\" width=0 height=0 \classid=\"clsid:8856F961-340A-11D0-A96B-00C04FD705A2\"></object>");

  printFireEvent(frame, eventScope, "onbeforeprint");
  frame.focus();
  window.printHelper = printHelper;
  setTimeout("window.printHelper()", 0);
}

/************************************************************************/
function printFireEvent(frame, obj, name) {
  var handler=obj[name];
  switch (typeof(handler)) {
    case "string": frame.execScript(handler); break;
    case "function": handler();
  }
}

/************************************************************************/
function printGetEventScope(frame) {
  var frameset=frame.document.all.tags("FRAMESET");
  if (frameset.length) return frameset[0];
  return (frame.document.body);
}

/************************************************************************/
/*	End of print page script											*/
/************************************************************************/