/* 
Derived from a script by Alejandro Gervasio. 
Modified to work in FireFox by Stefan Mischook for Killersites.com

Modified to work with multiple class groups also with elements with multiple class names
by Jonathan del Mar (dec-14-2006)

How it works: just apply the CSS class of 'column' to your pages' main columns.

to work with different classes
add 
<script type="text/javascript">
	var columns = new Array('class_name1', 'class_name1'...);
</script>
by Jonathan del Mar

by default the script will call 
matchColumns();
and the default class_name is 'column'
(see the bottom of this script)
by Jonathan del Mar

*/

	var columns = new Array('featured_item');

matchColumns=function(my_class){ 

     var divs,contDivs,maxHeight,divHeight,d; 
	
     // get all <div> elements in the document 

     divs=document.getElementsByTagName('div'); 

     contDivs=[]; 

     // initialize maximum height value 
     maxHeight=0; 
	 if (!my_class) {
	 	my_class = 'column';
	 }
	 
	 my_regex = new RegExp('(.* |^)' + my_class + '( .*|$)');

     // 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(/\bcolumn\b/.test(divs[i].className)){ 
		  // modified by Jonathan del Mar to match 'column' in multiple classes
		
		  if(my_regex.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) {
		 for(var i=0;i<contDivs.length;i++){ 
		 	if(BrowserDetect.browser && BrowserDetect.browser == 'Firefox') {
			  contDivs[i].style.minHeight=maxHeight + "px"; 
			  contDivs[i].style.height="auto"; 
			} else {
			  contDivs[i].style.height=maxHeight + "px"; 
			}
		 } 
	 }

} 


function set_columns () {
     if(document.getElementsByTagName){ 

		 try
		 {
			 if (columns) {
				 for(var i=0;i<columns.length;i++) {
					matchColumns(columns[i]);	
				 }
			 }
		 }
		 catch (e){}
         matchColumns();
     } 
}



