﻿function GetPrintVersion()
	{
		if (document.getElementById != null)
		{
			var html = '<HTML>\n<HEAD>\n';
			if (document.getElementsByTagName != null)
			{
				var headTags = document.getElementsByTagName("head");
				if (headTags.length > 0)
					html += headTags[0].innerHTML;
			}
			html += '\n<script language = "javascript">';
			html += '\n function printWindow()\n{';
			html += '\nwindow.print();\n';			
			html += '\nvar printReadyEle = document.getElementById("printContent");\nvar shtml = \'<HTML>\\n<HEAD>\\n\';\nif (document.getElementsByTagName != null)\n{\nvar sheadTags = document.getElementsByTagName("head");\nif (sheadTags.length > 0)\nshtml += sheadTags[0].innerHTML;\n}\nshtml += \'</HEAD>\\n<BODY>\\n\';\nif (printReadyEle != null)\n{\n';
			html += 'shtml += \'<form name = frmform1>\';\nshtml += printReadyEle.innerHTML;\n}\nshtml += \'\\n</form>\\n</BODY>\\n</HTML>\';\nvar printWin1 = window.open();\nprintWin1.document.open();\nprintWin1.document.write(shtml);\nprintWin1.document.close();\nprintWin1.print();';
			html += '\n}\n</script>\n</HEAD>\n<BODY>\n';

			var printReadyElement1 = document.getElementById("ctl00_ContentPlaceHolder1_div1");
			var printReadyElement2 = document.getElementById("ctl00_ContentPlaceHolder1_div2");
			if (printReadyElement1 != null)
			{
				html += '<form name = frmform>';
				html += '\n<div id = printContent>\n<table cellspacing = 0 cellpadding = 0 width = 100% class=grayBG>\n<tr>\n<td ><input type ="button" value ="Print" class = CommonTextBoxStyle  onclick ="printWindow();"> </td>\n</tr>\n</table>\n';
				html += '<TABLE cellSpacing=0 cellPadding=10 width=100% border=0>\n<TR>\n<TD class=tblArticleHeadingBG>\n';
				html += printReadyElement1.innerHTML;
				html += '\n</td>\n</tr>\n</table>';
				html += '\n<table cellspacing = 0 cellpadding = 0 width = 100%>\n<tr class=grayBG>\n<td>&nbsp;</td>\n</td>\n</tr>\n</table>\n';
				if(printReadyElement2 != null)
				{
					html += '<TABLE cellSpacing=0 cellPadding=10 width=100% border=0 class=ArticlePublisherBackgroundWhite align = center>\n<TR>\n<TD>\n';
					html += printReadyElement2.innerHTML;
					html += '\n</td>\n</tr>\n</table>\n\n';
					
				}
				else
				{
					alert("This offer doesn't contains any content! Sorry for inconvenience");
					return;
				}
			}
			else
			{
				alert("Could not find the header of the offer");
				return;
			}

			html += '\n</div>\n</form>\n</BODY>\n</HTML>';
                
			var printWin = window.open();
			printWin.document.open();
			printWin.document.write(html);
		}
		else
		{
			alert("The print ready feature is only available if you are using an browser. Please update your browswer.");
		}
	}	
