﻿function showVideoAd() {
    var curr = 0;
    $("#jsNav .trigger").each(function(i) {
        $(this).first().nextAll().addClass("imgBefore");
        $(this).click(function() {
            curr = i;
            $("#js img").eq(i).fadeIn("slow").siblings("#js img").hide();
            $(this).siblings(".trigger").removeClass("imgSelected").addClass("imgBefore").end().removeClass("imgBefore").addClass("imgSelected");
            return false;
        });
    });
    var pg = function(flag) {
        //flag:true表示前翻， false表示后翻
        if (flag) {
            if (curr == 0) {
                todo = 2;
            } else {
                todo = (curr - 1) % 3;
            }
        } else {
            todo = (curr + 1) % 3;
        }
        $("#jsNav .trigger").eq(todo).click();
    };
    //自动翻
    var timer = setInterval(function() {
        todo = (curr + 1) % 3;
        $("#jsNav .trigger").eq(todo).click();
    }, 4000);
    //鼠标悬停在触发器上时停止自动翻
    $("#jsNav a").hover(
        function() {
            clearInterval(timer);
        },
	    function() {
	        timer = setInterval(function() {
	            todo = (curr + 1) % 3;
	            $("#jsNav .trigger").eq(todo).click();
	        }, 1500);
	    }
    );
}

function showCommend() {
    $("#num li:eq(0)").addClass("on").css("color", "#FFF");
    var len = $("#num > li").length;
    var index = 0;
    $("#num li").mouseover(function() {
        index = $("#num li").index(this);
        showImages(index);
    });
    $("#commendList").hover(function() {
        if (MyTime) {
            clearInterval(MyTime);
        }
    }, function() {
        MyTime = setInterval(function() {
            showImages(index)
            index++;
            if (index == len) { index = 0; }
        }, 4000);
    });
    var MyTime = setInterval(function() {
        showImages(index)
        index++;
        if (index == len) { index = 0; }
    }, 4000);
}
function showImages(i) {
    $("#commendList").stop(true, false).animate({ top: -122 * i }, 400);
    $("#num li").eq(i).addClass("on").css("color", "#FFF").siblings().removeClass("on").css("color", "#6e6e6e");
}

function showCommend2() {
    $("#commendList li").hide();
    $("#commendList li").eq(0).show();
    $("#num li:eq(0)").addClass("on").css("color", "#FFF");
    var len1 = $("#num > li").length;
    var index1 = 0;
    $("#num li").mouseover(function() {
        index1 = $("#num li").index(this);
        showImages1(index1);
    });
    $("#commendList").hover(function() {
        if (MyTime1) {
            clearInterval(MyTime1);
        }
    }, function() {
        MyTime1 = setInterval(function() {            
            index1++;
            if (index1 == len1) { index1 = 0; }
            showImages1(index1)
        }, 5000);
    });
    var MyTime1 = setInterval(function() {        
        index1++;
        if (index1 == len1) { index1 = 0; }
        showImages1(index1)
    }, 5000);
}
function showImages1(i) {
    $("#commendList li").hide();
    $("#commendList li").eq(i).fadeIn();
    $("#num li").eq(i).addClass("on").css("color", "#FFF").siblings().removeClass("on").css("color", "#EDA24A");
    $("#num li").eq(i).addClass("on").css("cursor", "pointer");
    $("#num li").eq(i).addClass("on").css("background-color", "#AB1B01").siblings().removeClass("on").css("background-color", "#020000"); ;
}

function floatingAd() {
    var ad = 130;
   $(window).scroll(function() {
       $("#floatingAd").animate({ top: $(window).scrollTop() + ad + "px" }, { queue: false, duration: 500 });
    });
}
function closeAd1() {
    $("#closeAd1").click(function() {
    $("#floatingAd").hide();
    });
}
function closeAd() {
    $("#closeAd").click(function() {
    $("#bigAdPic").hide();
    });
}

function showAd() {
    $("#bigAdPic").animate({ top: "0px", opacity: 'show' }, 2000);
    setTimeout("shouAd()", 8000);
}

function shouAd() {
    $("#bigAdPic").animate({ top: "-665px", opacity: 'hide' }, 2000);
}/**/
