// equal_column_height.js
// Cross-Browser.com & SitePoint.com - Equal Column Height Demo

if (document.getElementById || document.all) { // minimum dhtml support required
	document.write("<"+"script type='text/javascript' src='./javascript/x_core.js'><"+"/script>");
	document.write("<"+"script type='text/javascript' src='./javascript/x_event.js'><"+"/script>");
	document.write("<"+"style type='text/css'>#footer{visibility:hidden;}<"+"/style>");
	window.onload = winOnLoad;
}
function winOnLoad()
{
  var ele = xGetElementById('left_column');
  if (ele && xDef(ele.style, ele.offsetHeight)) { // another compatibility check
    adjustLayout();
    xAddEventListener(window, 'resize', winOnResize, false);
  }
}
function winOnResize()
{
  adjustLayout();
}
function adjustLayout()
{
  // Get content heights
  /*var cHeight = xHeight('center_column_content');
  var lHeight = xHeight('left_column_content');
  var rHeight = xHeight('right_column_content'); */
  var cHeight = xHeight('center_column');
  var lHeight = xHeight('left_column');
  var rHeight = xHeight('right_column'); 
  //window.alert("cheight:" + cHeight + "   lHeight:" + lHeight +  "   rHeight:" + rHeight ); 
  

  // Find the maximum height
  var maxHeight = Math.max(cHeight, Math.max(lHeight, rHeight)); 
  //window.alert("maxHeight:" + maxHeight ); 
  
  // only way this is working, freezes up otherwise..
  //var maxHeight_plus_1 = maxHeight++;
  //window.alert("maxHeight_plus_1:" + maxHeight_plus_1 ); 
 
  // Assign maximum height to all columns
  xHeight('center_column', maxHeight );
  xHeight('right_column', maxHeight  );
  xHeight('left_column', maxHeight  );


  // Show the footer
  xShow('footer');
}
