/* fixup.js - fixing height of too short main-content in most browsers */

function height_fixup () {

  // Silently skip older browsers, including Netscape 4, IE 4 and Opera 5/6
  if (! document.getElementById || (window.opera && !document.childNodes)) 
	return;

  // No need to do anything unless these are present in the document...
  var sc = document.getElementById("system-content");
  var cn = document.getElementById("content");
  
  if (sc && cn && cn.offsetHeight) {
	// Get supposed heights of window and document
	var max = window.innerWidth ? window.innerWidth : 1;
	var doc = document.documentElement;
	if (doc && doc.offsetHeight && max < doc.offsetHeight) {
	  max = doc.offsetHeight;
	}
	if (doc && doc.scrollHeight && max < doc.scrollHeight) {
	  max = doc.scrollHeight;
	}
	// Get height of tallest div
	if (document.getElementsByTagName) {
	  var divs = document.getElementsByTagName("div");
	  for (i=0; i<divs.length; i++) {
		if (divs[i].offsetHeight && max < divs[i].offsetHeight) {
		  max = divs[i].offsetHeight;
		}
	  }
	}
	// Set the height of the content-div accordingly
	if (cn.offsetHeight < max) {
	  var extra_padding = navigator.userAgent.match(/KHTML/i) ? 200 : 50;
	  cn.style.height = max + extra_padding + 'px';
      if (document.all && navigator.userAgent.match(/MSIE [56]/))
        cn.style.marginBottom = '-15px';
	}
  }
  // Opera only: ad placement
  if (window.opera) {
	var srtc = document.getElementById('system-right-container');
	if (srtc && srtc.style) {
	   srtc.style.minWidth = '995px';
	}
  }
};

window.onload = height_fixup;


