$("document").ready(function () {
    $(".nav > li").hover(function () {
        //$(this).addClass("on");
        $(this).children("div").stop(true, true).slideDown("fast");
    }, function () {
        //$(this).removeClass("on");
        $(this).children("div").stop(true, true).slideUp("fast");
    })
    $("#navChild a:last-child ").css("border-bottom", "none");


    $(".searchbd").click(function () {
        $(".search").css("display", "block");
    })

    $(".proListPic ul li:nth-child(3n)").css("margin-right", "0px");
    $(".proListPic .pic").hover(function () {
        $(this).find(".zoom").css("display", "block");
    }, function () {
        $(this).find(".zoom").css("display", "none");
    })

    $(".newsList dl:nth-child(2n)").css("margin-right", "0px");
    $(".casePicUl li:last-child").css("margin-right", "0px");
    $(".claPicUl li:last-child").css("margin-right", "0px");

    $(".footClose").click(function () {
        $(".footOneBox").css("display", "none");
    })


    $('.codepic').hover(function () {
        $('.code').fadeIn()
    }, function () {
        $('.code').fadeOut()
    });
    $('.backup').hover(function () {
        //alert("aa");
        $('.fontBack').animate({ left: '-65px' }, 100);
        $('.backup').css("border-left", "1px solid #f39c11");
        //$('.backup').css("color","#FF0000");
    }, function () {
        //alert("bb");
        $('.fontBack').animate({ left: '0px' }, 100)
        $('.backup').css("border-left", "1px solid #eeeeee");
    });
    $('.backup').click(function () {
        $('.fontBack').animate({ left: '0px' }, 300)
        $('body,html').animate({ scrollTop: 0 }, 500)
    });
    $(".backup").hide();
    $(".fontBack").hide();
    $(function () {
        $(window).scroll(function () {
            if ($(window).scrollTop() > 500) {
                $(".backup").fadeIn(1000);
                $(".fontBack").fadeIn(2500);
            } else {
                $(".backup").fadeOut(1000);
                $(".fontBack").hide();
            }
        });
    });

    $(".leftProClaList > ul > li ").click(function () {
        $(this).next("ul").slideToggle();
        $(this).toggleClass("open");
    });
    $(".leftProClaList > ul > li ").hover(function () {
        $(this).toggleClass("on");
    });

    $(".pglist ul li").not(".on").hover(function () {
        $(this).addClass("on");
    }, function () {
        $(this).removeClass("on");
    })

    $(".footPicList ul li:nth-child(2n+1)").css("padding-right", "25px");
    $(".footPicList ul li:nth-child(2n)").css({ "padding-left": "24px", "border-left": "1px solid #d2d2d2" });
});


$("document").ready(function () {
    //case
    var page = 1;
    var i = 1;
    var box = $('.advPic ul');
    var n = $('.advPic li').length;
    var h = $('.advPic li').width();
    var pagetotal = Math.ceil(n / i);
    $('.picleft').bind('click', upwardsfn);
    $('.picright').bind('click', downfn);

    function upwardsfn() {
        if (page > 1) {
            box.animate({ marginLeft: '+=' + h }, "slow");
            page--;
            $(".picright").find("img").attr('src', 'images/advrightb.png');
            if (page <= 1) {
                $('.picleft').find("img").attr('src', 'images/advleftw.png');
            } else {
                $('.picleft').find("img").attr('display', 'images/advleftb.png');
            }
        }
    }

    function downfn() {
        if (pagetotal > page) {
            box.animate({ marginLeft: '-=' + h }, "slow");
            page++;
            $(".picleft").find("img").attr('src', 'images/advleftb.png');
            if (page >= pagetotal) {
                $('.picright').find("img").attr('src', 'images/advrightw.png');
            } else {
                $('.picright').find("img").attr('src', 'images/advrightb.png');
            }
        }
    }

});


//导航定位
function dingwei() {
    var links = $("#nav > li");
    var lilen = $("#nav").find(".navLi");
    //alert(links.length);
    var st2 = new Array();
    var str1 = new Array();
    var urrenturl = document.location.href;
    urrenturl = urrenturl.replace("http://", "");
    var urrenturlArr = urrenturl.split("/");
    var name = urrenturlArr[urrenturlArr.length - 1];
    st2 = name.split("_");
    alert(st2[0]);
    var last = 0;
    for (var i = 0; i < links.length; i++) {
        linkurl = lilen[i].getAttribute("rel");
        str1 = linkurl.split("/");
        var length2 = str1.length - 1;
        str11 = str1[length2].split(".");
        if (st2[0].indexOf(str11[0]) != -1) {
            last = i;
        }
    }
    links[last].className = "menu";
}

function scrolling(a, b, c) {
    var speedp = 30;
    var tabp = document.getElementById(a);
    var tab1p = document.getElementById(b);
    var tab2p = document.getElementById(c);
    tab2p.innerHTML = tab1p.innerHTML;

    function Marqueep() {
        if (tab2p.offsetWidth - tabp.scrollLeft <= 0)
            tabp.scrollLeft -= tab1p.offsetWidth
        else {
            tabp.scrollLeft++;
        }
    }

    var MyMarp = setInterval(Marqueep, speedp);
    tabp.onmouseover = function () {
        clearInterval(MyMarp)
    };
    tabp.onmouseout = function () {
        MyMarp = setInterval(Marqueep, speedp)
    };
}

function upscrolling() {
    var speed = 40;
    sdemo2.innerHTML = sdemo1.innerHTML;

    function Marquee() {
        if (sdemo2.offsetHeight - sdemo.scrollTop <= 0) {
            sdemo.scrollTop -= sdemo1.offsetHeight;
        } else {
            sdemo.scrollTop++;
        }
    }

    var MyMar = setInterval(Marquee, speed);
    sdemo.onmouseover = function () {
        clearInterval(MyMar);
    }
    sdemo.onmouseout = function () {
        MyMar = setInterval(Marquee, speed)
    }
}

$(function () {
    var wh = $(window).height();
    // console.log(wh);
    var zz = $(document).height() - wh - 199;
    var win = $(window).scrollTop();
    // console.log(zz);
    if (win >= zz) {
        $(".footOneBox").css("position", "relative");
    } else {
        $(".footOneBox").css("position", "fixed");
    }
    $(window).bind("scroll", function (e) {
        var win = $(window).scrollTop();
        // console.log(win);
        if (win >= zz) {
            $(".footOneBox").css("position", "relative");
        } else {
            $(".footOneBox").css("position", "fixed");
        }
    });
})
