﻿/*
    Copyrights 2009 KANN Software
*/

function RecalcLayout()
{
    CenterX("paneMain");
    
    RecalcHeight();
//    RecalcWidth();
}

function Center(objectID)
{
    var height1 = 500;
    var width1 = 900;
    
    if (window.innerHeight)
    {
        // netscape
        height1 = window.innerHeight;
        width1  = window.innerWidth;
    }
    else if (document.body && document.body.offsetHeight)
    {
        // z.B. IE 5
        height1 = document.body.offsetHeight;
        width1  = document.body.offsetWidth;
    }
    else
    {
        // neuere browser
        height1 = document.documentElement.clientHeight;
        width1  = document.documentElement.clientWidth;
    }

    var o = document.getElementById(objectID);
    var oStyle = o.style;
    
    var posY = Math.round((height1 - o.offsetHeight)/2);
    var posX = Math.round((width1  - o.offsetWidth)/2);
    
    oStyle.position = "absolute";
    oStyle.top  = posY+"px"; 
    oStyle.left = posX+"px"; 
}

function CenterX(objectID)
{
    var width1 = 700;
    
    if (window.innerWidth)
    {
        // netscape
        width1  = window.innerWidth;
    }
    else if (document.body && document.body.offsetWidth)
    {
        // z.B. IE 5
        width1  = document.body.offsetWidth;
    }
    else
    {
        // neuere browser
        width1  = document.documentElement.clientWidth;
    }

    var o = document.getElementById(objectID);
    var oStyle = o.style;
    
    var posX = Math.round((width1  - o.offsetWidth)/2);
    
    oStyle.position = "absolute";
    oStyle.left = posX+"px"; 
}

function RecalcHeight()
{
    var height1 = 500;
    
    if (window.innerHeight)
    {
        // netscape
        height1 = window.innerHeight;
    }
    else if (document.body && document.body.offsetHeight)
    {
        // z.B. IE 5
        height1 = document.body.offsetHeight;
    }
    else
    {
        // neuere browser
        height1 = document.documentElement.clientHeight;
    }
    
    var height = height1;
    if (height < 400)
    {
        height = 400;
    }
    
    height -= (80 + 14);   // Rand 
    
    document.getElementById("paneMain").style.height = height + "px"; 
    document.getElementById("paneMenu").style.height = height-48 + "px"; // Rand + Tabs
    document.getElementById("paneContent").style.height = height-48 + "px"; // Rand + Tabs

}

function RecalcWidth()
{
    var width1 = 700;
    
     if (window.innerWidth)
    {
        // netscape
        width1 = window.innerWidth;
    }
    else if (document.body && document.body.offsetWidth)
    {
        // z.B. IE 5
        width1 = document.body.offsetWidth;
    }
    else
    {
        // neuere browser
        width1 = document.documentElement.clientWidth;
    }

    var main = document.documentElement;
    var widthNavigation = document.getElementById("m_navigationMenu").offsetWidth;
    
    var width = (width1 - widthNavigation - 0);
    if (width < 50)
    {
        width = 50;
    }

    width -= 14;    // Ränder abziehen
    var client = document.getElementById("m_client");
    var scrollbarWidth = 20;    //client.offsetWidth - client.clientWidth;
    if (scrollbarWidth < 0)
    {
        scrollbarWidth = 0;
    }
    
    var o = client.childNodes[0];
    if (o != null && o.style)
    {
        if (scrollbarWidth > 0)
            o.style.width = width-scrollbarWidth + "px";    // Platz für Scrollbar
    }
//    else
////    {
//        alert("bingo");
//    }
//    

    document.getElementById("m_client").style.width = width + "px";  
}