// This debug function displays plain-text debugging messages in a
// special box at the end of a document. It is a useful alternative
// to using alert(  ) to display debugging messages.

function debug(msg) {
    // If we haven't already created a box within which to display
    // our debugging messages, then do so now. Note that to avoid
    // using another global variable, we store the box node as
    // a proprty of this function.
    if (!debug.box) {
        // Create a new &lt;div&gt; element
        debug.box = document.createElement("div");
        // Specify what it looks like using CSS style attributes
        debug.box.setAttribute("style", 
                               "background-color: white; " +
                               "font-family: monospace; " +
                               "border: solid black 3px; " +
                               "padding: 10px;");
        
        // Append our new &lt;div&gt; element to the end of the document
        document.body.appendChild(debug.box);
        
        // Now add a title to our &lt;div&gt;. Note that the innerHTML property is
        // used to parse a fragment of HTML and insert it into the document.
        // innerHTML is not part of the W3C DOM standard, but it is supported
        // by Netscape 6 and Internet Explorer 4 and later. We can avoid 
        // the use of innerHTML by explicitly creating the &lt;h1&gt; element,
        // setting its style attribute, adding a Text node to it, and 
        // inserting it into the document, but this is a nice shortcut.
        debug.box.innerHTML = "Debugging Output";
    }
    
    // When we get here, debug.box refers to a &lt;div&gt; element into which
    // we can insert our debugging message.
    // First create a &lt;p&gt; node to hold the message.
    var p = document.createElement("p");
    // Now create a text node containing the message, and add it to the &lt;p&gt;
    p.appendChild(document.createTextNode(msg));
    // And append the &lt;p&gt; node to the &lt;div&gt; that holds the debugging output
    debug.box.appendChild(p);
}

var in_init = false;

function init()
{
  if (!document.getElementById)
  {
  	return;
  }
  
  // debug("In init function");
    
  if (in_init)
  {
  	return;
  }
  
  in_init = true;
  var left = document.getElementById("left_column");
  var right = document.getElementById("right_column");
  var center = document.getElementById("main_column");

  var left_height = 0;
  var right_height = 0;
  var center_height = 0;
  
  center_height = center.offsetHeight;

  // debug("init center column height=" + center_height);
  
  if (left)
  {
  	 left_height = left.offsetHeight;
	 // debug("init left column height=" + left_height);
  }
  
  if (right)
  {
  	 right_height = right.offsetHeight;
	 // debug("init right column height=" + right_height);
  }
  
  max_col = Math.max(right_height, left_height);
  // debug("max column height=" + max_col);

  if (max_col > center_height)
  {
    center.style.height = max_col + "px";
  }
  
  in_init = false;
}

/* Turn off resizing if printing in IE */
function beforePrint()
{ if (document.getElementById) document.getElementById("main_column").style.height = '';  }

function afterPrint()
{ init(); }

if (document.all)
{
  window.onbeforeprint=beforePrint
  window.onafterprint=afterPrint
}

