$(document).ready(function() {
    $("#PrimaryContentContainer").prepend($("#ProductImageContainer").html());

    // Set the left-hand navigation product category label to be the same text as what's in the "on" secondary nav element
    var on = $("#SecondLevelSubNavContainer li.on:first");
    if (on != null) {
        var lhnCatLink = $("#productCategoryLabel a");
        if (lhnCatLink != null) {
            lhnCatLink.text(on.text());
            var onLink = $("a:first", on);
            lhnCatLink.attr("href", onLink.attr("href"));
        }
    }

    // Add resource center tab
    // alert($("#resourceCenterTabContainer li").length);
    if ($("#resource_center").length > 0) {
        $("<li><a href='#resource_center'><span>Resource Center</span></a></li>").appendTo("#tabs ul:first");
        $("#resource_center").appendTo("#tabs");
    }

    // Set up tabs
    // Using fx causes the page to jump to the top on tab click
    $("#tabs").tabs(); // { fx: { opacity: "toggle", duration: "fast"} });

    // Space images inside tabs based on their alignment (e.g. give left-aligned images a right-margin and vice versa)
    $(".ui-tabs .ui-tabs-panel img[align='left']").each(function() { $(this).css("margin-right", "20px").css("float", "left"); });
    $(".ui-tabs .ui-tabs-panel img[align='right']").each(function() { $(this).css("margin-left", "20px").css("float", "right"); });
    
    if(window.location.href.toLowerCase().indexOf("/cooking/rotisseries/") > -1){
    	$.getScript("/js/rotisseriecalc.js");
    }

});

function selectTab(idx) {
    $("#tabs").tabs("select", idx);
}

function playVideo(ekid) {

}

