﻿
(function($) {
    var divgrowid = 0;
    $.fn.divgrow = function(options) {
        var options = $.extend({}, {
            initialHeight: 50,
            moreText: "<img src='/imgs/forum/plus.gif' alt='more' />",
            lessText: "<img src='/imgs/forum/minus.gif' alt='less' />",
            speed: 1000,
            showBrackets: false
        }, options);
        return this.each(function() {
            divgrowid++; obj = $(this);
            var fullHeight = obj.height() + 10;
            if (fullHeight > options.initialHeight) {
                obj.css('height', options.initialHeight).css('overflow', 'hidden');
                if (options.showBrackets) {
                    obj.after('<p class="divgrow-brackets">[&hellip;]</p><a href="#" class="divgrow-showmore' + " divgrow-obj-" + divgrowid + '"' + '></a>')
                }
                else {
                    obj.after('<a href="#" class="divgrow-showmore' + " divgrow-obj-" + divgrowid + '"' + '></a>')
                } $("a.divgrow-showmore").html(options.moreText);
                $("." + "divgrow-obj-" + divgrowid).toggle(function() {
                equalHeight($(".column"), fullHeight - 100);
                $(this).prevAll("div:first").animate({ height: fullHeight + "px" }, options.speed, function() {
                        if (options.showBrackets) {
                            $(this).nextAll("p.divgrow-brackets:first").fadeOut()
                        } $(this).nextAll("a.divgrow-showmore:first").html(options.lessText)
                    })
                },
         function() {
             $(this).prevAll("div:first").stop(true, false).animate({ height: options.initialHeight }, options.speed, function() {
                 equalHeight($(".column"), -fullHeight - 100);
                 if (options.showBrackets) {
                     $(this).nextAll("p.divgrow-brackets:first").stop(true, false).fadeIn()
                 }
                 $(this).nextAll("a.divgrow-showmore:first").stop(true, false).html(options.moreText)
             })
         })
            }
        })
    }
})(jQuery);

