// JavaScript Document
$(function() {

    //焦点图切换
    var slideView = function(i) {
        $("#slideImg a").eq(i).fadeIn().siblings().hide();
        $("#trigger a").eq(i).addClass("selected").siblings().removeClass("selected");
    };

    //自动切换
    var item = 0,
		els = $("#slideImg a").length,
	    timer = setInterval(function() {
	        slideView(item);
	        item = (item + 1) % els;
	    }, 3000);

    //鼠标经过触发器切换
    $("#trigger a").each(function(i) {
        $(this).hover(function() {
            clearInterval(timer);
            slideView(i);
        }, function() {
            item = i + 1;
            timer = setInterval(function() {
                slideView(item);
                item = (item + 1) % els;
            }, 3000);
        });
    });

    //斑马线
    $(".tabBdListWrap > li:odd").css("background-color", "#f0f8f3");
    $(".list > li:odd").css("background-color", "#eaeaea");

    //切换 
    $("a", ".hds").each(function(i) {
        $(this).hover(function() {
            $(this).siblings().removeClass("hdSelected").end().addClass("hdSelected");
            var itemWidth = $(".tabBdListWrap", "#tabBd").width();
            $("#tabBd").animate({ right: itemWidth * i }, 600);
            return false;
        });
    });



    $("#footerMiddle a").each(function(i) {
        $(this).hover(function() {
            $(this).addClass("footerselected").siblings("a").removeClass("footerselected");
            $("#footerAddress .hoverAddress").eq(i).show().siblings().hide();
            return false;
        });
    });


    $(function() {
        $("#activityBd").marquee({
            direction: "up",
            scrollDelay: 50
        });
    });

    $(function() {
        $("#slider2").marquee({
            direction: "up",
            scrollDelay: 50
        });
    })

    $(function() {
        $("#slider3").marquee({
            direction: "up",
            scrollDelay: 50
        });
    })


    $(function() {
        var time = 0;
        var sle = $("#mainImage div").length;
        setInterval(function() {
            $("#mainImage div").eq(time).fadeIn().siblings().hide();
            time++;
            time = time % sle;
        }, 2000)
    });

    $(document).ready(function() {
        var x = 10;
        var y = 20;
        $("a.tooltip").mouseover(function(e) {
            this.myTitle = this.title;
            this.title = "";
            var imgTitle = this.myTitle ? "<br/>" + this.myTitle : "";
            var tooltip = "<div id='tooltip'><img src='" + this.href + "' alt='产品预览' />" + imgTitle + "</div>";
            $("body").append(tooltip);
            $("#tooltip")
			.css({
			    "top": (e.pageY + y) + "px",
			    "left": (e.pageX + x) + "px"
			}).show("fast");
        }).mouseout(function() {
            this.title = this.myTitle;
            $("#tooltip").remove();
        }).mousemove(function(e) {
            $("#tooltip")
			.css({
			    "top": (e.pageY + y) + "px",
			    "left": (e.pageX + x) + "px"
			});
        });
    });

    $(".startGame").click(function() { $(".startGame").hide(); $("#bigOne").show(); });
    $(".continue1").click(function() { $("#bigOne").hide(); $("#bigTwo").show(); });
    $(".continue2").click(function() { $("#bigTwo").hide(); $("#bigThree").show(); });
    $(".continue3").click(function() { $("#bigThree").hide(); $("#bigFour").show(); });
    $(".continue4").click(function() { $("#bigFour").hide(); $("#bigFive").show(); });
    $(".continue5").click(function() { $("#bigFive").hide(); $("#bigSix").show(); });
    $(".continue6").click(function() { $("#bigSix").hide(); $("#bigSeven").show(); });

});


