function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getWindowHeight() {
  var windowHeight=0;
  if (typeof(window.innerHeight)=='number') {
    windowHeight=window.innerHeight;
  }
  else {
    if (document.documentElement&&
	document.documentElement.clientHeight) {
      windowHeight=
	document.documentElement.clientHeight;
    }
    else {
      if (document.body&&document.body.clientHeight) {
        windowHeight=document.body.clientHeight;
      }
    }
  }
  return windowHeight;
}

/* This function returns the position that the footer SHOULD have. It
   will be enforced by the length of the leftSideBar

   Where the footer's Y will be is calculated as follows: 

   When the footers Y position is already below its minY, it must have
   been pushed there by the body content. In this case return the true
   Y position. The result is that the leftSideBar height is equal to
   the bodyText height.

   When the footer's Y is below the minY it must be pushed down to the
   screen's edge. Again this is done by the height of leftSideBar.

   This logic works, and for eyes that have seen so many other ugly
   CSS/JS hacks, the parsimony of using only a single condition beers
   a whiff of beauty. But in fact, it's unconditional crap.
*/
   
function footerShouldY(obj)
{
  var windowHeight=getWindowHeight();
  if (windowHeight>0) {
    var minY=windowHeight - obj.offsetHeight;
    if(findPosY(obj) < minY)
      return minY;
  }
  return findPosY(obj);
}
function setFooter() {
  if (document.getElementById)  {
    var leftSideBar=document.getElementById('leftSideBar');
    var footer=document.getElementById('footer');
    var bodyText=document.getElementById('bodyText');
    leftSideBar.style.height=(footerShouldY(footer)-findPosY(leftSideBar))+'px';  
  } 
}

window.onload = function() {
  setFooter();
}

/* window.onresize = function() {
  setFooter();
  }  */
