//This function can be called when the print button on the bottom of a page is clicked
//It will open a new window with the content to be printed which can be marked by tags
//Start printcontent must be marked in the HTML page with <!-- $print$ -->
//Stop printcontent must be marked with <!-- /$print$ -->
//doc_id   -> The 'id' of the form tag of the HTML page.
//winTitle -> Can be used to specify a title for the printwindow. If empty, no title is displayed
function printClick(doc_id, winTitle)
{		
	//var printWindow = window.open("", "", "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=500,height=600,left=0,top=0");
	var printWindow = window.open();
	var docId = doc_id;
	var title = winTitle;
	var HTMLheader = "<head><TITLE>PATNET -- PrintVersion</TITLE><LINK href='/PATnetWebset/Style/style.css' rel='stylesheet' type='text/css'><LINK href='/PATnetWebset/Style/PATNET.css' rel='stylesheet' type='text/css'><LINK href='/PATnetWebset/Style/search.css' rel='stylesheet' type='text/css'></head>";
	var HTMLContent = docId.outerHTML;
	var docLength = HTMLContent.length;											
	var content = "";																	
	var beginTag = "$print$" ;				
	var endTag = "/$print$";				
	var startIndex;
	var endIndex;
	var endOfDoc = false
		
	printWindow.document.writeln("<HTML>");
	printWindow.document.writeln(HTMLheader);				
						
	while (!endOfDoc)
	{
		startIndex = HTMLContent.indexOf(beginTag);
		endIndex = HTMLContent.indexOf(endTag);				
					
		if ((startIndex != -1) && (endIndex != -1))
		{					
			//Content += HTMLContent.substr(startIndex+11, (endIndex-startIndex)-16);						
			var subcontent = HTMLContent.substr(startIndex+11, (endIndex-startIndex)-16);						
			//var regex = /href=\x22[A-Za-z0-9_./:(),']*\x22/g;						
			var regex = /href=\x22\S*\x22/g;
			subcontent = subcontent.replace(regex,"href='#'");						
			content += subcontent;
			HTMLContent = HTMLContent.substr(endIndex+12, docLength-endIndex);						
		}
		else 
		{
			endOfDoc = true;
		}					
	}																		
	printWindow.document.writeln("<table width='450' height='100%' cellspacing=0 cellpadding=0 border=0><tr valign='top'><td>");		
	//printWindow.document.writeln("<SPAN class='linkermarge' id='spnMarge'>" + title + "<BR><BR>");
	printWindow.document.writeln("<P class='LinkerMarge datesheadgrijs'>" + title + "</P>");
	printWindow.document.writeln(content);	
	//printWindow.document.writeln("Blaat");
	printWindow.document.writeln("</td></tr>");
	printWindow.document.writeln("<tr><td>");	
	printWindow.document.writeln("<table width='100%' border=0><tr>");
	printWindow.document.writeln("<td valign='top' align='left' width='50%'><A onclick='window.print();' href='#'><IMG height='20' alt='print this page' src='/patnetwebset/includes/images/printversie.gif' width='22' border='0'></A></td>");
	printWindow.document.writeln("<td align='right'><A onclick='window.close();' href='#'>close this window</A></td>");
	printWindow.document.writeln("</tr></table>");	
	printWindow.document.writeln("</td></tr></table>");
	printWindow.document.writeln("</HTML>");
	printWindow.location.reload(false); 						
}