﻿
function PrintThisPage()
{ 
	var sOption='width=810,height=700,toolbar=no,location=no,directories=no,status=no,';
	sOption+='menubar=no,scrollbars=yes,resizable=no,copyhistory=no,left=100,top=25';
	var strContent = "";
	
    // load page content 
	try
	{
		strContent = document.getElementById('printContent').innerHTML;	
	}
	catch(err)
	{
		
	}
	
/* Remove in body script to circumvent document.write overwriting content in firefox */
	var sTmpContent		= "";
	var scanComplete	= false;
	var i = 0, j = 0;

	while(!(scanComplete))
	{
		scanComplete = true;

		i = strContent.toLowerCase().indexOf("<script");
		j = strContent.toLowerCase().indexOf("</script>");
		if((-1 != i)&&(-1 != j))
		{
			sTmpContent =  strContent.substring(0, i - 1);
			sTmpContent += strContent.substring(j + 9, strContent.length);
			strContent   = sTmpContent;
			
			scanComplete = false;
		}
	}


/* Replace Links (href) */
	var replacehref=/ href=/gi;
	strContent = strContent.replace(replacehref," dontprinthref=");

/* Replace alt  */
	var replacehref=/ alt=/gi;
	strContent = strContent.replace(replacehref," dontprintalt=");

/* Replace title  */
	var replacehref=/ title=/gi;
	strContent = strContent.replace(replacehref," dontprinttitle=");
	
	var winprint = window.open('','PrintPopup',sOption);
	winprint.document.open();
	
	winprint.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
	winprint.document.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
	winprint.document.write("<head>");
	
	var styles,i;
	styles = document.getElementsByTagName('Link');
	for(i in styles)
	{
	    winprint.document.write("<LINK href='" + document.getElementsByTagName('Link')[i].href + "' type='text/css' rel='stylesheet'>");
	}
	
/* builds a new print-friendly html doc */
	winprint.document.write("<title>");
	winprint.document.write("Alete NaturNes");
	winprint.document.write("</title>");
	winprint.document.write("</head>");
	winprint.document.write("<body style=\"background-image: none;\" >");
	winprint.document.write("<div class=\"printpage\" >");
    winprint.document.write("<div style='float:right;'><img src=\"/Includes/Images/close_icon.gif\" width=26 height=26 style=\"cursor:pointer;\" alt=\"Fenster schließen\" title=\"Fenster schließen\" onclick=\"javascript:window.close();\"></div>");
    winprint.document.write("<div style='float:right;'><img src=\"/Includes/Images/print_icon.gif\" width=26 height=26 style=\"cursor:pointer;\" alt=\"Seite drucken\" title=\"Seite drucken\" onclick=\"javascript:window.print();\"></div>");
    winprint.document.write("<div style='height:26px;'>&nbsp;</div>");
    winprint.document.write(strContent);
    winprint.document.write("</div>");
	winprint.document.write("</body>");
	winprint.document.write("</html>");
	winprint.document.close();
	winprint.focus();
}		
	