// JavaScript Document

//自动识别手机和电脑
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 || u.indexOf('iPhone') > -1) {//手机
    window.location.href = "http://m.maotui.cn"
}
$(document).ready(function () {
    //导航
    //$(window).scroll(function () {
    //    var scroll_top = $(document).scrollTop();
    //    if (scroll_top > 440) {
    //        $(".nav").addClass("cbgs");
    //    }
    //    else { $(".nav").removeClass("cbgs"); }
    //});


    /*****************banner********************/

    var qiehuan = $(".nav_banner ul li");
    var btenr = $(".btn_btn span")
    var speed = 4000;
    var nowindex = 0;
    var length = qiehuan.length;


    qiehuan.eq(nowindex).fadeIn('slow').siblings().fadeOut('slow');

    function play() {
        nowindex++;
        if (nowindex > length - 1) { nowindex = 0 }
        qiehuan.eq(nowindex).fadeIn('slow').siblings().fadeOut('slow');
        btenr.eq(nowindex).addClass('curus').siblings().removeClass('curus');
    }

    btenr.click(function () {
        clearInterval(tme)
        nowindex = $(this).index()
        qiehuan.eq(nowindex).fadeIn('slow').siblings().fadeOut('slow');
        btenr.eq(nowindex).addClass('curus').siblings().removeClass('curus');

        tme = setInterval(play, speed)

    })
    $(".btnleft").click(function () {

        clearInterval(tme)
        nowindex = nowindex - 1;
        if (nowindex < 0) { nowindex = length - 1 }
        qiehuan.eq(nowindex).fadeIn('slow').siblings().fadeOut('slow');
        btenr.eq(nowindex).addClass('curus').siblings().removeClass('curus');

        tme = setInterval(play, speed)

    })
    $(".btnright").click(function () {

        clearInterval(tme)
        nowindex++;
        if (nowindex > length - 1) { nowindex = 0 }
        qiehuan.eq(nowindex).fadeIn('slow').siblings().fadeOut('slow');
        btenr.eq(nowindex).addClass('curus').siblings().removeClass('curus');

        tme = setInterval(play, speed)

    })
    $(".banner").hover(function () {
        $(".btnxsd").fadeIn();
    }, function () {
        $(".btnxsd").fadeOut();
    })


    tme = setInterval(play, speed)

    if ($(window).width() < 600) {
        $('#jump').hide();
    }
    else {

        $(window).scroll(function () {
            if ($(window).scrollTop() > 500) {
                $('#jump').fadeIn();
            } else {
                $('#jump').fadeOut();
            }
        });
    }

    $("#top").click(function () {
        $('body,html').animate({
            scrollTop: 0
        },
        500);
        return false;
    });
    $("#weixin").mouseenter(function () {
        $("#EWM").fadeIn();
    })
    $("#weixin").mouseleave(function () {
        $("#EWM").hide();
    })

    //var speqiegs = $("#J_gamesMenu ul li");
    //var sgs = 0;
    //function specialplaygs() {
    //    sgs++;
    //    if (sgs > speqiegs.length - 3) {
    //        sgs = 0;
    //    }
    //    $("#J_gamesMenu ul").animate({ left: -(sgs * 369) }, 500)
    //}

    /**首页滚动**/
    //$("#J_gamesMenu .next").click(function () {

    //    specialplaygs()
    //    return false
    //})

    //$("#J_gamesMenu .prev").click(function () {
    //    sgs--;
    //    if (sgs < 0) {
    //        sgs = speqiegs.length - 3
    //    }
    //    $("#J_gamesMenu ul").animate({ left: -(sgs * 369) }, 500)
    //    return false
    //})



    /*****************首页猫推平台********************/
    var qiehuan2 = $(".index_zx .service ul.serviceu1 li");
    var btenr2 = $(".index_zx .service  ul.serviceu2 li")
    var btnp2 = $(".index_zx .service  ul.serviceu2 li p")
    var speed2 = 4000;
    var nowindex2 = 0;
    var length2 = qiehuan2.length;


    qiehuan2.eq(nowindex2).fadeIn('slow').siblings().fadeOut('slow');

    function play2() {
        nowindex2++;
        if (nowindex2 > length2 - 1) { nowindex2 = 0 }
        qiehuan2.eq(nowindex2).fadeIn('slow').siblings().fadeOut('slow');
        btnp2.removeClass('curus');
        btnp2.eq(nowindex2).addClass('curus');
    }

    btenr2.hover(function () {
        clearInterval(tme2)
        nowindex2 = $(this).index()
        qiehuan2.eq(nowindex2).fadeIn('slow').siblings().fadeOut('slow');
        btnp2.removeClass('curus');
        btnp2.eq(nowindex2).addClass('curus');

        tme2 = setInterval(play2, speed2)

    })
    tme2 = setInterval(play2, speed2)





    /*****************development********************/
    var qiehuan1 = $(".pt_li .pt_nav li");
    var btenr1 = $(".pt_li .pt_btn span")
    var speed1 = 4000;
    var nowindex1 = 0;
    var length1 = qiehuan1.length;


    qiehuan1.eq(nowindex1).fadeIn('slow').siblings().fadeOut('slow');

    function play1() {
        nowindex1++;
        if (nowindex1 > length1 - 1) { nowindex1 = 0 }
        qiehuan1.eq(nowindex1).fadeIn('slow').siblings().fadeOut('slow');
        btenr1.eq(nowindex1).addClass('curus').siblings().removeClass('curus');
    }

    btenr1.hover(function () {
        clearInterval(tme1)
        nowindex1 = $(this).index()
        qiehuan1.eq(nowindex1).fadeIn('slow').siblings().fadeOut('slow');
        btenr1.eq(nowindex1).addClass('curus').siblings().removeClass('curus');

        tme1 = setInterval(play1, speed1)

    })
    tme1 = setInterval(play1, speed1)

    /*****************ChessCard********************/
    $(".chesscard-2 li").hover(function () {
        $(this).find("span").stop().fadeIn();
    }, function () {
        $(this).find("span").stop().fadeOut();
    })


    /*****************返回顶部********************/
    if ($(window).width() < 600) {
        $('#jump').hide();
    }
    else {

        $(window).scroll(function () {
            if ($(window).scrollTop() > 500) {
                $('#jump').fadeIn();
            } else {
                $('#jump').fadeOut();
            }
        });
    }

    $("#top").click(function () {
        $('body,html').animate({
            scrollTop: 0
        },
		500);
        return false;
    });
    $("#weixin").mouseenter(function () {
        $("#EWM").fadeIn();
    })
    $("#weixin").mouseleave(function () {
        $("#EWM").hide();
    })
    /*****************返回顶部END********************/

});


/************************************************************************/
/* DateTime转换成Json                                                   */
/************************************************************************/
function ConvertJSONDateToJSDateObject(jsondate) {
    var date = new Date(parseInt(jsondate.replace("/Date(", "").replace(")/", ""), 10));
    return date;
}

/* 获取日期格式 */
function getDate(date) {
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    return year + "-" + month + "-" + day;
}
/* 获取日期时间格式*/
function getDateTime(date) {
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hh = date.getHours();
    var mm = date.getMinutes();
    var ss = date.getSeconds();
    return year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;
}