// Printable Content Area Function - Telus Billing Template

var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printContent()
{
	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</HE' + 'AD>\n<BODY>\n';
		html += '<H2><img src="/communitypages_wa/images/CWPheader_main.gif" width="537" height="58" border="0" alt="communityWEBpage"></H2>';
				
		var printReadyElem = document.getElementById("printReady");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("This page has not been setup with a print version.");
			return;
		}
			
		html += '<p class="smalltext" style="border-top-width: 1px; border-top: solid;">Copyright © 2003 City of Vancouver</p>';
		
		html += '<p></p>' + '\n</BO' + 'DY>\n</HT' + 'ML>';

		// so print window has no movement
		// remove start anchors - leave link content 
		html = html.replace(/<a[^<]+href=[^<]+>/gi,"");
				
        // so print window has no movement
		// remove form buttons that perform action by hiding them from print view 
		html = html.replace(/<input[^<]submit[^<]>/gi,"");
		html = html.replace(/type=submit/gi,"type=hidden");
		html = html.replace(/type=button/gi,"type=hidden");
		html = html.replace(/type="submit"/gi,"type=hidden");
						
		// open the new window for print content
		var width='650';
    	var height='450';
		var printWin = window.open("", "printContent", "resizable=no,scrollbars=yes,width="+width+",height="+height+" ");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		// ensure print window has focus in case they already have an open window 
		printWin.focus();
		if (gAutoPrint) {
			printWin.print();
		}	
	}
	else
	{
		alert("The printable page feature is only available in modern browsers.");
	}
}