/*
  jsPrint 2.0.  Written by Joe McCormack, 2008.  www.virtualsecrets.com.
  In order to use:
  1.  Place "jsPrintFrameBuild(jsprintID)" in the onload of the body tag OR window.onload.
  2.  Place "<script language="javascript" type="text/javascript">jsPrintMsgBlock("", "");</script>" where you want messages to appear.
  3.  Add "jsPrintStream()" to the click or mousedown event that visitors would click on in order to print.  If you want to print different areas of a page, you should call this function inside your own function instead so that you can change different parameters before doing a print.
*/
var jsprintID = "jsprint";															/* Name, ID label to assign to the IFRAME which holds content for printing */
var jsprintMsgID = "jsprintmsg";														/* Name, ID label to assign to the message area that let's people know the statuses print process */
var jsprintTitle = "jsPrint Page";														/* Title of the printable document */
var jsprintContentTarget = "content";														/* ID label of the element which contains the data to print */
var jsprintCSS = "<style type=\"text/css\">body { font-family: verdana; font-size: 8pt; color: #000000; background-color: #FFFFFF; }</style>";	/* Styles associated to the page to print */
var jsprintBodyStart = "<table><tr><td>";													/* Beginning data, formatting to wrap content inside of */
var jsprintBodyEnd = "</td></tr></table>";													/* Ending data, which closes off the beginning data */
var jsprintStart = "Loading requested document...";
var jsprintStartPause = 2000;
var jsprintLoaded = "Document loaded.  Printing document...";
var jsprintLoadedPause = 4000;

/* Do not modify below this line */
var jsprintCount = 0;
function jsPrintMsgBlock(cssClass, inlineStyle) {
/*
  cssClass = name of the CSS class to use for the print message status area
  inlineStyle = inline CSS style
*/
if (cssClass.length > 0) { document.write("<span id=\"" + jsprintMsgID + "\" class=\"" + cssClass + "\"></span>"); }
else if (inlineStyle.length > 0) { document.write("<span id=\"" + jsprintMsgID + "\" style=\"" + inlineStyle + "\"></span>"); }
else { document.write("<span id=\"" + jsprintMsgID + "\"></span>"); }
}
function jsPrintStatusClean() { clearTimeout(jsprintCount); document.getElementById(jsprintMsgID).innerHTML = ""; }
function jsPrintStatusUpdate() { jsprintCount = setTimeout("jsPrintStatusFinal()", jsprintStartPause); }
function jsPrintStatusFinal() {
clearTimeout(jsprintCount);
document.getElementById(jsprintMsgID).innerHTML = jsprintLoaded;
jsprintCount = setTimeout("jsPrintStatusClean()", jsprintLoadedPause);
if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
							      /* NOTE: IE Cannot do a print when referencing the IFRAME these ways. */
							      // frames[jsprintID].focus();
							      // frames[jsprintID].print();

							      // document.getElementById(jsprintID).focus();
							      // document.getElementById(jsprintID).print();

							      // window.frames[jsprintID].document.focus();
							      // window.frames[jsprintID].print();
							     }
else {
      /* NOTE: If display is set to none for the IFRAME, Firefox will not recognize the IFRAME to do a print.  The display can be set to none in IE and will still print. */
      document.getElementById(jsprintID).contentWindow.print();
     }
}
function jsPrintWrap(data) {
var pageWrap = "<html id=\"" + jsprintID + "\">\n";
pageWrap = pageWrap + "<head>\n<title>" + jsprintTitle + "</title>\n" + jsprintCSS + "\n</head>\n";
if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
							      /* IE; can't handle spawning a print from anywhere but here. */
							      pageWrap = pageWrap + "<body onload=\"self.focus();self.print();parent.jsPrintStatusUpdate();\">\n" + jsprintBodyStart + data + jsprintBodyEnd + "\n</body>\n";
                                                             }
else {
      /* Firefox */
      pageWrap = pageWrap + "<body onload=\"javascript:parent.jsPrintStatusUpdate();\">\n" + jsprintBodyStart + data + jsprintBodyEnd + "\n</body>\n";
     }
pageWrap = pageWrap + "</html>";
return(pageWrap);
}
function jsPrintStream() {
document.getElementById(jsprintMsgID).innerHTML = jsprintStart;
var dataStream = document.getElementById(jsprintContentTarget).innerHTML;
if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
							      frames[jsprintID].document.open();
							      frames[jsprintID].document.write(jsPrintWrap(dataStream));
							      frames[jsprintID].document.close();
							     }
else {
      document.getElementById(jsprintID).contentWindow.document.open();
      document.getElementById(jsprintID).contentWindow.document.write(jsPrintWrap(dataStream));
      document.getElementById(jsprintID).contentWindow.document.close();
     }
}
function jsPrintFrameBuild(label) {
elem = document.createElement("iframe"); elem.name = label;
elem.id = label;
if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
							      /* IE must have element visible */
							      elem.style.visibility = "visible";
							     }
else {
      /* Firefox does not require the element to be visible */
      elem.style.visibility = "hidden";
     }
elem.style.width = "100%"; elem.style.height = "0px";
document.body.appendChild(elem);
}