﻿function passPos(ch_div, pa_div) {
    pa_div_top = getRect_top(pa_div);
    document.getElementById(ch_div).style.top = pa_div_top + 'px';
}

function passPos2Cols(ch_div, pa_div1, pa_div2) {
    pa_div1_top = getRect_top(pa_div1) + 150;  // hoehe der buttonleiste addiert
    pa_div2_top = getRect_top(pa_div2) + 150;

    if (pa_div1_top > pa_div2_top) {
        document.getElementById(ch_div).style.top = (pa_div1_top + 50) + 'px';
    } else {
        document.getElementById(ch_div).style.top = (pa_div2_top + 50) + 'px';
    }
}

function getRect_top(id, win) {
    if (!document.getElementById) return null;
    var o = typeof id == 'string' ? document.getElementById(id) : id;
    if (!o) return null;

    var rect = { top: 0, left: 0, width: 0, height: 0 };
    rect.height = o.offsetHeight;
    rect.width = o.offsetWidth;

    while (o) {
        rect.top += parseInt(o.offsetTop);
        rect.left += parseInt(o.offsetLeft);
        o = o.offsetParent;
    }
    return rect.top;
}



function showSubMenu(menuId) {


    hideSubMenu();

    var subMenu = document.getElementById("ulSubMenu" + menuId);

    if (subMenu && subMenu.childNodes[1]) {

        // subMenu.style.zindex = 100;
        subMenu.style.display = "block";
        document.getElementById("placeHolder").style.display = "none";
    } // if

} // method showSubMenu

function hideSubMenu() {


    var elements = document.getElementsByTagName("ul");


    document.getElementById("placeHolder").style.display = "block";

    for (var i = 0; i < elements.length; i++) {

        if (elements[i].id.indexOf("ulSubMenu") >= 0) {

            elements[i].style.display = "none";
            //elements[i].style.zindex = 0;
        }
    } // for
} // hideSubMenu


function setVisibility(divName, visible) {
    document.getElementById(divName).style.display = visible ? "block" : "none";
 } // setVisibility


// Check whether 'Return'-key is pressed in a text box and executes
// click-event of passed button in this case.
function checkForEnter(e,execButtonId) {
    if (window.event) {
        e = window.event;
    }
    if ((e.which || e.keyCode) && (e.which == 13 || e.keyCode == 13)) {
        document.getElementById(execButtonId).click();
        return true;
    }
    return false;          
} // function


function openWindowCentered(url, name, height, width, features) {
    var top     = screen.height && height   < screen.height ? (screen.height - height)  / 2 : 0;
    var left    = screen.width  && width    < screen.width  ? (screen.width - width)    / 2 : 0;

    return window.open(url, name, "top=" + top + ",left=" + left + ",width=" + width + ",height=" + height + "," + features);
}

function prodThumbActive(elem) {
    var thumbs = document.getElementById('prodThumbs').getElementsByTagName('a');
    for (var i = 0; i < thumbs.length; i++) {
        thumbs[i].className = '';
    }
    elem.className='active';
}
