var oPrintWindow;
var oPrintDiv;
var oPrintStatus;

function printdiv(sDIVName) {


var tmpDoc
var i = 0;


oPrintDiv = document.getElementById(sDIVName);
if (!oPrintDiv) {
	alert( "Es wurde kein Druckbereich '" + sDIVName + "' auf der Seite gefunden.");
}
else {

	//oPrintWindow = open("about:blank","Ausdruck","height=200,width=480,status=yes,toolbar=no,menubar=no,location=no");
	oPrintWindow = open(document.URL,"Ausdruck","height=200,width=480,status=yes,toolbar=no,menubar=no,location=no");
	
	do {
		tmpDoc = oPrintWindow.document;
		i++;
	} while( !(tmpDoc.body));
	
	setTimeout('BuildPrintPage()',1000);
	return true;
}

}
function BuildPrintPage() {

var sPrefix = "Melville-Schellmann ";
var sSeitentitel = document.title;
var sTitel = "";
var sHTMLCode = "";

// Seitenüberschrift erstellen
if(sSeitentitel.search(RegExp(sPrefix,"g"))==0){
	sTitel = sSeitentitel.substr(sPrefix.length, sSeitentitel.length - sPrefix.length);
}
else {
	sTitel = sSeitentitel;
}

sHTMLCode += "<script language='JavaScript' type='text/JavaScript'>function window.onafterprint(){alert('Close');window.close();}</script>";
sHTMLCode += "<div id='Status' style='position:absolute; width:auto; height:auto; z-index:1; left: 28px; top: 25px; background-color: #FFFFFF; layer-background-color: #FFFFFF;'></div>"
sHTMLCode += "<p style='font-family: verdana, helvetica, arial;font-size: 12pt;border: 1px solid #000000; margin-bottom: 0px;'><img src='bilder/logos/logo_melville-schellmann.gif' width='170' height='40' align='absmiddle'> " + sTitel + "</p>";
sHTMLCode += "<p style='font-family: verdana, helvetica, arial;font-size: 8pt;border-right-width: 1px;border-left-width: 1px;border-right-style: solid;border-left-style: solid;border-right-color: #000000;border-left-color: #000000;border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #000000;margin-top: 0px;'>URL: " + document.URL + "</p>";
sHTMLCode += oPrintDiv.innerHTML;


	oPrintWindow.document.body.innerHTML = sHTMLCode;
	oPrintStatus = oPrintWindow.document.getElementById("Status");
	setTimeout('StartPrint()',1000);
	return true;
}
function StartPrint() {
	oPrintWindow.print();
	window.setTimeout("closeprint(4);", 5000);
}
function closeprint(lSekunden){
if(lSekunden==0){
	oPrintWindow.close();
}
else {
//	oPrintStatus.innerHTML = "<p>Fenster wird geschlossen (" + lSekunden + " Sek.)...</p>";
	lSekunden--;
	window.setTimeout("closeprint("+lSekunden+");", 1000);
	return true;
}
}