(function($){

$.fn.equalHeights = function(add) {
	var tallest = 0;
	$(this).each(function(){
		if ($(this).height() > tallest) tallest = $(this).height();
	});
	$(this).each(function(){
		var t = $(this);
		var p = parseInt(t.css('paddingTop')) + parseInt(t.css('paddingBottom'));
		var h = tallest - p;
		for (var i in add)
			if (this.id == i)
				h += add[i];
		if ($.browser.msie && $.browser.version == 6.0)
			t.css({'height': h});
		t.css({'min-height': h});
	});
	return this;
};

$.fn.removeHeights = function() {
    $(this).each(function(){
       $(this).css({'height': null, 'min-height' : null});
    });
};

$(document).ready(function(){

	setEqualBoxHeights();

	if ($.browser.msie) {
		try {document.execCommand("BackgroundImageCache", false, true);} catch(err){};
		if (typeof(DD_belatedPNG) != 'undefined')
		{
			DD_belatedPNG.fix('.png');
		}
	}

});

})(jQuery);

function beforePrint()
{
    (function($)
    {
        $('#side1 .box1a .wrap').each(function(){
            $(this).children().removeHeights();
        });
        $('.cols').each(function(){
            $('.col', this).removeHeights();
        });
    })(jQuery);
}

function afterPrint()
{
    setTimeout(setEqualBoxHeights, 1000);
}

function setEqualBoxHeights()
{
    (function($)
    {
        $('#side1 .box1a .wrap').each(function(){
            $(this).children().equalHeights();
        });
        $('.cols').each(function(){
            $('.col', this).equalHeights();
        });
        //This is acting crazy in IE6, so I'd rather not have the boxes the same height as a compromise
        if (!($.browser.msie && $.browser.version == 6.0)){
            $('#membership-boxes table tr').each(function(){
                $('td div.box1', this).equalHeights();
            });
        }
    })(jQuery);
}
