// JavaScript Document
jQuery(function($) {
    var index = 0;
    var width = jQuery("#myjQueryNav li:first").width();
    jQuery('<div id="flow"></div>').appendTo("#myjQueryNav");

    //自动播放
    var MyTime = setInterval(function() {
        ShowjQueryFlash(index, width);
        index++;
        if (index == 4) { index = 0; }

    }, 5000);

    //滑动导航改变内容
    jQuery("#myjQueryNav li").hover(function() {
        if (MyTime) {
            clearInterval(MyTime);
        }
        index = jQuery("#myjQueryNav li").index(this);
        MyTime = setTimeout(function() {
            ShowjQueryFlash(index, width);
            jQuery('#myjQueryContent').stop();
        }, 0);

    }, function() {
        clearInterval(MyTime);
        MyTime = setInterval(function() {
            ShowjQueryFlash(index, width);
            index++;
            if (index == 4) { index = 0; }
        }, 5000);
    });
    //滑入 停止动画，滑出开始动画.
    jQuery('#myjQueryContent').hover(function() {
        if (MyTime) {
            clearInterval(MyTime);
        }
    }, function() {
        MyTime = setInterval(function() {
            ShowjQueryFlash(index, width);
            index++;
            if (index == 4) { index = 0; }
        }, 5000);
    });

});
function ShowjQueryFlash(i, width) {
    jQuery("#myjQueryContent div").eq(i).animate({ opacity: 1 }, 1000).css({ "z-index": "1" }).siblings().animate({ opacity: 0 }, 1000).css({ "z-index": "0" });
    jQuery("#flow").animate({ left: i * width + 3 + "px" }, 300); //滑块滑动
    jQuery("#myjQueryNav li").eq(i).addClass("current").siblings().removeClass("current");
}
