var imgInterval; var i = 0;
$(function() {
    $(".imgBox").append("<div class='imgNum'></div>");
    var s = $(".imgShow").size();
    for (var j = 1; j <= s; j++) {
        var num = "<div class='num'>" + j + "</div>";
        if (j == s) {
            num = "<div class='num seld'>" + j + "</div>";
        }
        $(".imgNum").append(num);
    }
    $(".num").click(function() {
        $(".imgShow").css("z-index", 0);
        i = $(this).text() - 1;
        imgPlayer();
    });
    imgInterval = setInterval("imgPlayer()", 3000);
    $(".imgBox").mouseover(function() {
        imgInterval = clearInterval(imgInterval);
    });
    $(".imgBox").mouseout(function() {
        imgInterval = setInterval("imgPlayer()", 3000);
    });
});

function imgPlayer() {
    if (i >= $(".imgShow").size()) {
        i = 0;
        $(".imgShow").css("z-index", 0);
        $(".num").removeClass("seld");
    }
    $(".imgShow").eq(i).css("z-index", i + 1);
    $(".num").removeClass("seld");
    $(".num").eq(i).addClass("seld");
    i++;
}