globalDoc = null;
nodiveng = false;

function printnewwindow(url) {
     // Print all information 
     
	if (url.length > 5) {
		window.open(url,'', '');
		return;
	}

	var content = "content";
	var a, i, allstyles, stylesstr, repl;
	var infobox_value = "";

	//	Inhalt auslesen
	if(document.getElementById("IFRAME")) {
		var content_value = document.getElementById('IFRAME').contentWindow.document.body.innerHTML;	
	} else {
		var content_value = document.getElementById(content).innerHTML;	
	}
	var content_headline = document.getElementsByTagName("H1")[0].innerHTML;
	content_headline = "<h1>" + content_headline + "</h1>";

	
	//	Content überarbeiten
	content_value = content_value.replace( /<a href=".*?" class="historylink">.*?<\/a>/i, '');	

	//	Head auslesen
	var head_value = document.getElementsByTagName("head")[0].innerHTML;	
	head_value = "";		
 
	//	JavaScript-Aufrufe eliminieren
	repl = new RegExp('<script.*?</script>', 'gi');
	content_value = content_value.replace(repl, ' ');
	repl = 'setTimeout("resizeIFrame()",2000);';
	content_value = content_value.replace(repl, ' ');
	repl = /width="100%"/gi;
	content_value = content_value.replace(repl, 'width="97%"');

	//	Hinzufügen der Headline
	content_value = content_headline + content_value;
//alert(content_value);

	repl = new RegExp('<script.*?</script>', 'gi');
	head_value = head_value.replace(repl, ' ');
 
	//	Öffnen eines neuen leeren Fensters
	var printdoc = window.open('','', '');
	printdoc.document.open();

 
	//	Hinzufügen des HTML-Headers
	printdoc.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n');
 	printdoc.document.write('<html>\n<head>\n');

	//	Abschluss des HTML-Heads
  	printdoc.document.write(head_value);
  	printdoc.document.write('<style>\n');
  	printdoc.document.write('img {border:0px;}\n');
  	printdoc.document.write('font, a, td, p {font-family: Arial; font-size:12px;}\n');
  	printdoc.document.write('.listehead {font-family: Arial; font-size:16px; font-weight:bold;}\n');
  	printdoc.document.write('h1 {font-family: Arial; font-size:16px; font-weight:bold;}\n');
  	printdoc.document.write('h2 {font-family: Arial; font-size:14px; font-weight:bold;}\n');
  	printdoc.document.write('</style>\n');
	printdoc.document.write('</head>\n');
	printdoc.document.write('<body>\n');
	printdoc.document.write(printBody(content_value, infobox_value, document.location.href));
	printdoc.document.write('</body></html>');
	 
	// Explorer Bug de putain de merdde
	globalDoc = printdoc;
	setTimeout ( "wasteTime()", 3000 );
}

function wasteTime() {
  if(globalDoc ) {
    if (globalDoc.document) {
  	   globalDoc.document.close();
  	}
	globalDoc.focus();    

	if (nodiveng) {
		divs= globalDoc.document.getElementsByTagName("div") ;
		for (i = 0; i < divs.length; i++ )  {

			attr = divs[i].className;
			if (attr != null) {
				if(attr.match(/eng/)) {
                 
                 divs[i].style.marginLeft="0px";
                 divs[i].style.paddingLeft="0px";
              
                }
			}
		}
	}
  }
}

  /*
   * Funktion geht mit Firefox 2.0.
   */
function printBody(content, infobox, url) {
var currentTime = new Date();
var month =  currentTime.getMonth() + 1 ;
var day = currentTime.getDate();
var year = currentTime.getFullYear();

return  (
//'<div style="margin-left:90px;margin-right:100px;" >' +  "\n" +
'<div style="margin-left:10px;margin-right:10px;" >' +  "\n" +
'<div id="containerprint">' +  "\n" +
'<div id="headerprint">' +  "\n" +
'<div style="float:left"><p><a href="javascript:window.print();">> Drucken</a></p></div>' +  "\n" +
'<div style="float:right"><p><a href="javascript:window.close();">> Fenster schlie&szlig;en</a></p></div>' +  "\n" +
'</div><br><br>' +  "\n" +
'<div id="contentprint">' +  "\n" + content +  "\n" + "</div></div></div>"); 
}

function printBodyFirefox(content, infobox, url) {
var currentTime = new Date();
var month =  currentTime.getMonth() + 1 ;
var day = currentTime.getDate();
var year = currentTime.getFullYear();

return  (
'<div style="margin-left:90px;margin-right:100px;" >' +  "\n" +
'<div id="containerprint">' +  "\n" +
'<div id="headerprint">' +  "\n" +
'<div style="float:left"><p><a href="javascript:window.print();">> Drucken</a></p></div>' +  "\n" +
'<div style="float:right"><p><a href="javascript:window.close();">> Fenster schlie&szlig;en</a></p></div>' +  "\n" +
'</div>' +  "\n" +
'<div id="contentprint">' +  "\n" +

 content +  "\n" +
//'<div style="float:left; width:100%"><p><strong>test</strong><br>'+  "\n" +
//'Löffelstraße 22&minus;24<br>'+  "\n" +
//'70597 Stuttgart / Germany</p>'+  "\n" +
//' '+  "\n" +
//'<p>Telefon: +49/(0)711/7682-0<br>'+  "\n" +
//'Fax: +49/(0)711/7682-184<br>'+  "\n" +
//'E-Mail: info@suedwestmetall.de</p>'+  "\n" +
//''+  "\n" +
//''+  "\n" +
// '<p>Quelle:' + url + '</p>'+  "\n" +
//''+  "\n" +
//'</div></div></div>'); 
'</div></div>'); 
}
  
