﻿$(function() {


//create the effect for the features to fade in and out.
$.tools.tabs.addEffect('featurednewsfade', function(i, done) {
    //        //fade out the text and background.      
    //        //this.getPanes().fadeOut('slow', function() {
    //        //hack for ie - it won't fade the children out correctly.
    //        //   $(this).find('.feature_header,.feature_body,.feature_learnmore').fadeOut('slow');

    //        //});

    var panes = this.getPanes();
    this.currentIndex = i;
    // we have to fade the internal items in the div due to ie issues.

    $('#RotatingNewsWrapper').fadeOut('fast', function() {
        panes.hide();
        $('#left_news_dz').fadeOut('fast', function() {
            panes.eq(i).show(function() {
                //hack for ie - it won't fade the children in correctly.  have to fade them directly
                // $(this).find('.feature_header,.feature_body,.feature_learnmore').fadeIn('slow');
                $('#left_news_dz').html($(this).find('.hidden').html());

                $(this).show();
                $('#left_news_dz').fadeIn('fast');
                $('#RotatingNewsWrapper').fadeIn('fast');

            });
        });
    });
    done.call();
});

//2012-01-19 MR (iMedia) - seems to be crosstalk between fade effects. Use this effect to fade in/out
// news & promo items
$.tools.tabs.addEffect('newfade', function(tabidx, done) {
    this.getPanes().hide().eq(tabidx).fadeIn();
    done.call();
});

//$('#rotating_news_right').tabs("#hp_rotating_news_wrapper > .RotatingNewsItem", {
//    tabs: 'ul#rotating_news_counter li .newscount',
//    effect: 'featurednewsfade',
//    rotate: true,
//    current: 'active'
//}).slideshow({ next: "a.next_news", prev: "a.previous_news", autoplay: true, interval: 8000,
//    clickable: false
//});

$('#footerNewsWrapper').tabs("#tw_rotating_news_wrapper > .RotatingNewsItem", {
    tabs: 'ul#rotating_news_counter li .newscount',
    effect: 'newfade',
    rotate: true,
    current: 'active'
}).slideshow({ next: "a.next_news", prev: "a.previous_news", autoplay: true, interval: 12000,
    clickable: false
});

//RotatingNewsAPI = $('#tw_rotating_news_wrapper').data("tabs");

//RotatingNewsAPI.currentIndex = 0;

//RotatingNewsAPI.next = function() {
//    RotatingNewsAPI.currentIndex++;
//    if (RotatingNewsAPI.currentIndex == RotatingNewsAPI.getPanes().length)
//        RotatingNewsAPI.currentIndex = 0;
//    return RotatingNewsAPI.click(RotatingNewsAPI.currentIndex);
//}

//RotatingNewsAPI.prev = function() {
//    RotatingNewsAPI.currentIndex--;
//    if (RotatingNewsAPI.currentIndex < 0)
//        RotatingNewsAPI.currentIndex = RotatingNewsAPI.getPanes().length - 1;
//    return RotatingNewsAPI.click(RotatingNewsAPI.currentIndex);
//}
});
