﻿var index = 1;
var si;
function imgplay() {
    imgselect(index);
    index++;
    if (index > $(".imgdata span").length) {
        index = 1;
    }
}
function imgselect(i) {
    index = i;
    $(".imgnav a").css("background", "black");
    $(".imgnav a").eq(i - 1).css("background", "darkred");
    $(".imgs").stop().animate({ left: (i - 1) * -980 }, 300);
}
function fload() {
    $(".imgbox img").attr("src", $(".imgdata b").html());
    var t = $(".imgdata span").length;
    $(".imgnav").fadeTo(10, 0.7);
    for (var i = 1; i <= t; i++) {
        var item = $(".imgdata span").eq(i - 1);
        $(".imgnav").append($("<a href='javascript:void(0)'>" + i + "</a>"));
        $(".imgs").append($("<a href='" + item.children("p").html() + "'><img src='" + item.children("b").html() + "' width='980' height='250'/></a>"));
        $(".imgs").width(i * 980);

        $(".imgnav a").mouseout(function () { clearInterval(si); si = setInterval(imgplay, 2000); });
        $(".imgnav a").mouseover(function () { clearInterval(si); });
        $(".imgnav a").click(function () { imgselect($(this).html()) });
    }
    imgplay();
    si = setInterval(imgplay, 4000);
}
