// ======================
//    Flash Hero
// ======================

function cnb_hero_flash() {
    $('#hero', '#hero_wrapper').remove();

    $('#hero_wrapper').flashembed(
        {   // embedding arguments 
            //swf: 'http://jquery.thewikies.com/swfobject/test.swf',
            src: '/_ui/skin/swf/home/hero_area.swf',
            width: $('#hero_wrapper').width(),
            height: $('#hero_wrapper').height(),
            version: [9, 1],
            wmode: 'transparent', 
            menu: 'false'
        },
        {   // flashvars
            strXMLPath: '/_ui/skin/swf/home/hero-data.xml'
        }
    );
}

// ======================
//    Hero Tabs
// ======================

function cnb_hero_tabs(){
    $("#hero > .card").hide();
    
    // Tabs and slideshow
    $("ul#hero_nav").tabs("#hero > .card", { 
        // Current Tab Active State
        current: 'active',
        // Transition effect
        effect: 'fade',
        fadeOutSpeed: "slow",
        // Loop Tab Rotation
        rotate: true
    }).slideshow({
        autoplay: true,
        interval: 5000
    });
}


// ======================
//    Load Blog Entry
// ======================

function cnb_blog_load(){
    $('#blogEntry').hide();
        jQuery.getFeed({
            url: '/proxy.php?site=bluehealth&url=WorkArea/blogs/blogrss.aspx?blog=121',
            success: function(feed) {
                if (typeof feed != 'undefined' && typeof feed.items != 'undefined' && typeof feed.items[0] != 'undefined') {
                    
                    $('#blogEntry')
                    .empty()
                    .append(
                        '<h2>'+feed.items[0].title+'</h2><p>'
                        +feed.items[0].description
                        +'</p>'
                    );
                    $('#blogLink').attr('href', feed.items[0].link);
                    $('#blogEntry').slideDown();
                    
                    
                }
            },
            error: function(xhr, status, e) {
                $('#blogEntry').slideDown();
            }
        });
}

$(document).ready(function(){
    
    /* Initialize Blog Entry */
    cnb_blog_load();
    
    /* Initialize Hero */
    if(flashembed.isSupported([9, 1])) {
        // Embed SWF
        cnb_hero_flash();
    }
    else {
        // Else show JS tabs
        cnb_hero_tabs();
    }
    
});
