/* 
Derived from a script by Alejandro Gervasio. 
Modified to work in FireFox by Stefan Mischook for Killersites.com
*/
matchColumns=function(){ 

     var divs,contDivs, headerDivs, maxHeight,divHeight,d; 
	
	 var isExplorer, ofsLeft, ofsTop; 
	
	// are we using explorer?
	isExplorer = (navigator.appName=="Microsoft Internet Explorer");
	ofsLeft = "20px"; ofsTop = "20px";	

     // get all <div> elements in the document 

     divs=document.getElementsByTagName('div'); 

     contDivs=[];
     headerDivs=[]; 

     // 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 'guldkorn' 
          if(/\bguldkornContent\b/.test(divs[i].className)){ 
                contDivs[contDivs.length]=divs[i]; 
          } 
          if(/\bguldkornHeader\b/.test(divs[i].className)){ 
                headerDivs[headerDivs.length]=divs[i]; 
          } 
          
     } 

     // assign maximum height value to all of container <div> elements 
     for(var i=0;i<contDivs.length;i+=2){ 
     		var next = i + 1;    		
     			
            // determine height for <div> element
            d = contDivs[i]; 
            if(d.offsetHeight){ 
                     divHeight=d.offsetHeight; 					
            } 
            else if(d.style.pixelHeight){ 
                     divHeight=d.style.pixelHeight;					 
            } 
			maxHeight=divHeight; 

    		// Handle a left-only element at the end
     		if(next < contDivs.length)
			{
	            d = contDivs[next]; 
	            if(d.offsetHeight){ 
	                     divHeight=d.offsetHeight; 					
	            } 
	            else if(d.style.pixelHeight){ 
	                     divHeight=d.style.pixelHeight;					 
	            } 
	             // calculate maximum height 
				maxHeight=Math.max(maxHeight,divHeight); 
			}
			// set the margin according to maximum height
            contDivs[i].style.marginTop = "0px"; 
            contDivs[i].style.marginLeft = "0px"; 
            contDivs[i].style.marginBottom = (maxHeight - contDivs[i].clientHeight) + "px";
            if(isExplorer)
            {                        
				// We need to set the title position manually under IE :P
	            headerDivs[i].style.left = ofsLeft;
	            headerDivs[i].style.top = ofsTop;
            }
			            
     		if(next < contDivs.length)
			{
	            contDivs[next].style.marginTop = "0px"; 
	            contDivs[next].style.marginLeft = "0px"; 
	            contDivs[next].style.marginBottom= (maxHeight - contDivs[next].clientHeight) + "px"; 
	            if(isExplorer)
    	        {                        
	    	        headerDivs[next].style.left = ofsLeft;
	        	    headerDivs[next].style.top = ofsTop;
	        	}
			}            
     } 
} 

// Runs the script when page loads 

window.onload=function(){ 
     if(document.getElementsByTagName){ 
          matchColumns();			 
     } 
} 



