var t = n = 0, count;
$(document).ready(function () {
    count = $("#banner_list a").length;
    if (count <= 1) return;
    var lis = "<li class='on'>1</li>";
    for (var i = 2; i <= count; i++) {
        lis += "<li>" + i + "</li>";
    }
    $("#banner_index").append(lis);
    $("#banner_list a:not(:first-child)").hide();
    $("#banner_title").html($("#banner_list a:first #_title").html());
    $("#banner_index li").click(function () {
        var i = $(this).text() - 1;
        n = i;
        if (i >= count) return;
        var $A = $("#banner_list a:visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
        $("#banner_title").html($("#_title", $A).html());
        $(this).toggleClass("on");
        $(this).siblings().removeAttr("class");
    });
    t = setInterval("showAuto()", 4000);
    $("#banner").hover(function () { clearInterval(t) }, function () { t = setInterval("showAuto()", 4000); });
});

function showAuto() {
    n = n >= (count - 1) ? 0 : ++n;
    $("#banner li").eq(n).trigger('click');
}


var t1 = n1 = 0, count1;
$(document).ready(function () {
    if ($("#aflash").get(0)) {
        count1 = $("#aflash_index a").length;
        if (count1 <= 1) return;

        $("#aflash_list a:not(:first-child)").hide();

        $("#aflash_index a").each(function () {
            var maskLayer = '<div style="width:' + $(this).width() + 'px;height:' + $(this).height() + 'px;" class="maskLayer"></div>';
            $(this).prepend(maskLayer);
        });
        $("#aflash_index").hover(function () {
        }, function () {
            $(".maskLayer", $(this)).removeClass("maskLayer_5");
        });
        $("#aflash_index .maskLayer").hover(function () {
            $("#aflash_index .maskLayer").addClass("maskLayer_5");
            $(this).removeClass("maskLayer_5");
        }, function () {
        });

        $("#aflash_index li").hover(function () {
            var i1 = $(this).index();
            n1 = i1;
            if (i1 >= count1) return;
            $("#aflash_list a:visible").fadeOut(500).parent().children().eq(i1).fadeIn(1000);
        }, function () {
        });
        t1 = setInterval("showAuto1()", 4000);
        $("#aflash").hover(function () { clearInterval(t1) }, function () { t1 = setInterval("showAuto1()", 4000); });
    }
});

function showAuto1() {
    n1 = n1 >= (count1 - 1) ? 0 : ++n1;
    $("#aflash li").eq(n1).trigger('click');
}

