﻿   //resize an iframe to it's contents
   function resizeFrame(frameName)
    {
      //find the height of the internal page
      var the_height=
        document.getElementById(frameName).contentWindow.
          document.body.scrollHeight;
    
      //change the height of the iframe
      document.getElementById(frameName).height=
          the_height;

    //find the width of the internal page
      var the_width=
        document.getElementById(frameName).contentWindow.
          document.body.scrollWidth;
    
      //change the width of the iframe
      document.getElementById(frameName).width=
          the_width;   
    }
    
    
    function printWindow(windowName)
    {
         var printContent = document.getElementById(windowName);
         height = printContent.scrollHeight;
         width = printContent.scrollWidth;
         var left = parseInt((screen.availWidth/2) - (width/2));
         var top = parseInt((screen.availHeight/2) - (height/2));         
         var windowUrl = 'about:blank';
         var uniqueName = new Date();
         var windowName = 'Print' + uniqueName.getTime();
         var printWindow = window.open(windowUrl, windowName, 'location=No, width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
         printWindow.document.write('<HTML><HEAD>');
         printWindow.document.write('<link href="styles/common.css" rel="stylesheet" type="text/css" media="all" />');
         //printWindow.document.write('<link href="styles/custom.css" rel="stylesheet" type="text/css" />');   
         printWindow.document.write('<style type="text/css">body {background: none;} html {background: none;}</style>');
         printWindow.document.write('</HEAD><BODY>');
         printWindow.document.write(printContent.innerHTML);
         printWindow.document.write('</BODY></HTML>');
         printWindow.document.close();
         printWindow.focus();
         printWindow.print();
         printWindow.close();
    }
