﻿var gAutoPrint = true; // Call print function
function PrintPage()
{
 if (document.getElementById != null)
 {
  var StyleSheet1 = '../css/RBStyles.css';
  var html = '<HTML dir='+PrintLang+'>\n';
  html += '\n<Head>\n';
  html += '\n<Title>'+PrintTitle+'</Title>\n';
  html += '\n<link rel=stylesheet rev=stylesheet href='+StyleSheet1+' type=text/css>\n';
  //html += '\n<link rel=stylesheet rev=stylesheet href='+StyleSheet2+' type=text/css>\n';
  html += '\n</Head>\n';
  html += '\n<BODY>\n';

  html += '\n<BODY>\n';
  html += '\n<table align=center border=0 cellspacing=0 cellpadding=0 height=0 width=594><tr><td valign=middle align=left><img src='+PrintHeader+' width=594 height=95 border=0 vspace=3></td></tr></table>\n';

  html += '\n<table align=center cellspacing=1 cellpadding=2 border=0 width=594 bgcolor=#B2C2D0><tr><td width="100%" bgcolor="#FFFFFF">\n';



/*  if (document.getElementsByTagName != null)
// Disable
  {
   var headTags = document.getElementsByTagName("");
   if (headTags.length > 0)
    html += headTags[0].innerHTML;
  }

*/




  
  var printReadyElem = document.getElementById("PrintReady");
  
  if (printReadyElem != null)
  {
	html += printReadyElem.innerHTML;

  	if (PrintLang=="ltr")
	{
	var regEx = new RegExp ("Printer Friendly", 'gi') ;
   	html = html.replace(regEx, '')

  	var regEx2 = new RegExp ("<IMG src=\"../images/prnt.gif\" align=left>", 'gi') ;
    html = html.replace(regEx2, '')
	}

  	if (PrintLang=="rtl")
	{
	var regEx = new RegExp ("طباعة الصفحة", 'gi') ;
   	html = html.replace(regEx, '')

  	var regEx2 = new RegExp ("<IMG src=\"../images/prnt.gif\" align=right>", 'gi') ;
    html = html.replace(regEx2, '')
	}

  }
  else
  {
   alert("There is nothing to Print");
   return;
  }


  html += '\n</td></tr></table>\n';
  html += '\n<table align=center border=0 cellspacing=0 cellpadding=0 height=0 width=594><tr><td valign=middle align=left><img src='+PrintFooter+' width=594 height=59 border=0 vspace=3></td></tr></table>\n';   
  html += '\n</BODY>\n';
  html += '\n</Html>\n';

  var printWin = window.open("","PrintPage");
  printWin.document.open();
  printWin.document.write(html);
  printWin.document.close();
  if (gAutoPrint)
   printWin.print();
 }
 else
 {
  alert("Your Browser Doesn't Support This Feature");
 }
}
