﻿// Copyright (c) 2010 Robust Haven, Leblanc Meneses
// dependencies: jquery, jqueryui
jQuery.fn.CodeBlockPanel = function (defaultSize, ctrl) {
    $(this).wrap("<div style='height:" + defaultSize + "px; overflow-y: scroll; ' />");
    var wrap = $(this).parent();

    ctrl.insertAfter(wrap);

    var code = $(this);
    ctrl.each(function (index2) {
        $(this).data('Visibility', 'collapsed');
        $(this).click(function (e) {
            if ($(this).data('Visibility') == 'collapsed') {
                wrap.stop().animate(
                                        { height: code.height() },
                                        {
                                            duration: 1000,
                                            easing: 'easeOutQuint'
                                        });
                $(this).data('Visibility', 'expand');
            } else {
                wrap.stop().animate(
                                        { height: defaultSize },
                                        {
                                            duration: 1000,
                                            easing: 'easeOutQuint'
                                        });
                $(this).data('Visibility', 'collapsed');
            }
        });
    });
}
