var v = left = 0,right=1, countindex;
var t = n = 0, count;
$(document).ready(function(){
    count=$("#banner_list a").length;
    $("#banner_list a:not(:first-child)").hide();
    $("#banner_info").html($("#banner_list a:first-child").find("img").attr('alt'));
    $("#banner_info").click(function(){
        window.open($("#banner_list a:first-child").attr('href'), "_blank")
    });
    $("#banner li").click(function() {
        var i = $(this).text() - 1;//获取Li元素内的值，即1，2，3，4
        n = i;
        if (i >= count) return;
        $("#banner_info").html($("#banner_list a").eq(i).find("img").attr('alt'));
        $("#banner_info").unbind().click(function(){
            window.open($("#banner_list a").eq(i).attr('href'), "_blank")
        })
        $("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
        $("#banner li").eq(n).css({
            "background-color": "#CB0003",
            "color":'#ffffff'
        }).siblings().css({
            "background-color":"#9A9899",
            "color":'#ffffff'
        });
    });
    t = setInterval("showAuto()", 10000);
    $("#banner").hover(function(){
        clearInterval(t)
    }, function(){
        t = setInterval("showAuto()", 4000);
    });
    //
//    countindex=$("#holder i").length;
//    $("#prevlast").click(function() {
//        $("#holder i").eq(left).animate({
//            width: "0px"
//        }, 0 );
//        $("#holder i").eq(right).animate({
//            width: "0px"
//        }, 0 );
//        right=right-2;
//        right = right < 0 ? countindex : right;
//        left=right-1;
//        $("#holder i").eq(left).animate({
//            width: "386px"
//        }, 0 );
//        $("#holder i").eq(right).animate({
//            width: "386px"
//        }, 0 );
//        $("#holder").hover();
//    });
//    $("#prevnext").click(function() {
//        showAutoindex();
//        $("#holder").hover();
//    });
//
//    t = setInterval("showAutoindex()", 4000);
//    $("#holder").hover(function(){
//        clearInterval(t)
//    }, function(){
//        t = setInterval("showAutoindex()", 4000);
//    });
})

//function showAutoindex()
//{
//    $("#holder i").eq(left).animate({
//        width: "0px"
//    }, 0 );
//    $("#holder i").eq(right).animate({
//        width: "0px"
//    }, 0 );
//    right = right >=(countindex - 1) ? 1 : right+2;
//    left=right-1;
//    $("#holder i").eq(left).animate({
//        width: "386px"
//    }, 0 );
//    $("#holder i").eq(right).animate({
//        width: "386px"
//    }, 0 );
//}

function showAuto()
{
    n = n >=(count - 1) ? 0 : ++n;
    $("#banner li").eq(n).trigger('click');
}



