jq(function() {
    
    /*jq("#homepage-features div#features-carousel").jCarouselLite({
        btnGo : [
            "#homepage-features li.tab_1",
            "#homepage-features li.tab_2",
            "#homepage-features li.tab_3",
        ],
        visible: 1
    });*/

    // Make row-two headings the same height
    max_height = -1;
    jq(".homepage-row-two h1").each(function() {
        that = jq(this);
        if (that.height() > max_height) {
            max_height = that.height();
        }
    }).each(function() {
        jq(this).height(max_height);
    });
    
    jq("#feature-tabs").show();
    
    content_tabs = jq("#features-carousel ul li").remove();
    content_tabs_parent = jq("#homepage-features div#features-carousel ul");
    carousel_move_tabs = jq("#feature-tabs li");
    
    carousel_links = [
            "#feature-tabs li.tab_1",
            "#feature-tabs li.tab_2",
            "#feature-tabs li.tab_3"
        ];
        
    active_tab = null;
    
    jq.each(carousel_links, function(i, val) {
        
        jq(val).click(function(event) {
            that = jq(this);            
            event.preventDefault();
                      
            active_tab.fadeOut("fast", function() {
                new_tab = jq(content_tabs[i]);
                
                active_tab.remove();
                           
                content_tabs_parent.append(new_tab);
                new_tab.fadeIn("fast");
                
                active_tab = new_tab;
            });           
        
            carousel_move_tabs.removeClass("active");
            that.addClass("active");
        });
    })
    
    if (content_tabs.length > 0)
    {        
        active_tab = jq(content_tabs[0]);
        jq(active_tab).css("display", "block");  
        jq(carousel_links[0]).addClass("active");
        content_tabs_parent.append(active_tab);
    }
    
});
