	// Register onload event without overwriting 
	if ( typeof window.addEventListener != "undefined" )
		window.addEventListener( "load", StretchColumnsInit, false );
	else if ( typeof window.attachEvent != "undefined" )
		window.attachEvent( "onload", StretchColumnsInit );

	// Global vars
	var StretchColumnsContainers = new Array();
	var StretchColumnsCompiling = false;
	
	// Initializer (Locate and compile StretchColumns elements, set onresize event)
	function StretchColumnsInit()
	{
		StretchColumnsRegistrationTraverse( document ); 
		StretchColumnsCompile(); 		

		if ( typeof window.addEventListener != "undefined" )
			window.addEventListener( "resize", StretchColumnsCompile, false );
		else if ( typeof window.attachEvent != "undefined" )
			window.attachEvent( "onresize", StretchColumnsCompile );
	}

	// Locate As Tall elements
	function StretchColumnsRegistrationTraverse( Node )
	{
		if( Node.childNodes != null )
			for( var i=0;i<Node.childNodes.length; i++ )
				StretchColumnsRegistrationTraverse( Node.childNodes[ i ] );

		if( null!=Node.className && (' '+Node.className+' ').indexOf( ' StretchColumns ' ) >-1 )
			StretchColumnsContainers[ StretchColumnsContainers.length ] = Node;
	}
	
	function StretchColumnsCompile()
	{
		if( StretchColumnsCompiling ) // Simple mutex
			return;

		StretchColumnsCompiling = true;

		for( var i=0; i<StretchColumnsContainers.length; i++ )
		{
			levelChildDivHeights( StretchColumnsContainers[ i ] );
		}
		
		StretchColumnsCompiling = false;
	}
	
	// Level children of the StretchColumnsContainer element
	function levelChildDivHeights( StretchColumnsContainer )
	{
		var Columns = StretchColumnsContainer.childNodes;
		var MaxStrippedHeight = 0;
		var AllLeveled = true;
		var PrecedingOffsetTop = null;

		// Handle resize by resetting
		if( StretchColumnsContainer.style.height != null )
			StretchColumnsContainer.style.height = '100%';

		for( var i=0; i<Columns.length; i++ )
			if( true == Columns[ i ].FixedHeightSet )
				Columns[ i ].style.height = '100%';
				
		// Calculate max heigh for individual columns
		for( var i=0; i<Columns.length; i++ )
		{
			if( null != Columns[ i ].offsetHeight )
			{
				AllLeveled = AllLeveled && ( PrecedingOffsetTop == null ? true : PrecedingOffsetTop == Columns[ i ].offsetTop );
				PrecedingOffsetTop = Columns[ i ].offsetTop;
				var MyStrippedHeight = Columns[ i ].clientHeight - GetPaddingHeight( Columns[ i ] ); 
				MaxStrippedHeight = Math.max( MaxStrippedHeight, MyStrippedHeight );
			}
		}
	
		// Only stretch columns if they are aligned at the top
		if( AllLeveled )
		{
			var MaxOffsetHeight = 0;
			
			StretchColumnsContainer.style.height = MaxStrippedHeight + 'px';

			// Compensate for larger borders and paddings on other columns
			for( var i=0; i<Columns.length; i++ )
				if( null != Columns[ i ].offsetHeight )
					MaxOffsetHeight = Math.max( MaxOffsetHeight, Columns[ i ].offsetHeight );

			for( var i=0; i<Columns.length; i++ )
			{
				if( null != Columns[ i ].offsetHeight )
				{
					Columns[ i ].FixedHeightSet = false;
					var MyStrippedHeight = Columns[ i ].clientHeight - GetPaddingHeight( Columns[ i ] ); 

					if( MyStrippedHeight == MaxStrippedHeight )
					{
						if( Columns[ i ].offsetHeight < MaxOffsetHeight )
						{
							// Compensate for larger borders and paddings on other columns
							Columns[ i ].style.height = MyStrippedHeight + ( MaxOffsetHeight - Columns[ i ].offsetHeight ) + 'px';
							Columns[ i ].FixedHeightSet = true;
						}
					}
				}
			}
		}
	}
	
	function GetPaddingHeight( StretchColumnsElement )
	{
		if( null==StretchColumnsElement.PaddingHeight )
		{
			var MyOffsetHeight = StretchColumnsElement.offsetHeight;
			var StretchColumnsStoredPaddingTopInfo = StretchColumnsElement.style.paddingTop;
			var StretchColumnsStoredPaddingBottomInfo = StretchColumnsElement.style.paddingBottom;

			StretchColumnsElement.style.paddingTop = '0';
			StretchColumnsElement.style.paddingBottom = '0';

			StretchColumnsElement.PaddingHeight = ( MyOffsetHeight>0 ? MyOffsetHeight - StretchColumnsElement.offsetHeight : 0 );

			StretchColumnsElement.style.paddingTop = StretchColumnsStoredPaddingTopInfo;
			StretchColumnsElement.style.paddingBottom = StretchColumnsStoredPaddingBottomInfo;
		}
		
		return StretchColumnsElement.PaddingHeight;
	}
