/**
 * Common scripts
 *
 * @author  Paul Kolbovich <paulkolbovich@gmail.com>
 * @version 0.6.4.1
 */
jQuery.noConflict();

jQuery(function($) {
	
    /**
     * expand / collapse trade operations
     * {{{
     */
    /**
     * collapse all
     */
    function collapseAll() {
        $('tr.child').hide();
        $('tr.parent td.anchor').removeClass('expanded').addClass('collapsed');
    }
    /**
     * expand all
     */
    function expandAll() {
        $('tr.child').show();
        $('tr.parent td.anchor').addClass('expanded').removeClass('collapsed');
    }
    collapseAll();
    $('tr.parent td.anchor').click(function () {
        var tr = $(this);
        if (tr.hasClass('collapsed')) { //expand
            tr = tr.addClass('expanded').removeClass('collapsed').parent().next();
            while (tr.hasClass('child')) {
                tr.show();
                tr = tr.next();
            }
        } else { // collapse
            tr = tr.removeClass('expanded').addClass('collapsed').parent().next();
            while (tr.hasClass('child')) {
                tr.hide();
                tr = tr.next();
            }
        }
    });
    $('#expandAll').click(function () {
        expandAll();
    });
    $('#collapseAll').click(function () {
        collapseAll();
    });
    /**
     * }}}
     */
});

