﻿
function PrintThisPage()
{ 
	var sOption='width=800,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('contentRight').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=");
	
/* Replace Size of div layers to print properly in IE6 THIS IS A TEMPORARY QUICK FIX, THIS NEEDS TO BE REDONE   */
//	if (navigator.userAgent.indexOf("MSIE 6.") != "-1") {
//		var re = /654px/gi;
//		var re2 = /MARGIN-LEFT: 15px/gi
//		var re3 = /<TABLE border=0>/gi
//		/*var re4 = /MARGIN-TOP: 0px/gi */
//		var re4 = / WIDTH: 674px/gi
//		var re5 = /<TABLE cellSpacing=0 cellPadding=0 border=0>/gi
//		var re6 = /PADDING-RIGHT: 15px/gi
//		var re7 = /PADDING-RIGHT: 20px/gi
//		var re8 = /PADDING-LEFT: 10px/gi
//		var re9 = /WIDTH: 390px/gi
//		var re10 = /WIDTH: 350px/gi
//		var re11 = /PADDING-LEFT: 27px/gi
//		var re12 = /WIDTH: 312px/gi
//		strContent = strContent.replace(re,"625px");
//		strContent = strContent.replace(re2,"MARGIN-LEFT: 5px");
//		strContent = strContent.replace(re3,"<TABLE border=0 width='580'>");
//		/*strContent = strContent.replace(re4,"MARGIN-TOP: 0px; width:315px");*/
//		strContent = strContent.replace(re4,"width:315px");
//		strContent = strContent.replace(re5,"<TABLE cellSpacing=0 cellPadding=0 border=0 width='580'>");
//		strContent = strContent.replace(re6,"PADDING-RIGHT: 0px");
//		strContent = strContent.replace(re7,"PADDING-RIGHT: 5px");// diesen ändern für produkt
//		strContent = strContent.replace(re8,"PADDING-LEFT: 0px");
//		strContent = strContent.replace(re9,"WIDTH: 300px");
//		strContent = strContent.replace(re10,"WIDTH: 300px");
//		strContent = strContent.replace(re11,"PADDING-LEFT: 5px");
//		strContent = strContent.replace(re12,"WIDTH: 300px");
//		
//	}
    var browser=navigator.appName;

	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)
	{
	  if (browser == "Microsoft Internet Explorer")
	  {
	    winprint.document.write("<LINK href='" + "../../" + document.getElementsByTagName('Link')[i].href + "' type='text/css' rel='stylesheet'>");
	  }
	  else 
	  {
	    winprint.document.write("<LINK href='" + document.getElementsByTagName('Link')[i].href + "' type='text/css' rel='stylesheet'>");
	  }
	}
 
//	styles = document.getElementsByTagName('Style');
//	for(i in styles)
//	{
//		winprint.document.write("<style type='text/css'>" + document.getElementsByTagName('Style')[i].innerHTML + "</style>");
//	}
	
    /* edited by dn */
    /* builds a new print-friendly html doc */
	
	winprint.document.write("<title>");
	winprint.document.write("Nestlé Nutrition");
	winprint.document.write("</title>");
	winprint.document.write("</head>");
	winprint.document.write("<body style=\"background-color:#FFFFFF; background-image: none;\" >");	
    winprint.document.write("<div style='float:right;'><img src=\"/Images/close_icon.gif\" width=26 height=26 style=\"cursor:hand;\" alt=\"Fenster schließen\" title=\"Fenster schließen\" onclick=javascript:window.close();></div>");
    winprint.document.write("<div style='float:right;'><img src=\"/Images/print_icon.gif\" width=26 height=26 style=\"cursor:hand;\" alt=\"Seite drucken\" title=\"Seite drucken\" onclick=window.print();></div>");
    winprint.document.write("<div>&nbsp;</div>");
    winprint.document.write(strContent);
	winprint.document.write("</body>");
	winprint.document.write("</html>");
	winprint.document.close();
	winprint.focus();
}		
	