﻿$("#divAboutAndContact .Categories a").click(function () {
    var eleA = $(this);
    var forId = eleA.attr("for");
    eleA.parent().children("a").each(function (index, a) {
        if ($(a).attr("for") == forId) {
            $(a).addClass("active");
        }
        else {
            $(a).removeClass("active");
        }
    });
    $(".detail").children("div").each(function (index, div) {
        if (div.id == forId) {
            $(div).removeClass("collapse");
        }
        else {
            $(div).addClass("collapse");
        }
    });
});


$("div.gallery").each(function (index, gallery) {
    $(gallery).gallery({
        autoplay: true
    });
});

$("#divTypicalCustomers .carousel").each(function (index, element) {
    var totalWidth = $(".container").width();
    var colAutoWidth = 0;
    $(element).parent().parent().children(".col-auto").each(function (index, element) {
        colAutoWidth += Math.abs($(element).width());
    });
    var carouselWidth = totalWidth - colAutoWidth - 40;
    $(element).width(carouselWidth);
    var div = $(element).children("div");
    var imgCount = div.children("img").length;
    var width = imgCount * 304;//图片宽+间距
    div.width(width);
    if (width < totalWidth)
        return;
    function startAnimation() {
        if (parseInt(div.css("left"), 10) <= parseInt(carouselWidth - width)) {
            div.css("left", 0);
        }
        div.animate({ left: (carouselWidth - width) + "px" }, imgCount * 1000, "linear", function () { startAnimation(); });
    }
    startAnimation();
    div.mouseenter(function () {
        $(this).stop();
    });
    div.mouseleave(function () {
        if ($(this).is('.animated')) {
        } else {
            startAnimation();
        }
    });
});