/* Javascript for print-friendliness, by Richard Harris, BBS, Nov 2007 */

function popupPrint() {
   window.open('print.htm','printWindow','width=620,height=460,resizable,top=90,left=120'); return false;
}

/* Since only the print-friendly window is shown inside a frame, we check all windows to see if they are on top.
   If the window is in a frame, it assumes to be in the print popup and disables all stylesheets except print.css */

function printCheck() {
   var css = document.getElementsByTagName('link');
   var buttons = document.getElementsByTagName('input');
   if(window != top) {
      /* disable links */
      for(j=0; j < document.links.length; j++) {
         document.links[j].href = '#'; //document.links[j].href.toString();
         document.links[j].disabled = true;
         document.links[j].onclick = new Function("return false;");
      }
      /* disable buttons */
      for(f=0; f < buttons.length; f++) {
         buttons[f].disabled = true;
      }
      /* disable styles */
      for(i=0; i < css.length; i++) {
         var linkTitle = css[i].title;
         css[i].disabled = true;
      /* enable print style */
         if(linkTitle == 'print') {
            css[i].disabled = false;
//            css[i].media = 'all';
         }
      }
      self.print();
   }
}

addDOMLoadEvent=(function(){var e=[],t,s,n,i,o,d=document,w=window,r='readyState',c='onreadystatechange',x=function(){n=1;clearInterval(t);while(i=e.shift())i();if(s)s[c]=''};return function(f){if(n)return f();if(!e[0]){d.addEventListener&&d.addEventListener("DOMContentLoaded",x,false);/*@cc_on@*//*@if(@_win32)d.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");s=d.getElementById("__ie_onload");s[c]=function(){s[r]=="complete"&&x()};/*@end@*/if(/WebKit/i.test(navigator.userAgent))t=setInterval(function(){/loaded|complete/.test(d[r])&&x()},10);o=w.onload;w.onload=function(){x();o&&o()}}e.push(f)}})();

addDOMLoadEvent(printCheck);