// JavaScript Document

//-------------------------------------------------------------------//
//  Script sets up column heights to the height of biggest column.   //
//  Works with 2 or 3 columns. Set up their html IDs below           //
//-------------------------------------------------------------------//

window.fixCols = function(){

    // SET-UP COLUMN HTML IDs HERE ---------------------------------------//
    
      	var contentCol = document.getElementById('content');
      	var leftCol    = document.getElementById('left');
      	var rightCol   = document.getElementById('right');
      	
  	//------------------------------------------------------------------//
  
  	var bigger = 0;
  	var smaller = 0;
    
    // IF we have 3 cols
    if(rightCol && leftCol && contentCol){
    
        if(leftCol.offsetHeight <= rightCol.offsetHeight ){
        
             bigger = rightCol.offsetHeight;
            smaller = leftCol.offsetHeight;
           
        }else{
            
            bigger = leftCol.offsetHeight;
            smaller = rightCol.offsetHeight;
            
        }
         
        if(contentCol.offsetHeight > bigger){
        
            // alert('3 columns - content is biggest');
            
            leftCol.style.height = contentCol.offsetHeight + "px";
            rightCol.style.height = contentCol.offsetHeight + "px";
            
        }else if(contentCol.offsetHeight > smaller){
        
            // alert('3 columns - content is middle');
            
            contentCol.style.height = bigger + "px";
            
            if( leftCol.offsetHeight > rightCol.offsetHeight ){
                contentCol.style.height = leftCol.offsetHeight + "px";
                 rightCol.style.height = leftCol.offsetHeight + "px";
            }else{
                contentCol.style.height = rightCol.offsetHeight + "px";
                 leftCol.style.height = rightCol.offsetHeight + "px";
            }
            
        }else{
        
            // alert('3 columns - content is smallest');
            
            contentCol.style.height = bigger + "px";
            
            if( leftCol.offsetHeight > rightCol.offsetHeight ){
                rightCol.style.height = leftCol.offsetHeight + "px";
            }else{
                leftCol.style.height = rightCol.offsetHeight + "px";
            }
            
        }
        
    // ELSE IF we have 2 cols    
  	}else if( (rightCol && contentCol) || (leftCol && contentCol) ){
  
        if(rightCol){
        
            // alert('Content + Right');
        
            if( rightCol.offsetHeight > contentCol.offsetHeight ){
                contentCol.style.height = rightCol.offsetHeight + "px";
            }else{
                rightCol.style.height = contentCol.offsetHeight + "px";
            }
        
        }else if(leftCol){
        
            // alert('Content + Left');
        
            if( leftCol.offsetHeight > contentCol.offsetHeight ){
                contentCol.style.height = leftCol.offsetHeight + "px";
            }else{
                leftCol.style.height = contentCol.offsetHeight + "px";
            }
        }
    }
	
}


// ON-LOAD TRIGGER

window.onload = function(){
	 fixCols();
}
