function activateHeroCycle() {
    /* Variables */
    var $heroBanners = $("#heroBanners li");
    var current = 0;
    var next = 1;
    var speed = 10000;
    var transitionSpeed = 3000;
    var $heroBannerThumbs = $("#heroBannerThumbs li");
    var thumbTransparency = 0.3;
    var $heroLink = $("#heroMoreInfo");
    $("#heroBannerThumbs li:not(:first)").fadeTo("700", thumbTransparency);
    
    function cycleHeros() {
        $($heroBannerThumbs[current]).fadeTo(transitionSpeed, thumbTransparency);
        $($heroBannerThumbs[next]).fadeTo(transitionSpeed, 1);
        $($heroBanners[current]).fadeOut(transitionSpeed);
        $($heroBanners[next]).fadeIn(transitionSpeed, function() {
            current = current + 1;
            if ( current > $heroBanners.length - 1 ) {
                current = 0;
            } else {    
            }
            next = next + 1;
            if ( next > $heroBanners.length - 1 ) {
                next = 0;
            }
            var link = $($heroBanners[current]).find("a").attr("href");
            $heroLink.attr("href", link);
        });
    }
        
    var heroInterval = setInterval(cycleHeros, speed);

    $heroBannerThumbs.mouseover(function() {
        clearInterval(heroInterval);
        var thisElem = $(this);
        $("#heroBannerThumbs li:not(this)").stop().animate({
            opacity: 0.3
        });
        thisElem.stop().animate({
            opacity: 1
        });
        var slideIndex =  thisElem.attr("rel");
        if ( slideIndex != current ) {
            $($heroBanners[current]).stop().animate({ opacity: 0 }, function() {
                $(this).hide();
            });
            $($heroBanners[slideIndex]).stop().css({ display: "block", opacity: 0 }).animate({ opacity: 1 });
            var link = $($heroBanners[slideIndex]).find("a").attr("href");
            $heroLink.attr("href", link);
        }
        current = slideIndex;
    });

    /* End Hero Banner SlideShow */
}

$(function() {
    
    /* Hero Banner SlideShow */
    activateHeroCycle();
    
    $("#twdkSlideShow").show().innerfade({
        speed: 1000,
        timeout: 4000,
        controls: false 
    });
    
    /* Partnership Page Show Offer Code Instructions */
    var $offerCodeDisplay =  $("#offerCodeDisplay");
    if ( $offerCodeDisplay.length > 0 ) {
        $offerCodeDisplay.children("a").click(function() {
            $("#offerCodeInstruct").slideDown();
            return false;
        });
    }
        
});    