function confirmAction (question, uri)
{
  if (confirm (question))
  {
    document.location = uri;
  }
  return false;
}


// --------------------------------------------------------------------------------------------------------------------------------
// MainLayout
// --------------------------------------------------------------------------------------------------------------------------------
function MainLayout (globalName,
                     mainDiv,
                     header,
                     userInfo,
                     issueMenu,
                     pageMenu,
                     tableMiddle,
                     pageContent,
                     pageNavigation,
                     footer)
{
    this.globalName = globalName;

    // setting all relevant layout elements
    this.mainDiv        = document.getElementById(mainDiv);
    this.header         = document.getElementById(header);
    this.userInfo       = document.getElementById(userInfo);
    this.issueMenu      = document.getElementById(issueMenu);
    this.pageMenu       = document.getElementById(pageMenu);
    this.tableMiddle    = document.getElementById(tableMiddle);
    this.pageContent    = document.getElementById(pageContent);
    this.pageNavigation = document.getElementById(pageNavigation);
    this.footer         = document.getElementById(footer);

    // initiate constant layout widths and heights
    this.MAINwidth = 950;
    this.HEADERheight = 100;
    this.USERINFOheight = 19;
    this.ISSUEMENUheight = 24;
    this.TABLEMIDDLEwidth = 5;
    this.PAGEMENUwidth = 330;
    this.PAGENAVIGATIONheight = 16;
    this.FOOTERheight = 25;

    if (window.addEventListener)
    {
        window.addEventListener("resize", new Function("event", this.globalName + ".resizeEvent(event);"), false);
    }
    else if (window.attachEvent)
    {
        window.attachEvent("onresize", new Function("event", this.globalName + ".resizeEvent(event);"));
    }
}

MainLayout.prototype.updateLayout = function()
{
    // get width and height of whole viewable browser area
    //var width;
    var height;

    if(typeof(window.innerWidth) == "number")
    {
        //width = window.innerWidth;
        height = window.innerHeight;
    }
    else if(document.documentElement && (document.documentElement.clientWidth))
    {
        //width = document.documentElement.clientWidth;
        height = document.documentElement.clientHeight;
    }
    else if(document.body && document.body.clientWidth)
    {
        //width = document.body.clientWidth;
        height = document.body.clientHeight;
    }

    height = height - 5;

    // compute all widths and heights of the layout elements
    this.mainDiv.style.width = this.MAINwidth + "px";
    this.mainDiv.style.height = height + "px";

    this.header.style.width = this.MAINwidth + "px";
    this.header.style.height = this.HEADERheight + "px";

    this.footer.style.width = this.MAINwidth + "px";
    this.footer.style.height = this.FOOTERheight + "px";

    this.userInfo.style.width = this.MAINwidth + "px";
    this.userInfo.style.height = this.USERINFOheight + "px";

    this.issueMenu.style.width = this.MAINwidth + "px";
    this.issueMenu.style.height = this.ISSUEMENUheight + "px";

    this.pageNavigation.style.height = this.PAGENAVIGATIONheight + "px";

    /* Berechne die Hoehe, die fuer Menue und Page-Content zur Verfuegung steht */
    var mainHeight =   height
                     - this.elementHeight(this.header)
                     - this.elementHeight(this.userInfo)
                     - this.elementHeight(this.issueMenu)
                     - this.elementHeight(this.pageNavigation)
                     - this.elementHeight(this.footer);

    var menuEntries = document.getElementById("menuEntries");

    if (mainHeight < 400)
    {
       menuEntries.style.borderCollapse = "collapse";
       this.pageMenu.style.fontSize = "9px";
    }
    else if (mainHeight < 500)
    {
       menuEntries.style.borderCollapse = "collapse";
       this.pageMenu.style.fontSize = "11px";
    }
    else if (mainHeight < 600)
    {
       menuEntries.style.borderCollapse = "separate";
       this.pageMenu.style.fontSize = "12px";
    }
    else
    {
       menuEntries.style.borderCollapse = "separate";
       this.pageMenu.style.fontSize = "13px";
    }

    this.pageMenu.style.width = this.PAGEMENUwidth + "px";

    /* Loeschen der aktuell gesetzten Menue-Hoehe zur Neubestimmung der Hoehe */
    this.pageMenu.style.height = "";

    /* Neubestimmung der Menue-Hoehe, falls Menue-Hoehe die Browser-Hoehe uebersteigt */
    var pageMenuHeight = this.elementHeight(this.pageMenu);

    /* Setzen der Menue-Hoehe - Maximum aus Main-Height oder der Menue-Hoehe */
    this.pageMenu.style.height = this.max(mainHeight, pageMenuHeight) + "px";

    this.tableMiddle.style.width = this.TABLEMIDDLEwidth + "px";
    this.tableMiddle.style.height = this.max(mainHeight, pageMenuHeight) + "px";

    this.pageContent.style.width = (  this.MAINwidth
                                    - this.elementWidth(this.pageMenu)
                                    - this.elementWidth(this.tableMiddle)
                                    - 20) + "px";

    /* Setzen der Page-Content-Hoehe - Maximum aus Main-Height oder der Menue-Hoehe */
    this.pageContent.style.height = this.max(mainHeight, pageMenuHeight) + "px";

    this.pageNavigation.style.width = (  this.MAINwidth
                                      - this.elementWidth(this.pageMenu)
                                      - this.elementWidth(this.tableMiddle)) + "px";
};

MainLayout.prototype.resizeEvent = function(event)
{
    this.updateLayout();
};

MainLayout.prototype.elementWidth = function(element)
{
    if (element.clientWidth)
    {
        // Gecko
        return element.clientWidth;
    }
    else
    {
        // Internet Explorer
        return element.offsetWidth;
    }
};

MainLayout.prototype.elementHeight = function(element)
{
    if (element.clientHeight)
    {
        // Gecko
        return element.clientHeight;
    }
    else
    {
        // Internet Explorer
        return element.offsetHeight;
    }
};

MainLayout.prototype.max = function(a, b)
{
   if (a > b) return a;
   else return b;
}
