// Position eines Elements ermitteln
function getpos( el, pos ) {
    var xpos = ypos = 0;
    var o_el = el;

    if ( document.getElementById ) {
        if ( !el ) return( [0,0] );
        xpos = el.offsetLeft;
        ypos = el.offsetTop;
        while( (el = el.offsetParent) != null ) {
            xpos += el.offsetLeft;
            ypos += el.offsetTop;
        }
    } else {
        return( [0,0] );
    }

    switch(pos) {
        case "tl":
        xpos = xpos;
        break;
        case "tr":
        xpos = xpos+o_el.offsetWidth;
        break;
        case "bl":
        ypos = ypos+o_el.offsetHeight;
        break;
        case "br":
        xpos = xpos+o_el.offsetWidth;
        ypos = ypos+o_el.offsetHeight;
        break;
        default:
        break;
    }

    return ([xpos,ypos]);
}

// Login: Challenge-Response-Authentifikation ausfuehren
function cmslogin(f) {
    if ( f.elements['username'].value.length && f.elements['password'].value.length ) {
        f.elements['response'].value = MD5(f.elements['password'].value);
        f.elements['password'].value = "";
        f.submit();
    }
}

function cmslogoff(f) {
    f.submit();
}

function setwin() {
    var dw = document.body.offsetWidth;
    while (isNaN(dw))
    {
        dw = dw.substr(0,dw.length-1);
    }
    difw = dw - document.body.clientWidth;
    win_x = document.body.scrollWidth+difw;

    var dh = document.body.offsetHeight;
    while (isNaN(dh))
    {
        dh = dh.substr(0,dh.length-1);
    }
    difh = dh - document.body.clientHeight;
    win_y = document.body.scrollHeight+difh;
    scr_x = screen.width;
    scr_y = screen.height;
    if ( scr_x < win_x ) win_x = scr_x-8;
    if ( scr_y < win_y ) win_y = scr_y-32;
    window.resizeTo(win_x+6,win_y+48);
}
