function init()
{
	// Resize Columns
	resizeColumns();

	window.onresize = function() {
		resizeColumns();
	}
}

function resizeColumns()
{
	// Get leftcolumn and rightcolumn elements
	var leftColumn = document.getElementById("left859");
	var leftNav = document.getElementById("sidenav");
   	var centerColumn = document.getElementById("maincontent");
	var rightColumn = document.getElementById("right131");

	// Get left-visualPadding and right-visualPadding elements
	var leftVisualPadding = document.getElementById("sidenav-detail");
	var rightVisualPadding = document.getElementById("rightsidenav-detail");
	
	// Set the heights of these two padding divs to auto
	leftVisualPadding.style.height = "auto";
	rightVisualPadding.style.height = "auto";

	// Calculate max height of leftcontent and rightcontent
	var maxHeight=Math.max(leftColumn.offsetHeight, leftNav.offsetHeight, centerColumn.offsetHeight, rightColumn.offsetHeight);
	maxHeight = maxHeight - 60;

	// Set IE Fudge -- For some reason, IE7 works just fine, but IE6 is 19px off
	
	var IE_left = 0;
	var IE_center = 0;
	var IE_right = 0;
	
//	if (msieversion() == 6)
//	{
//		IE_left = 19;
//		IE_right = 19;
//	}

	//writeDebug( leftColumn.offsetHeight + ", " + rightColumn.offsetHeight);
	
	// Set both heights to the same (max) value.  Note that we have to append "px" to the value.
	leftVisualPadding.style.height = (maxHeight + IE_left) + "px";
	rightVisualPadding.style.height = (maxHeight + IE_right) + "px";

	//writeDebug(maxHeight + ": " + leftVisualPadding.style.height + ", " + rightVisualPadding.style.height);
	//writeDebug( leftColumn.offsetHeight + ", " + rightColumn.offsetHeight + "<br><br>");
}






function msieversion()
{
	var ua = window.navigator.userAgent
	var msie = ua.indexOf ( "MSIE " )
	
	if ( msie > 0 )      // If Internet Explorer, return version number
		return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
	else                 // If another browser, return 0
		return 0

}

function writeDebug(theText, popAlert)
{
	var theDebugId = "debugwindow";
	var theDebugWindow = document.getElementById(theDebugId);
	if (!theDebugWindow)
	{
		theDebugWindow = document.body.appendChild(document.createElement("div"));
		theDebugWindow.id = theDebugId;
		theDebugWindow.style.position = "absolute";
		theDebugWindow.style.background = "#ffffcc";
		theDebugWindow.style.borderWidth = "1px";
		theDebugWindow.style.borderColor = "#ff6633";
		theDebugWindow.style.borderStyle = "solid";
		theDebugWindow.style.fontSize = "15px";
		theDebugWindow.style.zIndex = "999";
		theDebugWindow.style.top = "10px";
		theDebugWindow.style.right = "10px";
		theDebugWindow.style.padding = "10px";
		theDebugWindow.style.width = "33%";
	}

	theDiv = document.createElement("div");
	theDiv.innerHTML = theText;
	theDebugWindow.appendChild(theDiv);
	
	if (popAlert)
	{
		alert(theText);
	}
}

function imgSwap(oImg)
{
   var strOver  = "_on"    // image to be used with mouse over
   var strOff = "_off"     // normal image
   var strImg = oImg.src
   if (strImg.indexOf(strOver) != -1) 
      oImg.src = strImg.replace(strOver,strOff)
   else
      oImg.src = strImg.replace(strOff,strOver)
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 and 6.
{
   if ((version >= 5.5) && (document.body.filters)) 
   {
       for(var i=0; i<document.images.length; i++)
       {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	      {
		     var imgID = (img.id) ? "id='" + img.id + "' " : ""
		     var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		     var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		     var imgStyle = "display:inline-block;" + img.style.cssText 
		     var imgAttribs = img.attributes;
		     for (var j=0; j<imgAttribs.length; j++)
			 {
			    var imgAttrib = imgAttribs[j];
			    if (imgAttrib.nodeName == "align")
			    {		  
			       if (imgAttrib.nodeValue == "left") imgStyle = "float:left;" + imgStyle
			       if (imgAttrib.nodeValue == "right") imgStyle = "float:right;" + imgStyle
			       break
			    }
             }
		     var strNewHTML = "<span " + imgID + imgClass + imgTitle
		     strNewHTML += " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		     strNewHTML += "(src='" + img.src + "', sizingMethod='scale');\""
		     strNewHTML += " onmouseover=\"PNGswap('" + img.id + "');\" onmouseout=\"PNGswap('" + img.id +"');\""
		     strNewHTML += "></span>" 
		     img.outerHTML = strNewHTML
		     i = i-1
	      }
       }
   }
}

function PNGswap(myID)
{
   var strOver  = "_on"
   var strOff = "_off"
   var oSpan = document.getElementById(myID)
   var currentAlphaImg = oSpan.filters(0).src
   if (currentAlphaImg.indexOf(strOver) != -1)
      oSpan.filters(0).src = currentAlphaImg.replace(strOver,strOff)
   else
      oSpan.filters(0).src = currentAlphaImg.replace(strOff,strOver)
}

function holdUp()
{
//
// This function is first called either by an onLoad event in the <body> tag
// or some other event, like onClick.
//
// Set the value of refreshFreq to how often (in seconds)
// you want the picture to refresh
//
refreshFreq=60;
//
//after the refresh time elapses, go and update the picture
//
setTimeout("freshPic()", refreshFreq*1000);
}

function freshPic()
{
//
// Get the source value for the picture
// e.g. http://www.mysite.com/doug.jpg and
//
var currentPath=document.campic.src;
//
// Declare a new array to put the trimmed part of the source
// value in
//
var trimmedPath=new Array();
//
// Take everything before a question mark in the source value
// and put it in the array we created e.g. doug.jpg?0.32234 becomes
// doug.jpg (with the 0.32234 going into the second array spot
//
trimmedPath=currentPath.split("?");
//
// Take the source value and tack a qustion mark followed by a random number
// This makes the browser treat it as a new image and not use the cached copy
//
document.campic.src = trimmedPath[0] + "?" + Math.random();
//
// Go back and wait again.
holdUp();
}