var ddequalcolumns=new Object()
//Input IDs (id attr) of columns to equalize. Script will check if each corresponding column actually exists:
ddequalcolumns.columnswatch=["leftcolumn", "rightcolumn", "contentcolumn"]

ddequalcolumns.setHeights=function(reset){
var tallest=0;
var innerPad=0;
var resetit=(typeof reset=="string")? true : false
if (navigator.appName == 'Microsoft Internet Explorer')
{
	  innerPad = document.getElementById("innerpad").value
	  innerPad = innerPad*2
}
for (var i=0; i<this.columnswatch.length; i++)
{
	if (document.getElementById(this.columnswatch[i])!=null)
	{
		if (resetit)
			document.getElementById(this.columnswatch[i]).style.height="auto"
		if (document.getElementById(this.columnswatch[i]).offsetHeight>tallest)
			if (i == 2)
			{
				if (navigator.appName == 'Microsoft Internet Explorer')
				{
					innerPad = document.getElementById("innerpad").value
	  				innerPad = innerPad*2
					tallest=document.getElementById(this.columnswatch[i]).offsetHeight+innerPad
				}
				else
				{
					tallest=document.getElementById(this.columnswatch[i]).offsetHeight
				}				
			}
			else
			{
				tallest=document.getElementById(this.columnswatch[i]).offsetHeight
			}		
	}
}
if (tallest>0)
{
	for (var i=0; i<this.columnswatch.length; i++)
	{
		if (document.getElementById(this.columnswatch[i])!=null)
			if (navigator.appName == 'Microsoft Internet Explorer')
			{			
				if (i == 2)
				{		
					var iMax = 0
					var ilc = 0				
					if (document.getElementById(this.columnswatch[0])!=null)
					{					
						ilc = parseInt(getStyle("leftcolumn","borderWidth"))
					}
					var irc = 0
					if (document.getElementById(this.columnswatch[1])!=null)
					{
						irc = parseInt(getStyle("rightcolumn","borderWidth"))
					}
					if (ilc > irc)
					{
						iMax = ilc		
					}
					else
					{
						iMax = irc
					}
					var ic = parseInt(getStyle("contentcolumn","borderWidth"))
					iMax = iMax - ic
					document.getElementById(this.columnswatch[i]).style.height=(tallest+(2*iMax))+"px"
				}
				else
				{
					document.getElementById(this.columnswatch[i]).style.height=tallest+"px"
				}
			}
			else // non IE
			{
				if (i == 2)
				{		
					var iMax = 0
					var ilc = 0				
					if (document.getElementById(this.columnswatch[0])!=null)
					{					
						ilc = document.getElementById("ilcBorder").value
					}
					var irc = 0
					if (document.getElementById(this.columnswatch[1])!=null)
					{
						irc = document.getElementById("ircBorder").value
					}
					if (ilc > irc)
					{
						iMax = ilc		
					}
					else
					{
						iMax = irc
					}
					var ic = document.getElementById("iccBorder").value
					iMax = iMax - ic
					document.getElementById(this.columnswatch[i]).style.height=(tallest+(2*iMax))+"px"
				}
				else
				{
					document.getElementById(this.columnswatch[i]).style.height=tallest+"px"	
				}
				
			}
		}
	}
}

ddequalcolumns.resetHeights=function(){
this.setHeights("reset")
}

ddequalcolumns.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}

ddequalcolumns.dotask(window, function(){ddequalcolumns.setHeights()}, "load")

function getStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}
