﻿$(document).ready(function() {
    var showID = "";
    if (queryJson.TradeMarkId != "00" && queryJson.Pager.PageNumber == 1) {
        showID = queryJson.CurrentClassId + "-" + queryJson.TradeMarkId;
    } else if (queryJson.TradeMarkId == "00" && queryJson.Pager.PageNumber == 1) {
        showID = queryJson.CurrentClassId;
    } else {
        showID = "";
    }
    var id = queryJson.ClassId1;
    if ((queryJson.ItemType == "2" && id == "N1") || queryJson.ItemType == "3" || queryJson.ItemType == "4") {
        return;
    }
    else {
        if (showID != "") {
            var showURL = "Style/tj_" + queryJson.ItemType + ".html #" + showID;
            $("#rec").load(showURL, function() {
                $("#brand-alt li").hover(function() {
                    stopPlay();
                    $('#brand-alt li img').stop(false, true);
                    $(this).find("img").stop().animate({ marginTop: "-60px" }, 350)
                }, function() {
                    if (!$(".extend-btn").hasClass("extend-up")) {
                        autoPlay();
                    }
                    $(this).find("img").stop().animate({ marginTop: "0px" }, 250)
                })
                $("#alt-extend-btn").toggle(
							function() {
							    stopPlay();
							    $("#scroll-ul").animate({ height: "286px" }, 400);
							    $("#brand-alt>ul").slideDown();
							    $(this).addClass("extend-up");
							    $(".extend-btn").html("收起");
							    return false;
							},
							  function() {
							      autoPlay();
							      $("#scroll-ul").animate({ height: "143px" }, 400);
							      $("#brand-alt>ul").slideUp();
							      $(this).removeClass("extend-up");
							      $(".extend-btn").html("显示更多品牌");
							      return false;
							  }
							);
                function alt() {
                    $("#scroll-ul>div").animate({
                        marginTop: "-143px"
                    }, 1000, function() {
                        $(this).css({ marginTop: "0px" }).find("ul:first").appendTo(this);
                    });
                }
                var autoPlay = function() {
                    timerID = window.setInterval(alt, 3500);
                };
                var stopPlay = function() {
                    window.clearInterval(timerID);
                };
                $(document).ready(function() {
                    autoPlay();
                });

            });
        }
    }
});
