﻿//  autoPrint - Flag for whether or not to automatically call the print function)
function printControl(id, autoPrint)
{
	  if (autoPrint == null)
		autoPrint = true;
      if (document.getElementById != null)
      {
            var html = '<HTML>\n';
            html += '\n<HEAD>\n';
            if (document.getElementsByTagName != null)
            {
                  var headTags = document.getElementsByTagName('head');
                  for(var i=0;i<headTags.length;i++)
                        html += headTags[i].innerHTML;
//                  var scriptTags = document.body.getElementsByTagName('script');
//                       
//                  for(var i=0;i<scriptTags.length;i++)
//                        html += scriptTags[i].innerHTML;
            }
            html += '\n</HE' + 'AD>\n';
			html += '<BODY';
			if (autoPrint)
				html +=' onload="window.print(); window.close();"';
			html += '>\n';
			var printReadyElem = document.getElementById(id);
            if (printReadyElem != null)
            {
                html += printReadyElem.innerHTML;
            }
            else
            {
                  alert('Could not find the \''+id+'\' section in the HTML');
                  return;
            }
            html += '\n</BO' + 'DY>';
			html+='\n</HT' + 'ML>';
			var uniqueName = new Date();
            var windowName = 'Print' + uniqueName.getTime();
            var printWin = window.open('',windowName,'left=100,top=100');
            
            printWin.document.open();
            printWin.document.write(html);
            printWin.document.close();
            //loadStyles(printWin);
            
      }
      else
      {
            alert('Sorry, the print ready feature is only available in modern browsers.');
      }
}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();