//Funktion zur Korrektur der PNGs fuer IE
function correctPNG(){
	for(var i=0; i<document.images.length; i++){
		var img = document.images[i];
		var imgName = img.src.toUpperCase();
		if(imgName.substring(imgName.length-3, imgName.length) == "PNG"){
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			   + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}
if(document.all){
   window.attachEvent("onload", correctPNG);
}

//Funktion fuer Seitengroesse (Array mit page width, height und window width, height)
//Corecode - quirksmode.org
function getPageSize(){
   
	var xScroll, yScroll;	
	if (window.innerHeight && window.scrollMaxY) {	
        xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { 
        //Explorer Mac...wuerde auch in Explorer 6 Strict, Mozilla und Safari funktionieren
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	if(document.all || navigator.appName == "Opera"){
      yScroll = document.all.layout.offsetHeight;
    }
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		//alle Browser ausser Internet Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { 
		//Internet Explorer 6  im Strict Modus
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { 
		//andere Internet Explorer
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	//fuer kleine Seiten mit einer kleineren Hoehe als der sichtbare Bereich
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	//fuer kleine Seiten mit einer totalen Breite kleiner als der sichtbare Bereich
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function changeHeight(){
   var pageSize = getPageSize();
   if(pageSize[1]>pageSize[3]){
      var divHeight = pageSize[1];
   } else{
      var divHeight = pageSize[3];
   }
   document.getElementById("ebene01").style.height = divHeight+"px";
   document.getElementById("ebene02").style.height = divHeight+"px";
}


// Schrift ersetzen Hauptnavigation und Ueberschriften
function changeFont(){
   Cufon.replace('a.changeFont', {fontFamily: 'DIN', hover: true });
   Cufon.replace('h2', {fontFamily: 'DIN'});
   Cufon.replace('h3', {fontFamily: 'DIN'});
   Cufon.replace('span.hervorhebung', {fontFamily: 'DIN'});
}


window.onload = function(){
   changeHeight();
   changeFont();   
}
