﻿$(function () {
    var widthOfItem = $(".item").width();
    var width = ($("#bannerUL li").length) * widthOfItem;
    $("#bannerUL").css({ "width": width + "px", "height": "90px" });

    startShow("start");

    function startShow(value) {
        var Show = setInterval(forward,10000);
    }



    function forward() {
        var left = $("#bannerUL").css("left").replace("px", "");
        var leftNum = parseInt(left);
        var widthNum = parseInt(width);
        var widthofItemNum = parseInt(widthOfItem);
        var newLeft = (leftNum - widthofItemNum);
        if (widthNum == (-1 * newLeft)) {
            newLeft = 0;
        }
        $("#bannerUL").css("left", newLeft + "px");
    }

    function previous() {
        var left = $("#bannerUL").css("left").replace("px", "");
        var leftNum = parseInt(left);
        var widthNum = parseInt(width);
        var widthofItemNum = parseInt(widthOfItem);
        var newLeft = (leftNum + widthofItemNum);
        if (leftNum == 0) {
            newLeft = -1 * (width - widthOfItem);
        }
        $("#bannerUL").css("left", newLeft + "px");
    }
});


