﻿//************************************************************************************* 
// File     :   cols.js
// Requires :   prototype.js, mf_domLibrary_0.1.js
// Author   :   Rusty Swayne (rss)
// Origin   :   mindfly.com
// Purpose  :   sets heights of cols to be equal and clears a footer
//*************************************************************************************

var ht_branding     = 100;
var ht_site_info    = 15;
var ht_content_adj  = 0;       
var ht_col_adj      = 0;

// holds the initially displayed height
var min_height      = 0;
var max_col_height  = 0;

var objTimeout = null;

function setupColLayout() {

    // create a list of divs with class col     
    var cols = $$('div.col');
    cols.each( function(col) {
            if(col.offsetHeight > max_col_height)
                max_col_height = col.offsetHeight;
        });
        
}

function setColumnHeights() {
    
    var body = $$('body');
    
    
        // main content div
    var content = $('content');
    
    // create a list of divs with class col     
    var cols = $$('div.col');
            
    
    // determine the dims of the browser
    var winH = getViewportSize()[1];
    var min_height = winH - (ht_branding + ht_site_info);
    
    // override min_height
    min_height = 0;
    
   var new_col_height = 0;
   if(max_col_height < min_height) 
   {
   
        new_col_height = min_height;
        
   } else {
    
        new_col_height = max_col_height;
                 
   }      
   
   
   content.style.height = new_col_height + ht_content_adj + 'px'; 
   /*content.setStyle({ 
        height : new_col_height
        });*/
                        
    cols.each( function(col) {
            col.style.height = new_col_height + ht_col_adj + 'px'; 
        });
   
        clearTimeout(objTimeout);
        objTimeout = null;
              
}




addLoadEvent(setupColLayout);
addLoadEvent(setColumnHeights);
addOnresizeEvent(setColumnHeights);
//window.setInterval('setColumnHeights()', 50);



