﻿$(document).ready(function() {
    // Prepair for scrollable
    // **************************************************
    $("div#scrollable .items > div > span:nth-child(2)").addClass("right");

    $("div#scrollable .items > div > span a").each(function() {
        if ($(this).hasClass("True")) {
            $(this).parent("span").addClass("wide");
            $(this).parent("span").parent("div").addClass("center");
        }

        $(this).removeClass("False");
        $(this).removeClass("True");
    });

    // Check if the div should be visible
    var shouldBeVisible = false;

    if ($('#wideLayout').length > 0) { shouldBeVisible = false; }
    else if ($('#startLayout').length > 0) { shouldBeVisible = false; }
    else if ($("div#scrollable .items").children().size() > 0) { shouldBeVisible = true; }

    if (shouldBeVisible) { $("div#latestViewedProducts").css("display", "inline"); }

    // Check if next button should have the disabled class
    if ($("div#scrollable .items").children().size() < 3) {
        $("div#latestViewedProducts a.next").addClass("disabled");
    }

    // initialize scrollable    
    $("div#scrollable").scrollable({
        vertical: true,
        size: 2
    });
});