var gAutoPrint = true; // Flag for whether or not to automatically call the print function
var sPrintMsg="Sorry, the print ready feature is only available in modern browsers.";
var sPrtMsgError= "Could not find the printReady section in the HTML";

function printTheArea(sArea)
{
	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</HEAD>\n<BODY>\n';
		
		var printReadyElem = document.getElementById(sArea);
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert(sPrtMsgError);
			return;
		}
			
		html += '\n</BODY>\n</HEAD></HTML>';
		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert(sPrintMsg);
	}
}


function printSpecial()
{
	printTheArea("printarea");
}

