/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 * 
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
 *
 * Usage: $(object).equalHeights([minHeight], [maxHeight]);
 * 
 * Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
 * Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
 * Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
 * than 300 pixels tall. Elements with too much content will gain a scrollbar.
 * 
 */

if(window.addEventListener){
    window.addEventListener('load',function(){
        drawBorders();
        showColumns();
        equalHeights();
    },true);
}else if(window.attachEvent){
    window.attachEvent('onload', initExplorer);  
}

function initExplorer(){
        drawBorders();
        showColumns();
        equalHeights();
}

function showColumns(){
    $("div#columnIzq").css('visibility','visible');
    $("div#columnDer").css('visibility','visible');
}

function equalHeights() {
	var divI = $('#columnIzq div.body');
	var divD = $('#columnDer div.body');
	
    divI.css('height', divI.height());
    divD.each(function(){
        $(this).css('height', $(this).height());
    });
    
    //var objIzq = document.getElementById("columnIzq");
	var heightIzq = $("div#columnIzq").height();//objIzq.offsetHeight;
    //var objDer = document.getElementById("columnDer");
	var heightDer = $("div#columnDer").height();//objDer.offsetHeight;
    
	if(heightIzq < heightDer) {
	    var newHeight = heightDer-heightIzq;
	    divI.animate({height: '+='+newHeight},1000,
	        function(){});
		//divI.height(divI.height()+(heightDer-heightIzq));
	}else if(heightIzq != heightDer){
	    var newHeight = (heightDer-heightIzq)/2;	    
	    divD.each(function(){
	        $(this).animate({height: '+='+newHeight},1000,
	            function(){});}
	    );
	    //divD.height(divD.height()+(heightIzq-heightDer)/2);
	}
}
/*$(document).ready(function() {
    equalHeights();
});*/
/*$(document).resize(function(){
 	equalHeights();
});*/

