/* ################################################## */
getCSS();
zs = null;

function setCSS(title) {
    if (zs == null){
        setActiveStyleSheet(title);
        createCookie("aiticonFontSize", title, 1);
    } else {
        alert('Bei dieser Seite ist die Schriftgrößenumschaltung deaktiviert.\n\nUm diese Seite mit einer anderen Schriftgröße darzustellen, wählen Sie Ihre bevorzugte Schriftgröße auf einer anderen Seite und kehren Sie dann auf diese Seite zurück.');
    }
}

function getCSS() {
    fs = readCookie("aiticonFontSize");
    if (fs != null) setActiveStyleSheet(fs);
}

/* ################################################## */
function setActiveStyleSheet(title) {
    var i, a, main;
    for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
            a.disabled = true;
            if(a.getAttribute("title") == title) a.disabled = false;
        }
    }
}
/* ################################################## */
function createCookie(name,value,days) {
    if (navigator.cookieEnabled == true) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires = " + date.toGMTString();
        } else {
            expires = "";
        }
        document.cookie = name + "=" + value + expires + "; path=/";
    }  
}
function readCookie(name) {
    if (navigator.cookieEnabled == true) {
        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;
    } else {
        return null;
    }
}
/* ################################################## */
function d_support() {
    return (document.layers ||
    document.all ||
    document.getElementById);
}
function d_style(id) {
    if (document.layers) {
        return d_obj(id);
    } else if (document.all || document.getElementById) {
        return d_obj(id).style;
    }
}
function d_obj(id) {
    if (document.layers) {
        return document.layers[id];
    } else if (document.all) {
        return document.all[id];
    } else if (document.getElementById) {
        return document.getElementById(id);
    } 
}
/* ################################################## */

function checkform_psendform() {

    fname = 'psendform';

    d_style('emails_missing').display = 'none';
    d_style('emails_error').display = 'none';
    d_style('emailr_missing').display = 'none';
    d_style('emailr_error').display = 'none';

    d_style('emails').borderColor = bBorderColor;
    d_style('emails').backgroundColor = bBackgroundColor;
    d_style('emailr').borderColor = bBorderColor;
    d_style('emailr').backgroundColor = bBackgroundColor;

    if (!document.forms[fname].emails.value) {
    
        error = 1;
        d_style('emails_missing').display = 'block';
        d_style('emails').borderColor  = rBorderColor;
        d_style('emails').backgroundColor = rBackgroundColor;
    
    } else {

        if (!(document.forms[fname].emails.value.search(/[@.]/) >= 0)
         || !(document.forms[fname].emails.value.search(/.+@..+\...+/) >= 0)
         || !(document.forms[fname].emails.value.length >= 8)) {

            error = 1;
            d_style('emails_error').display = 'block';
            d_style('emails').borderColor  = rBorderColor;
            d_style('emails').backgroundColor = rBackgroundColor;
        }
    }

    if (!document.forms[fname].emailr.value) {
    
        error = 1;
        d_style('emailr_missing').display = 'block';
        d_style('emailr').borderColor  = rBorderColor;
        d_style('emailr').backgroundColor = rBackgroundColor;
    
    } else {
        if (!(document.forms[fname].emailr.value.search(/[@.]/) >= 0)
         || !(document.forms[fname].emailr.value.search(/.+@..+\...+/) >= 0)
         || !(document.forms[fname].emailr.value.length >= 8)) {
            error = 1;
            d_style('emailr_error').display = 'block';
            d_style('emailr').borderColor  = rBorderColor;
            d_style('emailr').backgroundColor = rBackgroundColor;
        }
    }

    if ( error == 1 ) {

        d_style('box_2col_74').paddingBottom = "1px"; /* fix for IE 6 */
        d_style('box_2col_74').paddingBottom = "0px"; /* both lines needed! */

        error = 0;
        return false;

    } else {
        return true;
 
    }
}
/* ################################################## */
function send_hover(mode) {

    if (mode == 1) {

        d_style('send').backgroundColor = '#ce1a00';
        d_style('send').backgroundImage = 'url(/assets/images_system/icon_send_hover.gif)';
        d_style('send').color = 'white';

    } else {

        d_style('send').backgroundColor = '#f5d1cc';
        d_style('send').backgroundImage = 'url(/assets/images_system/icon_send.gif)';
        d_style('send').color = '#ce1a00';

    }

}
/* ################################################## */
function openwindow(t_url, sbars, width, height, bnav) {
    var wx, wy;
    if (bnav == 1) {
        bnav = "menubar=yes,toolbar=yes,";
    } else {
        bnav = "";
    }
    if (sbars == 1) {
        scrollb = "scrollbars=yes,";
    } else {
        scrollb = "";
    }
    if (screen.availWidth >= width) {
        wx = (screen.availWidth - width) / 2;
    } else {
        wx = 0;
    }
    if (screen.availHeight >= height) {
        wy = (screen.availHeight - height) / 2;
    } else {
        wy = 0;
    }
    return window.open(t_url, '', scrollb + bnav + 'width=' + width + ',height=' + height + ',left=' + wx + ',top=' + wy + ', resizable=yes');
}