// Flash einbinden
var flashVersion = 0;
function getFlashVersion() {
    var maxFlashVersion = 25;
    var minFlashVersion = 6;
    var agent = navigator.userAgent.toLowerCase(); 
    // NS3 needs flashVersion to be a local variable
    if (((agent.indexOf("mozilla/3") != -1) && (agent.indexOf("msie") == -1)) || ((agent.indexOf("msie") != -1) && (agent.indexOf("mac") != -1))) {
        flashVersion = 0;
        return flashVersion;
    }
   
    // NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
    if (navigator.plugins != null && navigator.plugins.length > 0) {
        var flashPlugin = navigator.plugins['Shockwave Flash'];
        if (typeof flashPlugin == 'object') { 
            for (var i = maxFlashVersion; i >= minFlashVersion; i--) {
                if (flashPlugin.description.indexOf(i + '.') != -1) {
                    flashVersion = i;
                    break;
                }
            }
        }
    }
    // IE4+ Win32:  attempt to create an ActiveX object using VBScript
    else if ((agent.indexOf("msie") != -1) && (parseInt(navigator.appVersion) >= 4) && (agent.indexOf("win") != -1) && (agent.indexOf("16bit") == -1)) {
        var doc = '<scr' + 'ipt language="VBScript"\> \n';
        doc += 'On Error Resume Next \n';
        doc += 'Dim obFlash \n';
        doc += 'For i = '+maxFlashVersion+' To '+minFlashVersion+' Step -1 \n';
        doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
        doc += '   If IsObject(obFlash) Then \n';
        doc += '      flashVersion = i \n';
        doc += '      Exit For \n';
        doc += '   End If \n';
        doc += 'Next \n';
        doc += '</scr' + 'ipt\> \n';
        document.write(doc);
    } else flashVersion = -1;
    return flashVersion;
}
function insertFlashObject(id,src,width,height,name,bgcolor,imgsrc) {
    if (bgcolor.length == 0) bgcolor = '#ffffff';
    var canDo=0;
    if (getFlashVersion() >= 6) canDo = 1;
    if (canDo!=1) {
        if (imgsrc && imgsrc.length > 0) {
            document.write('<img src="'+imgsrc+'" border="0" alt="" />');
        }
    } else {
        document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" align=""');
        if (id.length > 0) document.write(' id="'+id+'"');
        if (name.length > 0) document.write(' name="'+name+'"');
        document.write('>\n');
        document.write('<param name="movie" value="'+src+'" />');
        document.write('<param name="menu" value="false" />');
        document.write('<param name="quality" value="high" />');
        document.write('<param name="scale" value="noborder" />');
        document.write('<param name="wmode" value="transparent" />');
        document.write('<param name="bgcolor" value="'+bgcolor+'" />');
        if ((id.length == 0) && (name.length > 0)) id = name;
        document.write('<embed src="'+src+'" menu="false" quality="high" scale="noborder" bgcolor="'+bgcolor+'" width="'+width+'" height="'+height+'" name="'+id+'" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent"></embed>');
        document.writeln('</object>');
    }
}
// Druckansicht
function showPrint(css) {
    header = document.getElementsByTagName("head")[0];
    var myLink = document.createElement("link");
    var linkRel = document.createAttribute("rel");
    var linkType = document.createAttribute("type");
    var linkHref = document.createAttribute("href");
    linkRel.nodeValue = "stylesheet";
    linkType.nodeValue = "text/css";
    linkHref.nodeValue = css;
    myLink.setAttributeNode(linkRel);
    myLink.setAttributeNode(linkType);
    myLink.setAttributeNode(linkHref);
    header.appendChild(myLink);
    return false;
}
// Cookie auslesen
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
}
// Cookie setzen
function setCookie(name, value) {
    var expiration = new Date();
    var sevenDays = expiration.getTime() + (7 * 24 * 60 * 60 * 1000);
    expiration.setTime(sevenDays);
    var curCookie = name + "=" + escape(value) + ";expires=" + escape(expiration.toGMTString()) + ";";
    document.cookie = curCookie;
}
// Schrift vergrößern
function increaseFontsize() {
    value = getCookie("fontsize");
    if (value) {
        if (value < 2) {
            value = Math.abs(value) + 0.05;
        }
    } else {
        value = 0.625;
    }
    setCookie("fontsize",value);
    var idelement = document.getElementsByTagName("body")[0];
    idelement.style.fontSize = value + "em";
}
// Schrift verkleinern
function decreaseFontsize() {
    value = getCookie("fontsize");
    if (value) {
        if (value > 0.1) {
            value = value - 0.05;
        }
    } else {
        value = 0.625;
    }
    setCookie("fontsize",value);
    var idelement = document.getElementsByTagName("body")[0];
    idelement.style.fontSize = value + "em";
}
// Schrift auf Normalgröße setzen
function normalFontsize() {
    var idelement = document.getElementsByTagName("body")[0];
    idelement.style.fontSize = "0.625em";
    setCookie("fontsize","0.625");
}
// Schriftgröße initialisieren
function initFontsize() {
    value = getCookie("fontsize");
    if (!value) {
        value = "0.625";
    }
    var idelement = document.getElementsByTagName("body")[0];
    idelement.style.fontSize = value + "em";
}
// Stylesheet wechseln
function changeStyle(sheet) {
    setCookie("sheet",sheet);
    document.location.reload();
}
// Vorgabewert eines Formularfelds löschen
function clearField (thisfield, placeholder) {
    if (thisfield.value == placeholder) { thisfield.value = ''}
}
// gewähltes Stylesheet bestimmen und laden
value = getCookie("sheet");
if (value) {
    document.write("<link rel='stylesheet' type='text/css' media='screen' href='" + value + "' />");
}
