﻿jQuery(document).ready(function() {
    // do stuff when DOM is ready
    var scroller = new Nova.Controls.TestimonialScroller(jQuery('.product'), jQuery('.testimonials ul'), null);

    // Cannot use opacity with IE as it the ombination of ClearType text and Opacity causes
    // the text to blur. The situation is not any better in IE8. So I am led to beleive
    if (!jQuery.browser.msie) {
        jQuery('#testimonial-scroller').css('opacity', 0.9);
    }
});

function alignHorizontallyWrappedList(list, colCount) {

    var accumulatedHeight = 0;
    var accumulatedHeights = new Array();
    var listHeight = 0;

    // Obtain the height if each column. This height will be used to offset the next column so that the tops of columns > 1 are 
    // all aligned

    for (var col = 1; col <= colCount; col++) {
        accumulatedHeight = 0;
        jQuery('.col' + col, list).each(function(index) {
            accumulatedHeight += jQuery(this).outerHeight(true);
        })
        accumulatedHeights[col - 1] = accumulatedHeight;
        listHeight = Math.max(listHeight, accumulatedHeight);
    }

    // The margin tops are set once all columns are measured rather than as we go because the margining effects the height.
    for (var heightIndex = 0; heightIndex <= accumulatedHeights.length - 1; heightIndex++) {
        jQuery('.col' + (heightIndex + 2) + '.topItem', list).css('marginTop', '-' + accumulatedHeights[heightIndex] + 'px')
    }

    // Set the height of the list to be the same as the tallest column
    list.css('height', listHeight + 'px');

    jQuery(list).addClass('wrapped');
}

function tabContentVisibilityStatusChanged(visibility, tabLink, tabContent) {
    if (tabContent.hasClass('video')) {
       // IF Play and Pause of video worked from a player that was hidden it would be done here
    }
}

