﻿$(document).ready(function() {
    $.preloadCssImages();
    $('ul.collapsing-menu').superfish({ autoArrows: false, dropShadows: false, animation: { height: 'show'} });
    initVerticalMenu();
    wrapTextBoxes();
    wrapTextAreas();
    initCarousels();

    $('div.login').find('label:contains("Password:")').text("Membership ID:");


});

function initVerticalMenu() {
    $('ul.vertical-collapsing-menu li').filter(function(index) {
        if (!$(this).hasClass("selected") && !$(this).hasClass("child-selected")) {
            return true;
        }
        else {
            return false;
        }
    }).find("ul:first").hide();
}

function wrapTextBoxes() {
    $("input[type=text]").wrap('<div class="tb-container" />');
    $("input[type=password]").wrap('<div class="tb-container" />');
}

function wrapTextAreas() {
    $("textarea").wrap('<div class="ta-container" />');
}

function initCarousels() {

    $("div.related-product-listings-3").each(function() {

        if ($(this).find("li").length > 3) {

            $(this).wrap("<div class=\"carousel-container\" />");
            $(".carousel-container").append("<div class=\"carousel-previous-button\" />");
            $(".carousel-container").append("<div class=\"carousel-next-button\" />");

            $(this).jCarouselLite({
                btnNext: ".carousel-next-button",
                btnPrev: ".carousel-previous-button",
                scroll: 1,
                visible: 3,
                circular: true
            });
        }

    });

    $("div.related-product-listings-4").each(function() {

        if ($(this).find("li").length > 3) {
            $(this).wrap("<div class=\"large-carousel-container\" />");
            $(".large-carousel-container").append("<div class=\"carousel-previous-button\" />");
            $(".large-carousel-container").append("<div class=\"carousel-next-button\" />");

            $(this).jCarouselLite({
                btnNext: ".carousel-next-button",
                btnPrev: ".carousel-previous-button",
                scroll: 1,
                visible: 4,
                circular: true
            });
        }

    });
}

