﻿function AdjustHeight(parentContainer, classToFind, tag)
{
    // get a reference to the main content DIV that holds the other columns
    var contentCol = window.document.getElementById(parentContainer);
            
    //create an array and fill it with refernces to the elements that need to be altered
    var divsToResize = new Array();
    var divsToResize= getElementsByClass(classToFind,contentCol,tag);
            
    //minimum height value desired
    var maxHeight = 350;
            
    //calculate the max height by comparing the height of each found element 
    //to the current maxHeight
    for (i=0; i<divsToResize.length; i++)
    {    
	    maxHeight = Math.max(maxHeight, divsToResize[i].offsetHeight);
	}
    //set the height for all found elements to maxHeight
    for (i=0; i<divsToResize.length; i++)
    {   
	    divsToResize[i].style.height= maxHeight + "px";  
	}
}
                
//returns a list of elements that are of a certain css class
function getElementsByClass(searchClass,node,tag) 
{
    var classElements = new Array();
    //the upper most level to start searching
    //if not provided it defaults to document and will search entire DOM
    if ( node == null )
	    node = document;
    if ( tag == null )
	    tag = "*";
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    //var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
    for (i = 0, j = 0; i < elsLen; i++) {
	    var elClassName = els[i].className;
		if (elClassName.indexOf(searchClass) > -1) 
		{
		    classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}  