onload = function() {
    var s = readCookie("fs");
    if (s != null) {
        document.body.style.fontSize = "1." + (s - 1) + "em";
    }
    $(function() {
        $("#example_3").accessNews({
            headline: "Organisation",
            speed: "slow",
            slideBy: 1
        });
    });
    $(function() {
        $("#example_4").accessNews({
            headline: "Organisation",
            speed: "slow",
            slideBy: 1
        });
    });
    $(function() {
        $("#example_5").accessNews({
            headline: "Organisation",
            speed: "slow",
            slideBy: 1
        });
    });
    $(function() {
        $("#example_6").accessNews({
            headline: "Organisation",
            speed: "slow",
            slideBy: 1
        });
    });
    window.onmousedown = wcl;
    if (document.all) {
        document.onmousedown = wcl;
    }
    var h3 = document.getElementsByTagName("ul");
    var h3h = 0;
    var ergid = [];
    for (i = 0; i < h3.length; i++) {
        if (h3[i].parentNode.parentNode.parentNode.id == "th_sm_l") {
            ergid.push(i);
        }
    }
    for (i = 0; i < Math.ceil(ergid.length / 3); i++) {
        h3h = 0;
        var start = i * 3;
        var ende = (i + 1) * 3;
        for (j = start; j < ende; j++) {
            var ind = ergid[j];
            if (h3[ind].parentNode.clientHeight > h3h) {
                h3h = h3[ind].parentNode.clientHeight;
            }
        }
        for (j = start; j < ende; j++) {
            var ind = ergid[j];
            h3[ind].parentNode.style.height = h3h + 40 + "px";
        }
    }
}
function wcl(e) {
    var t = null;
    var ausblenden = true;
    if (window.event) {
        t = window.event.srcElement;
    }
    if (e&&e.target) {
        t = e.target;
    }
    while (t != null && t.tagName != "BODY") {
        if (t.className == "aejkw") {
            ausblenden = false;
            break;
        }
        t = t.parentNode;
    }
    if (ausblenden == true || t == null) {
        showkm(10);
    }
}
function aejsearchkw(v) {
    showkm(10);
    document.getElementById('ipa').value = v; 
    document.forms['ksbsuchform'].submit();
}
function showkm(n) {
    var ws = sethora_achievement_windowsize();
    for (i = 0; i < 5; i++) {
        if (document.getElementById("aejkw_" + i)) {
            document.getElementById("aejkw_" + i).style.display = "none";
        }
    }
    if (n != 10) {
        document.getElementById("aejkw_" + n).style.left = (ws.width/2-380)+"px";
        document.getElementById("aejkw_" + n).style.display = "block";
    }
}
function Go(select) {
    var wert = select.options[select.options.selectedIndex].value;
    if (wert == "leer") {
        select.form.reset();
        return;
    }
    else {
        location.href = wert;
    }
}
function setfn(s) {
    document.body.style.fontSize = "1." + (s - 1) + "em";
    createCookie("fs", s, 365);
}
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}
function sethora_achievement_windowsize() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return { width: myWidth, height: myHeight };
}
function tl_show() {
    document.documentElement.style.overflow = "hidden"; 
    var d = document.createElement("div");
    d.id = "sethora_achievement_lightboxes";
    var ws = sethora_achievement_windowsize();
    d.style.position = "fixed";
    d.style.zIndex = "99999999999999999999999999";
    d.style.width = "100%";
    d.style.height = "100%";
    d.style.top = "0px";
    d.style.left = "0px";
    d.style.overflow = "hidden";
    d.style.textAlign = "center";
    d.onclick = function() {
        if (document.getElementById('sethora_achievement_lightboxes')) document.body.removeChild(document.getElementById('sethora_achievement_lightboxes'));
        if (document.getElementById('sethora_achievement_lightboxes2')) document.body.removeChild(document.getElementById('sethora_achievement_lightboxes2'));
        document.documentElement.style.overflow = "auto";
        document.body.style.marginRight = '0px';
    }

    var e = document.createElement("div");
    e.id = "sethora_achievement_lightboxes2";
    e.style.position = "fixed";
    e.style.zIndex = "99999999999999999999999998";
    e.style.backgroundColor = "#000";
    e.style.width = "100%";
    e.style.height = "100%";
    e.style.opacity = "0.5";
    e.style.overflow = "hidden";
    e.style.top = "0px";
    e.style.left = "0px";
    e.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
    e.onclick = function() {
        if (document.getElementById('sethora_achievement_lightboxes')) document.body.removeChild(document.getElementById('sethora_achievement_lightboxes'));
        if (document.getElementById('sethora_achievement_lightboxes2')) document.body.removeChild(document.getElementById('sethora_achievement_lightboxes2')); 
        document.documentElement.style.overflow = "auto";
        document.body.style.marginRight = '0px';
    }

    var f = document.createElement("div");
    f.id = "lb";
    f.innerHTML = document.getElementById("schaltboxtext2").innerHTML;
    d.appendChild(f);
    document.body.appendChild(e);
    document.body.appendChild(d);
}
/**
*	pflichtfeldcheck
*
*	�berpr�ft, ob die Pflichtfelder in einem Formular ausgef�llt wurden
*
*	@param	string	f	formularname
*	@param	string	c	pflichtfeldname
*	@return	boolean		Ausgef�llt, oder nicht
*/
function pflichtfeldcheck(f, c) {
    var senden = true;
    var failed_fields = "";
    var radionames = new Array();
    var el = document.forms[f].elements;
    for (i = 0; i < el.length; i++) {
        if (el[i].className == c) {
            el[i].style.backgroundColor = "#fff";      
        }
    }
    for (i = 0; i < el.length; i++) {
        if (el[i].className == c && el[i].value == "" || el[i].className.lastIndexOf(c) != -1 && el[i].value == "") {
            el[i].style.backgroundColor = "#ff6464";
            failed_fields += " - " + el[i].previousSibling.previousSibling.innerHTML + "\n";
    	    if (el[i].previousSibling.previousSibling)
    	    	el[i].previousSibling.previousSibling.style.fontWeight = "bold";
            senden = false;
        }
        else if (el[i].className == c && el[i].type=="radio")
        {
            if (!radionames.contains(radionames, el[i].name))
	           radionames.push(el[i].name);  
        }
    }
    
    for (i = 0; i < radionames.length; i++)
    {
	flag = false;
        for (a = 0; a < document.getElementsByName(radionames[i]).length; a++)
        {
            if (document.getElementsByName(radionames[i])[a].checked) flag = true;
        }    
        if (!flag)
        {
            for (a = 0; a < document.getElementsByName(radionames[i]).length; a++)
            {
            	document.getElementsByName(radionames[i])[a].nextSibling.style.color = "#ff0000";
            }        	
            senden = false;
        }
        else
        {
            for (a = 0; a < document.getElementsByName(radionames[i]).length; a++)
            {
            	document.getElementsByName(radionames[i])[a].nextSibling.style.color = "#000";
            }   
        }
    }
    
    if (!senden) {
        alert("Bitte überprüfen Sie alle rot markierten Eingabefelder im Formular, und füllen Sie diese ggf. richtig aus.\nBetroffene Felder:\n\n"+failed_fields);
    }
    return senden;
}

var httpRequest = createHttpRequestObject();

function createHttpRequestObject()
{
    var req;
    
    if (window.XMLHttpRequest)
        req = new XMLHttpRequest();
    else if (window.ActiveXObject)
        req = new ActiveXObject("Microsoft.XMLHTTP");
    
    return req;
}

Array.prototype.contains = function(mArray, mValue) {
    for (var i = 0; i < mArray.length; i++) {
        if (mArray[i]==mValue)
            return true;
    }
    return false;
}
