function getPrintWinContent(links, scripts, size, title, content) {
  var linksText = "";
  if (links != null) {
    for (var i = 0; i < links.length; i++) {
      var link = "http://" + window.location.host + links[i];
      linksText += '<link type="text/css" rel="stylesheet" href="' + link + '"/>\n';
    }
  }  
  var scriptsText = "";
  if (scripts != null) {
    for (var i = 0; i < scripts.length; i++) {
      var script = "http://" + window.location.host + scripts[i];
      scriptsText += '<script type="text/javascript" src="' + script + '">' + '</scr' + 'ipt>\n';
    }
  }  
  return "<html><head><title>Print Results</title>\n" +
         linksText + "\n" +
         scriptsText + "\n" +
         "<style type='text/css' media='print'>\n" +
         "@page port {size: portrait;}\n" +
         "@page land {size: landscape;}\n" +
         ".portrait {page: port;}\n" +
         ".landscape {page: land;}\n" +
         "</style>\n" +
         "<script type='text/javascript'>\n" + 
         "function setTimer() { \n" + 
         "setTimeout('doPrint()', 10);\n" + 
         "}\n" +
         "function doPrint() {\n" + 
         "window.print();\n" +
         "window.close();\n" + 
         "}\n" +
         "</scr" + "ipt>\n" +
         "</head>\n" +
          "<body class='" + size + "' style='padding-left:20px;font-family:arial,helvetica,sans-serif;font-size: 10pt;' " +
          "onload='javascript:setTimer();'>" +
          "<div style='text-align:center;color:#000000;font-size: 18px;margin-bottom: 10px;'>" + title + "</div>\n" +
          content + "\n" +
         "</body></html>";
}

function printDiv(links, scripts, size, title, divId) {
  var childWin = window.open("about:blank","childWin","resizable=1, scrollbars=1, toolbar=0, statusbar=0, " + 
                                           "width=800,height=600,location=no,menubar=no,toolbar=no,status=no,directories=no");
  childWin.document.open();
  childWin.document.write(getPrintWinContent(links, scripts, size, title, document.getElementById(divId).innerHTML));
  childWin.document.close();
}

function doPrint(title, divId) {
  var linksArray = new Array();
  linksArray[0] = '/new/modules/node/node.css';   
  linksArray[1] = '/new/modules/system/defaults.css';   
  linksArray[2] = '/new/modules/system/system.css';   
  linksArray[3] = '/new/modules/user/user.css';   
  linksArray[4] = '/new/sites/dennispriebe.com/themes/burnt/style.css';     
  printDiv(linksArray, null, 'portrait', title, divId);
}

