function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else {
		elm['on' + evType] = fn;
	}
}
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			if((this.className =="menuparent") || (this.className =="menuparentclosed")){	
				this.className+=" sfhover menuparentsfhover";
			}else{
				this.className+=" sfhover";
			}
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover menuparentsfhover\\b"), "");
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
//if (window.attachEvent) window.attachEvent("onload", sfHover);

function init_ie6(){
  if (getBrowserName() == 'IE' && getBrowserVer() < 7) {
    pngRepair('.png');
  }
}

function pngRepair() {
  if (navigator.userAgent.indexOf("MSIE")!=-1) {
    for (i=0; i < document.getElementsByTagName("img").length; i++) {
      if (document.getElementsByTagName("img")[i].src.indexOf(".png")!=-1) {
        width = document.getElementsByTagName("img")[i].width;
        height = document.getElementsByTagName("img")[i].height;
        src = document.getElementsByTagName("img")[i].src;
        document.getElementsByTagName("img")[i].src="/fileadmin/templates/img/c.gif";
        document.getElementsByTagName("img")[i].height = height;
        document.getElementsByTagName("img")[i].width = width;
        document.getElementsByTagName("img")[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',sizingMethod='scale');";
      }
    }
  }
}

function postItPosition(){
	var postItHome = getElementsByClassName(document.getElementById("postit"), "div", "postitfoot");
	for(var i=0;i<=postItHome.length;i++){
		var pTag = postItHome[i].getElementsByTagName("p")[0];
		if(typeof(pTag) != 'undefined'){
			aTag = pTag.getElementsByTagName("a")[0];
			if(typeof(pTag) != 'undefined'){
				aTag.style.setAttribute("position", "relative", false);
			}
		}
	}
}

function getElementsByClassName(oElm, strTagName, oClassNames){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object"){
		for(var i=0; i<oClassNames.length; i++){
			arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames[i].replace(/-/g, "\-") + "(\s|$)"));
		}
	}
	else{
		arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames.replace(/-/g, "\-") + "(\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++){
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className)){
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function getBrowserName() {
    if (navigator.userAgent.indexOf("MSIE")!=-1) return 'IE';
    else if (navigator.userAgent.indexOf("Opera")!=-1) return 'Opera';
    else return 'unknown';
}

function getBrowserVer() {
    var sReturn = 'unknown';
    var sBrowser = getBrowserName();
    if (sBrowser == 'IE') {
        arrRes = navigator.userAgent.match(/MSIE (\d+)/);
        if (arrRes[1]) sReturn = arrRes[1];
    }
    if (sBrowser == 'Opera') {
        arrRes = navigator.userAgent.match(/Opera\/([0-9.]+)/);
        if (arrRes[1]) sReturn = arrRes[1];
    }
    return sReturn;
}
function closeBoxSlow(el){
	plusminus(el+'icon');
	Effect.toggle(el, 'blind',{ duration: 0.3 });
}
function closeBoxSlow2(el){
	plusminus2(el+'icon');
	Effect.toggle(el, 'blind',{ duration: 0.3 });
}
function plusminus(imgID){
	if(document.getElementById(imgID).getAttribute("src").indexOf("/fileadmin/templates/images/plus-blau.gif")!=-1){
		document.getElementById(imgID).setAttribute("src","/fileadmin/templates/images/minus-blau.gif");
	}else{
		document.getElementById(imgID).setAttribute("src","/fileadmin/templates/images/plus-blau.gif");
	}
}
function plusminus2(imgID){
	if(document.getElementById(imgID).getAttribute("src").indexOf("/fileadmin/templates/images/minus-blau.gif")!=-1){
		document.getElementById(imgID).setAttribute("src","/fileadmin/templates/images/plus-blau.gif");
	}else{
		document.getElementById(imgID).setAttribute("src","/fileadmin/templates/images/minus-blau.gif");
	}
}


//Passwortfeld auf Sicherheit prüfen

var nCrackrate = 1000000;		// Anzahl mÃ¶glicher Versuche das Passwort zu Knacken pro Sekunde
var nTreshholddays = 365 * 10000;	// Schwellwert, ab wann das Passwort als Sicher gilt
var nSteps = 10;		// Anzahl der Schritte, die im CSS angehangen werden

function contains(strText, strPattern)
{
	for (i = 0; i < strText.length; i++)
	{
		if (strPattern.indexOf(strText.charAt(i)) > -1) return true;
	}
	return false;
}

function checkPass(strPass, strId, strClassname, strTextId, aTexts)
{
	nCombinationCount = 0;
	
	strToCheck = "0123456789";			// Ã¼berprÃ¼fen ob Ziffern vormmen
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
	strToCheck = "abcdefghijklmnopqrstuvwxyz";	// Ã¼berprÃ¼fen ob kleine Buchstaben vorkommen
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
	strToCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";	// Ã¼berprÃ¼fen ob grosse Buchstaben vorkommen
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
	strToCheck = ",;:-_=+\|//?^&!.@$Â£#*()%~<>{}[]";// Ã¼bersprÃ¼fen ob Sonderzeichen vorkommen
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;

	var nDays = ((Math.pow(nCombinationCount, strPass.length) / nCrackrate) / 2) / 86400;	// Wieviele Tage benÃ¶tigt man?
	var nStrongness = Math.round(nDays / nTreshholddays * 100);				// StÃ¤rke errechnen
	if (nStrongness < (strPass.length * 5)) nStrongness += strPass.length * 5;		// ZeichenlÃ¤nge fÃ¼r StÃ¤rke berÃ¼cksichtigen
	if (nStrongness > 100) nStrongness = 100;						// Max 100% zulassen
	nStrongness = Math.round(nStrongness / (100 / nSteps));					// Max Schritte

	oId = document.getElementById(strId);
	oId.className = strClassname + "-" + nStrongness;

	otId = document.getElementById(strTextId);
	
	if (aTexts)
	{
		nKey = Math.round((aTexts.length - 1) / nSteps * nStrongness);
		otId.innerHTML = aTexts[nKey];
	}
}

	



