/*
if ('http://'+window.location.host+'/' != window.location.href) {
       window.location.href = 'http://'+window.location.host+'/';
}

*/

(function($){ // @author trixta http://www.protofunc.com/scripts/jquery/animate-step/
        $.fx.step.syncWidth = function(fx){
                if (!fx.state || !fx.syncStart) {
                        var o = fx.options;
                        fx.start = $(fx.elem).width();
                        fx.syncStart = [];
                        fx.fullWidth = o.fullWidth;
                        fx.syncElements = $(o.syncElements).map(function(i, elem){
                                if(elem !== fx.elem){
                                        return elem;
                                }
                        })
                        .each(function(i){
                                fx.syncStart.push($(this).width());
                        });
                        fx.syncEnd = (fx.fullWidth - fx.end) / fx.syncElements.length;
                }
                var syncedWidth = 0;
                fx.syncElements
                .each(function(i){
                        var width = Math.round(fx.pos * (fx.syncEnd - fx.syncStart[i]) + fx.syncStart[i]);
                        syncedWidth += width;
                        this.style.width = width + fx.unit;
                });
                fx.elem.style.width = fx.fullWidth - syncedWidth + fx.unit;
        };
})(jQuery);



$(document).ready(function() {
        
        lastBlock = $("div.start a.link");
        $("a.link").click(
                function() {
                        $(lastBlock).next('div.content').empty();
                        thisBlock = $(this);
                        $(this).next('div.content').load($(this).attr('href')+' div.start > div.content > *', function(responseText, textStatus, XMLHttpRequest) {
                                $('.scroll').jScrollPane({
                                        showArrows:true,
                                        scrollbarWidth:10
                                });
                                $(this).hide();
                                $('.fancy').fancybox({ 
                                        'overlayOpacity': 0.6, 
                                        'overlayColor': '#000' 
                                });
                                
                                $(".iframe").fancybox({
                                          'frameWidth'          : 700,
                                          'frameHeight'         : 565,
                                          'overlayColor'   : '#000',
                                          'overlayOpacity' : '0.5'
                                  });
                                
                                $(".toggle_container").hide();
      
                                   $("h4.expand_heading").toggle(function(){
                                           $(this).addClass("active"); 
                                           }, function () {
                                           $(this).removeClass("active");
                                   });
                                   
                                   $("h4.expand_heading").click(function(){
                                           $(this).next(".toggle_container").slideToggle("slow,");
                                   });
                                   $(".expand_all").toggle(function(){
                                           $(this).addClass("expanded"); 
                                           }, function () {
                                           $(this).removeClass("expanded");
                                   });
                                   $(".expand_all").click(function(){
                                           $(".toggle_container").slideToggle("slow,");
                                   });
                                   
                        });

                        var tabs = $('div.tab');
                        
                        $(lastBlock).parent().animate({syncWidth: 81}, {
                                duration:300, 
                                queue: false,
                                syncElements: tabs, 
                                fullWidth: 965 /* (5 tabs x 81px) + (1 tab x 560px) */
                        });
                        
                        $(thisBlock).parent().animate({syncWidth: 560}, {
                                complete: function(){
                                        $(this).children('div.content').fadeIn(100);
                                },
                                duration:300, 
                                queue: false,
                                syncElements: tabs, 
                                fullWidth: 965 /* (5 tabs x 81px) + (1 tab x 560px) */
                        });

                        lastBlock = $(this);
                        return false;
                }
        );
});
