function adjustLayout()
{
  if (self.innerWidth) {
    var requestUri = window.location.pathname;
    var bodyWidth = self.innerWidth;
    switch (window.location.pathname) {
      case '/':
        var sidebarWidth = 220;
        break;
      case '/news':
      case '/impressum':
        var sidebarWidth = 260;
        break;
      default:
        var sidebarWidth = 160;
        break;
    }
    bodyMinWidth = 560 + sidebarWidth;
    if (bodyWidth < bodyMinWidth) {
      document.body.style.width = bodyMinWidth + 'px';
      document.getElementById('navi').style.position = 'absolute';
      document.getElementById('sidebar').style.left = (bodyMinWidth - (sidebarWidth + 2)) + 'px';
      document.getElementById('sidebar').style.right = 'auto';
    } else {
      document.body.style.width = 'auto';
      document.getElementById('navi').style.position = 'fixed';
      document.getElementById('sidebar').style.left = 'auto';
      document.getElementById('sidebar').style.right = '20px';
    }
  }
}

document.addEventListener("DOMContentLoaded", adjustLayout, false);
window.addEventListener("resize", adjustLayout, false);

