
Drupal.theme.adjustHeight = function () {
  var maxH = $(document).height() - 120;
  var rcH =   $('#wrapper #container #center #squeeze .right-corner .left-corner').height();
  var sbrH =   $('#wrapper #container #sidebar-right').height();

  if ( rcH > sbrH ) maxH = ( rcH > maxH ) ? rcH : maxH;
  else maxH = ( sbrH > maxH ) ? sbrH : maxH;

  if ( typeof document.body.style.maxHeight == "undefined" ) { // es handelt sich wohl um den IE < 7
    $('#wrapper #container #center #squeeze .right-corner').css({ height:  (maxH + 35) + 'px' });
    $('#wrapper #container #center #squeeze .right-corner .left-corner').css({ height: maxH + 'px' });
    $('#wrapper #container #sidebar-right').css({ height: (maxH + 31) + 'px' });
    $('#wrapper #container #sidebar-left').css({ height: (maxH + 35) + 'px' });

  } else {
    $('#wrapper #container #center #squeeze .right-corner').css({ minHeight:  (maxH + 35) + 'px' });
    $('#wrapper #container #center #squeeze .right-corner .left-corner').css({ minHeight: maxH + 'px' });
    $('#wrapper #container #sidebar-right').css({ minHeight: (maxH + 31) + 'px' });
    $('#wrapper #container #sidebar-left').css({ minHeight: (maxH + 35) + 'px' });
  }
};



$(window).load(function() {
  Drupal.theme.adjustHeight();

  $(window).resize(function() {
    Drupal.theme.adjustHeight();
  });
});


Drupal.toggleFieldset = function(fieldset) {
  if ($(fieldset).is('.collapsed')) {
    // Action div containers are processed separately because of a IE bug
    // that alters the default submit button behavior.
    var content = $('> div:not(.action)', fieldset);
    $(fieldset).removeClass('collapsed');
    content.hide();
    content.slideDown( {
      duration: 'fast',
      easing: 'linear',
      complete: function() {
        Drupal.collapseScrollIntoView(this.parentNode);
        this.parentNode.animating = false;
        $('div.action', fieldset).show();
      },
      step: function() {
        // Scroll the fieldset into view
        Drupal.collapseScrollIntoView(this.parentNode);
      }
    });
  }
  else {
    $('div.action', fieldset).hide();
    var content = $('> div:not(.action)', fieldset).slideUp('fast', function() {
      $(this.parentNode).addClass('collapsed');
      this.parentNode.animating = false;
    });
  }
  Drupal.theme.adjustHeight();
};