﻿$(document).ready(function () {

    var sHtml = $(".slider li:last-child").html();
    sHtml = "<li>" + sHtml + "</li>";
    var sSliderHtml = $(".slider").html();
    $(".slider").html(sHtml + sSliderHtml);

    var len = $(".num > li").length;
    var index = 1;
    var adTimer;
    $(".num li").mouseover(function () {
        index = $(".num li").index(this);
        showImg(index);
    })
    //$(".num li").eq(0).mouseover();
    //滑入 停止动画，滑出开始动画.
    $('#advUp').hover(function () {
        clearInterval(adTimer);
    }, function () {
        adTimer = setInterval(function () {
            showImg(index)
            index++;
            if (index == len) { index = 0; }
        }, 3000);
    });
    $('#advUp').trigger("mouseleave");
})
// 通过控制top ，来显示不同的幻灯片
function showImg(index) {
    var adHeight = $("#advUp").height();
    if (index == 0) {
        $(".slider").stop(true, false).animate({ top: -adHeight * index }, 0);
        $(".slider").stop(true, false).animate({ top: -adHeight * (index + 1) }, 500);
    } else {
        $(".slider").stop(true, false).animate({ top: -adHeight * (index + 1) }, 500);
    }
    $(".num li").removeClass("on")
			.eq(index).addClass("on");
}
$(function(){
    $('#slides').slides({
        preload: true,
        preloadImage: 'img/loading.gif',
        play: 0,
        pause: 0,
        hoverPause: true,
        animationStart: function(){
            $('.caption').animate({
                bottom: -35
            }, 100);
        },
        animationComplete: function(current){
            $('.caption').animate({
                bottom: 0
            }, 200);
            if (window.console && console.log) {
                // example return of current slide number
                console.log(current);
            };
			}
    });
});

$(document).ready(function(){
    //(内容)选项卡处理。
    $("span.tab").mouseover(function(){
        $(".active").removeClass("active");
        $(this).addClass("active");
        $(".page").slideUp(0);
        var content_show = $(this).attr("title");
        $("#" + content_show).slideDown(0);
    });
    //公告处理。
    $("span.NoticeTab").mouseover(function(){
        $(".NoticeActive").removeClass("NoticeActive");
        $(this).addClass("NoticeActive");
        $(".NoticePage").slideUp(0);
        var content_show = $(this).attr("title");
        $("#" + content_show).slideDown(0);
    })
})



