// Javascript specific to pages w/o a sidebar/3rd column


// 11/2006 - IE7 in quirks (compat) mode recognizes max-width but does not implement it
function readIEVersion(){
 var ua=navigator.userAgent;
 var IEOffset = ua.indexOf("MSIE ");
 return (IEOffset>-1) ? parseFloat(ua.substring(IEOffset + 5, ua.indexOf(";", IEOffset))) : 0;
}


function maxWidthIE()
{
  div = "BodyContent";
  maxwidth = 622;
  // also check for IE7 in quirks mode:
  if(document.getElementById(div).style.maxWidth&&
       !(readIEVersion()>6&& (document.compatMode.indexOf('BackCompat')>-1))
     )
  {
    // do nothing for browsers that support 'max-width'
    return;
  }
  // ok, now handle IE (or other browsers) that don't support
  // max-width
  if(document.getElementById(div).scrollWidth > maxwidth)
  {
    document.getElementById(div).style.width = maxwidth;
  }
  else
  {
    document.getElementById(div).style.width = "auto";
  }
}

// by Pau@YellowPencil.com and Scot@YellowPencil.com
// feel free to delete all comments except for the above credit
// http://www.paulbellows.com/getsmart/balance_columns/column.js
function setTall() {
	if (document.getElementById) {

    // if the expected divs do not exist, do not continue
    if(!document.getElementById('BodyContent')||!document.getElementById('NavColumn')){ return; }


		// the divs array contains references to each column's div element.  
		// Replace 'center' 'right' and 'left' with your own.  
		// Or remove the last one entirely if you've got 2 columns.  Or add another if you've got 4!
		var divs = new Array(document.getElementById('NavColumn'), document.getElementById('BodyContent'));
		
		// Let's determine the maximum height out of all columns specified
		var maxHeight = 0;
		for (var i = 0; i < divs.length; i++) {
			if (divs[i].offsetHeight > maxHeight) maxHeight = divs[i].offsetHeight;
		}
		
		// Let's set all columns to that maximum height
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.height = maxHeight + 'px';

			// Now, if the browser's in standards-compliant mode, the height property
			// sets the height excluding padding, so we figure the padding out by subtracting the
			// old maxHeight from the new offsetHeight, and compensate!  So it works in Safari AND in IE 5.x
			if (divs[i].offsetHeight > maxHeight) {
				divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
			}
		}
		// now set the bottom fade on the sidebar column
                var bf = new Array(document.getElementById('bodyFooter'))
		if(bf[0])
		{
			//var bottomTop = maxHeight - 90;
			var bottomTop = maxHeight;
			//alert(bottomTop);
			bf[0].style.top = bottomTop + 'px';
			//alert(sbf[0].style.top);
		}
	}
}


addOnLoadEvent(function() {
	maxWidthIE();
	setTall();
});

addOnResizeEvent(function() {
	maxWidthIE();
	setTall();
});


