// matchHeight.js
//***Script Name.....matchHeight.js
//***Programmer......Shareware via the internet
//***Language........Javascript
//***Project.........PI 3842 - Standardize Internet Pages
//***Main Function...This function allows us to dynamically set the heights 
//***				 of the columns in our tableless layout by setting all the 
//***				 column heights to the largest one, or 400px if they are smaller.
//***				 Current understanding requires that this file be added in the <HEAD> section
//***				 of a page to ensure that it fires at load and performs as expected.
//***********************************************************
//***********change log
//*** date 		Programmer 				Nature of change
//*** 6/2007  	Robert Bohannon, Jr.	File found and implemented
//**********************************************************

matchHeight=function(){ 

     var divs,contDivs,maxHeight,divHeight,d; 

     // get all <div> elements in the document 

     divs=document.getElementsByTagName('div'); 

     contDivs=[]; 

     // initialize maximum height value 

     maxHeight=0; 

     // iterate over all <div> elements in the document 

     for(var i=0;i<divs.length;i++){ 

          // make collection with <div> elements with class attribute 'container' 

          if(/\bcontainer\b/.test(divs[i].className)){ 

                d=divs[i]; 

                contDivs[contDivs.length]=d; 

                // determine height for <div> element 

                if(d.offsetHeight){ 

                     divHeight=d.offsetHeight; 

                } 

                else if(d.style.pixelHeight){ 

                     divHeight=d.style.pixelHeight; 

                } 

                // calculate maximum height 

                maxHeight=Math.max(maxHeight,divHeight); 

          } 

     } 

     // assign maximum height value to all of container <div> elements 

	if(maxHeight < 400){
	
		maxHeight = 400;  //Forced min-height of 400px
	
	}
     for(var i=0;i<contDivs.length;i++){ 

          contDivs[i].style.height=maxHeight; 

     } 

} 

// execute function when page loads 

window.onload=function(){ 

     if(document.getElementsByTagName){ 

          matchHeight(); 

     } 

} 
