window.addEvent('domready', function() {
    var fx = new Fx.Styles($('full'), {duration:500, wait:false});
    $('about_capabilities').className = 'workSelected';

    // Get the default web work.
    new Ajax("about_jx.php?p=3", {
        method: 'get',
        onSuccess: function() {
            $('full').setHTML(this.response.text);

            makeh2s();
        } 
    }).request();

    // Add some clicking action for the navigation.  Fade out the old content and fade
    // in the new content via ajax.
    $$('#AboutTab ul li a').each(function(element) {
        element.addEvent('click', function(e) {
            e = new Event(e).stop();

            // Set up active states for nav
            $$('.workSelected').each(function(ele){ $(ele.id).className = ''; });
            $(element.id).className = 'workSelected';

            switch(element.id) {
                case 'about_history': var sec = '1';
                break;
                case 'about_leadership': var sec = '2';
                break;
                case 'about_capabilities': var sec = '3';
                break;
                default: var sec = '1';
                break;
            }

            var url = "about_jx.php?p=" + sec;

            fx.start({
                'opacity': 0
            }).chain(function() {
                fx.start({ 'opacity': 1 });
                $('full').setHTML("<img src='http://tkfast.com/img/loading.gif' alt='loading' style='margin-left:70px; margin-top:-50px;' />");
            }).chain(function() {
                fx.start({ 'opacity': 0 });
            }).chain(function() {
                new Ajax(url, {
                    method: 'get',
                    onSuccess: function() {
                        $('full').setHTML(this.response.text);
                        fx.start({ 'opacity': 1 });

                        // Start lightbox when AJAX is done loading
                        if(sec == '3') {
                            Lightbox.init();
                        }

                        // Start sIFR when AJAX is done loading
                        makeh2s();
                    }
                }).request();
            });

        });
    });
});
