// JavaScript Document
var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;

function DHTML_init() {

 if (window.opera) {
     OP = 1;
 }
 if(document.getElementById) {
   DHTML = 1;
   DOM = 1;
 }
 if(document.all && !OP) {
   DHTML = 1;
   MS = 1;
 }
if(document.layers && !OP) {
   DHTML = 1;
   NS = 1;
 }
}


function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
  {
    if(a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) 
	{
	  a.disabled = true;
      if(a.getAttribute("title") == title) 
	  {
			a.disabled = false;
			cookieManager.setCookie("style", title, 365);
      }
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) 
	{return a.getAttribute("title");}
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) {return a.getAttribute("title");}
  }
  return null;
}

var cookie = cookieManager.getCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();

setActiveStyleSheet(title);

var gAutoPrint = false; // Flag for whether or not to automatically call the print function

function printPage()
{
        if (document.getElementById != null)
        {
                var html = "<HTML lang=\"de\">\n<HEAD>\n";

                if (document.getElementsByTagName != null)
                {
                        var headTags = document.getElementsByTagName("head");
                        if (headTags.length > 0)
						{
							var titletag = document.title;							
							var printStylesheet = document.getElementById("pstylesh");
							html += "<title>"+titletag+"</title>";
							html += "<link rel=\"stylesheet\" href=\"";
							html += printStylesheet.href;
							html += "\" type=\"text/css\" media=\"print\" >";
							html += "<link rel=\"stylesheet\" href=\"";
							html += printStylesheet.href;
							html += "\" type=\"text/css\" media=\"screen\" >";
						}
                }
				
				html += "\n</HEAD>\n<BODY><div id=\"content\">\n";
                var printReadyElem = document.getElementById("content");
				/*var printLogo 	=    document.getElementById("logo");
				if(printLogo != null)
				{
								html += "<div id=\"logo\">";
								html += printLogo.innerHTML;
								html += "</div>";
				}*/				
                if (printReadyElem != null)
                {
                                html += printReadyElem.innerHTML;
                }
                else
                {
                        return;
                }

                html += "\n</div></BO" + "DY>\n</HT" + "ML>";

                var printWin = window.open("","","");
                printWin.document.open();
                printWin.document.write(html);
                printWin.document.close();
                if (gAutoPrint)
                        printWin.print();
        }
        else
        {
                alert("Diese Funktion wird von Ihrem Browser leider nicht unterstützt.");
        }
}
