/* JS- FIle */

// IEPNGfix
if (document.all && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule) {
	document.styleSheets[0].addRule('#content'  , 'behavior: url(/fileadmin/ethik/sources/iepngfix.htc)');
}

// home - hover tool 
function highlight(category) {
	var elements2 = document.getElementById('navigation').getElementsByTagName("li");
	for (var j=0;j<elements2.length;j++) {
		if (elements2[j].className.indexOf(category) != -1) {
			elements2[j].className = elements2[j].className+' active';
		}
	}
}

function noHighlight() {
	for(i=0;i<(arguments.length);i++) {
		var category = arguments[i];
		var elements2 = document.getElementById('navigation').getElementsByTagName("li");
		for (var k=0;k<elements2.length;k++) {
			if (elements2[k].className.indexOf('active') != -1) {
				elements2[k].className = elements2[k].className.substring(0,elements2[k].className.indexOf('active'));
			}
		}
	}
}


/* dynamisch posititonierter footer */
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	// gueltig fuer folgende domains
	var validFooterDomainsString = "i-c-h.at, i-c-h.modulo.at";
	var validFooterSubomainsString = "*.i-c-h.at, *.i-c-h.modulo.at";

	
	if(((validFooterDomainsString.indexOf( window.location.hostname ) != -1 ) && ( validFooterDomainsString.charAt(validFooterDomainsString.indexOf( window.location.hostname )-1) == ' '))  //wenn die domain oben angegeben ist (ohne stern davor) 
	  	|| ((validFooterSubomainsString.indexOf( window.location.hostname.substr(window.location.hostname.indexOf('.')+1) ) != -1 )  && ( validFooterSubomainsString.charAt(validFooterSubomainsString.indexOf( window.location.hostname.substr(window.location.hostname.indexOf('.')) )-1) == '*')  )) { //wenn host eine sub ist und oben *.host angegeben ist
		if (document.getElementById) {
			var windowHeight = getWindowHeight();
			if (windowHeight > 0) {
				// container gesamthoehe ueber dem footer (id) eintragen
				var contentHeight = document.getElementById('container').offsetHeight + document.getElementById('header').offsetHeight + document.getElementById('header-navigation').offsetHeight;
				var footerElement = document.getElementById('footer');
				var footerHeight  = footerElement.offsetHeight;
				if (windowHeight - (contentHeight + footerHeight) >= 0) {
					footerElement.style.position = 'absolute';
					footerElement.style.top = (windowHeight - footerHeight) + 'px';
				}
				else {
					footerElement.style.position = 'static';
				}
			}
		}
	}
}


window.onload = function() {
	setFooter();
}
window.onresize = function() {
	setFooter();
}

