(function ($) {

    $(function() {
        $('.height-equal, .height-equal-clear').each(function () {
            if (!this.equalHeight_check) {
                var me = $(this),
                    height = me.height(),
                    tempEl,
                    elList = [];
                    
                $(['prev', 'next']).each(function(k, func) {
                    tempEl = me[func]();
                    while (tempEl.length) {
                        if (tempEl.css('clear') == 'both') {
                            if (me.hasClass('height-equal-clear')) {
                                break;
                            }
                            else {
                                tempEl = tempEl[func]();
                                continue;
                            }
                        }
                        this.equalHeight_check = true;
                        height = Math.max(height, tempEl.height());
                        elList.push(tempEl);
                        tempEl = tempEl[func]();
                    }
                });
    
                me.css({minHeight: height + 'px'});
                $(elList).css({minHeight: height + 'px'});
            }
        });

    });
    
// END
}) ($);

