
function work_packages() {
        
        $('.expandable').addClass('hidden');
        $('.csc-header').addClass('collapsed');
        $('.csc-header h1').wrapInner('<a href="#"></a>');
        $('.csc-header h2').wrapInner('<a href="#"></a>');
        $('.csc-header h3').wrapInner('<a href="#"></a>');
        $('.csc-header').bind('click', 
                     function() {
                             if ($(this).hasClass('collapsed')) {
                                     $(this).removeClass('collapsed');
                                     $(this).addClass('expanded');
                                     $(this).siblings().removeClass('hidden');
                             } else if ($(this).hasClass('expanded')) {                             
                                     $(this).removeClass('expanded');
                                     $(this).addClass('collapsed');
                                     $(this).siblings().addClass('hidden');
                             }
                             return false;
                     }
                );

}


function animation() {
        jQuery('.animation-control').click(
                function () {
                        var oldp, id, newp; 

                        oldp = $('#animation .active-element');
                        id = '#pic' + $(this).text();
                        newp = $(id);

                        if (oldp.attr('id') != newp.attr('id')) {
                                $('#animation-control-container a').removeClass('active');
                                $(this).addClass('active');
                                oldp.fadeOut(2000);
                                newp.fadeIn(2000);
                                oldp.removeClass('active-element');
                                newp.addClass('active-element');
                        }
            
                        return false;
                }
                );
        return 'wtf';
}


var datadive = {

current: 1,
timer: null,
interval: 10000,

init: function() {
           
                $('.animation-control').click(
                        function() {
                                newid = $(this).text();                 
                                datadive.swap(datadive.current, newid);
                                datadive.current = Number(newid);
                                
                                return false;
                        }
                        );
                $('#animation').mouseenter(
                        function() {
                                window.clearInterval(datadive.timer);
                        }
                        );
                $('#animation').mouseleave(
                        function() {
                                datadive.timer = window.setInterval(datadive.walk, datadive.interval);
                        }
                        );
                datadive.timer = window.setInterval(datadive.walk, datadive.interval);
        },

swap: function(oldid, newid) {
                if (oldid == newid) {
                        return;
                }
                oldpic = $('#pic' + oldid);
                oldctrl = $('#ctrl' + oldid);
                newpic = $('#pic' + newid);
                newctrl = $('#ctrl' + newid);

                oldpic.fadeOut(2000);
                newpic.fadeIn(2000);
                oldctrl.removeClass('active');
                newctrl.addClass('active');
        },

walk: function() {
                oldid = Number(datadive.current);
                newid = oldid + 1;
                if (newid == 7) {
                        newid = 1;
                }
                
                datadive.current = newid;
                datadive.swap(oldid, newid);
        }
};

