/* 
Derived from a script by Alejandro Gervasio. 
Modified to work in FireFox by Stefan Mischook for Killersites.com
Edited to work for inyourfootsteps.com usecase by Michael Sheldon

This gets called by smallcb.js to make sure the layout is complete before getting sizes
*/
matchColumns=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 of sizable from mainpage box elements
          if(/\bbox[1345]/.test(divs[i].id)){ 

                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;					 
                } 

		if(/\bbox3/.test(d.id)) {
			box3Height = divHeight;
		}

                // calculate maximum height 
                maxHeight=Math.max(maxHeight,divHeight); 
          } else if(/\bbox2/.test(divs[i].id)) {
	  	//Find the height of box2
	  	d = divs[i]

		if(d.offsetHeight) {
			box2Height = d.offsetHeight;
		} else if (d.style.pixelHeight) {
		  	box2Height = d.style.pixelHeight;
		}
	  }

     } 

     //Check combined height of box2 and box3 and their padding
     maxHeight=Math.max(maxHeight, box2Height + 58 + box3Height);

     //Minimize bottom padding
     maxHeight = maxHeight - 15;

     // assign maximum height value to all of container <div> elements 
     for(var i=0;i<contDivs.length;i++){ 
     	  
	  //Make exception for box3 which shares a column with box2
	  if(contDivs[i].id == "box3") {
	  	height = maxHeight - box2Height - 58; //58 is manual adjustment for padding, would be nice to do this automatically
	  	contDivs[i].style.height = height + "px";
	  } else {
          	contDivs[i].style.height = maxHeight + "px"; 
	  }

     } 

} 
