var istouch = modernizr.touch, ismobile = false, mobile = false, scrollnav = true, navitem = 0, serachitem = 0, w_width = jquery(window).width(), w_height = jquery(window).height(), $navbox = jquery(".navbox"), $subnav = jquery(".subnav"), $mobilebox = jquery(".mobilebox"), $menubtn = jquery('#menu-handler'), $navmobile = jquery("#navmobile"), $moba = $navmobile.find("a"), $mobsubnav = $navmobile.find(".msubnav"); $serachbtn = jquery(".serachbtn"), $searchbox = jquery(".searchbox"), $mtop = jquery(".mtop"), $mtoph = $mtop.height(); var _mousemove; var _click; var _mousedown; var _mouseup; if (modernizr.touch) { _mousemove = "touchmove"; _click = "touchend"; _mousedown = "touchstart"; _mouseup = "touchend"; } else { _mousemove = "mousemove"; _click = "click"; _mousedown = "mousedown"; _mouseup = "mouseup"; }; function pagebox() { w_width = jquery(window).width(); w_height = jquery(window).height(); if (w_width <= 1024) { ismobile = true; } else if (w_width > 1024) { ismobile = false; mobpage(); }; }; function setimgmax(img, imgw, imgh, tw, th) { var twidth = tw || w_width; var theight = th || w_height; var coe = imgh / imgw; var coe2 = theight / twidth; if (coe < coe2) { var imgwidth = theight / coe; img.css({ height: theight, width: imgwidth, left: -(imgwidth - twidth) / 2, top: 0 }); } else { var imgheight = twidth * coe; img.css({ height: imgheight, width: twidth, left: 0, top: -(imgheight - theight) / 2 }); }; }; function mobpage() { navitem = 0; $menubtn.removeclass("active").removeclass("mobactive"); $mobilebox.hide(); }; function pagebanner() { if (!ismobile) { var bannerh = w_width * (590 / 1920); jquery('.pbanner').innerheight(bannerh); } else { jquery('.pbanner').css("height", "auto"); } }; pagebanner(); pagebox(); jquery(window).resize(function () { pagebox(); pagebanner(); }); function tabs(outname, outconname, focusclass, displaymethod, speed, sefs, sibling) { if (speed == null) speed = "slow"; if (focusclass == null) focusclass = "tbfocus"; if (displaymethod == null) displaymethod = 0; if (sefs == "") sefs = "click"; if (sibling == "") sibling = "li"; var sw = displaymethod; function myshow(i) { jquery(outname).eq(i).addclass(focusclass).siblings(sibling).removeclass(focusclass); jquery(outconname).fadeout(speed); jquery(outconname).eq(i).stop(true, true).slidedown(600); } myshow(sw); if (sefs == "click") { jquery(outname).click(function () { sw = jquery(outname).index(this); myshow(sw); }); } else if (sefs == "mouseover") { jquery(outname).mouseover(function () { sw = jquery(outname).index(this); myshow(sw); }); } }; if (ismobile) { $serachbtn.bind(_click, function () { if (serachitem == 0) { $menubtn.removeclass("active").removeclass("mobactive"); $mobilebox.hide(); $moba.removeclass("cur"); $mobsubnav.hide(); $searchbox.stop(false, false).css({ top: 52 }).slidedown(300); //jquery(".search-txt").focus(); navitem = 0; serachitem = 1; } else { $menubtn.removeclass("active").removeclass("mobactive"); $mobilebox.hide(); $moba.removeclass("cur"); $mobsubnav.hide(); $searchbox.stop(false, false).slideup(200); serachitem = 0; } }); $serachbtn.unbind("mouseenter mouseleave"); } else { $serachbtn.bind("mouseenter", function () { $searchbox.stop(false, false).animate({ top: 80, opacity: "show" }, 400); serachitem = 1; jquery(".search-txt").focus(); }); jquery(".searchbox").bind("mouseleave", function () { $searchbox.stop(false, false).animate({ top: 100, opacity: "hide" }, 400); serachitem = 0; }); $serachbtn.unbind(_click); } jquery(function () { $(".search-txt").keyup(function (event) { var keyvalue = event.which; var vakes = $(this).val(); if (keyvalue == 13) { if (vakes == '') { $(this).focus(); return; } window.location = 'search.aspx?keyword=' + encodeuricomponent(vakes); } }) $('.search-btn').click(function () { var vakes = $(this).prev().val(); if (vakes == '') { $(".search-txt").focus(); return; } window.location = 'search.aspx?keyword=' + encodeuricomponent(vakes); }); jquery(".backtop").bind("click", function () { jquery('html, body').stop().animate({ scrolltop: 0 }, 800, 'easeinoutexpo'); }); function setpopup(obj, title) { obj.click(function () { var str = ''; $("body").append(str); $(".popup .close").click(function () { $(".popup").remove(); }); return false; }); } //pc nav jquery(".navbox .nav li").mouseenter(function () { if (jquery(this).hasclass("hov")) { return; }; $searchbox.stop(false, false).animate({ top: 100, opacity: "hide" }, 200); serachitem = 0; jquery(".navbox .nav li").removeclass("hov"); jquery(this).addclass("hov"); jquery(".subbox").stop(false, false).animate({ top: 80, opacity: "show" }, 400).addclass("subboxact"); $subnav.removeclass("subnavact"); var subname = ".subnav" + (jquery(this).index() + 1); if (jquery(subname).length >= 1) { jquery(subname).stop(false, false).addclass("subnavact"); } }); $subnav.mouseenter(function () { if (jquery(this).hasclass("subnavact")) { return; }; $subnav.removeclass("subnavact"); jquery(this).stop(false, false).addclass("subnavact"); var linname = ".nav .line" + (jquery(this).index() + 2); jquery(".navbox .nav li").removeclass("hov"); if (jquery(linname).length >= 1) { jquery(linname).stop(false, false).addclass("hov"); } }); $navbox.bind("mouseleave", function () { jquery(".navbox .nav li").removeclass("hov"); jquery(".subbox").removeclass("subboxact"); jquery(".subbox").stop(true, true).animate({ top: 100, opacity: "hide" }, 200); $subnav.removeclass("subnavact"); }); //非pc nav //menubtn click $menubtn.bind('click', function (e) { if (navitem == 0 && scrollnav) { $menubtn.addclass("active"); $mobilebox.stop(false, false).slidedown(500); navitem = 1; serachitem = 0; $searchbox.stop(false, false).hide(); jquery('html, body').stop(false, false).animate({ scrolltop: 0 }, 700, 'easeinoutexpo'); } else if (navitem == 1 && !scrollnav) { jquery('html, body').stop(false, false).animate({ scrolltop: 0 }, 700, 'easeinoutexpo'); scrollnav = true; serachitem = 0; $searchbox.stop(false, false).hide(); } else { $menubtn.removeclass("active").removeclass("mobactive"); $mobilebox.slideup(200); navitem = 0; if (ismobile) { $moba.removeclass("cur"); $mobsubnav.hide(); } }; }); //navmobile click jquery("#navmobile>dd>p>a").bind("click", function (e) { var ydcur = $(this); var yddd = $(this).parents("p").parents("dd"); if (yddd.find(".msubnav").size() > 0) { if (ydcur.hasclass("cur")) { yddd.find(".msubnav").stop(false, false).slideup(); ydcur.removeclass("cur"); } else { $moba.removeclass("cur"); $mobsubnav.stop(false, false).slideup(); yddd.find(".msubnav").stop(false, false).slidedown(); ydcur.addclass("cur"); e.preventdefault(); } } }); function gethash() { var hash = location.href.split("#")[1]; if (hash) { if (hash != "messagebox") setscroll("#" + hash); } }; gethash(); function setscroll(anchorcur) { jquery("html,body").animate({ scrolltop: jquery(anchorcur).offset().top - $mtoph }, 800, 'easeinoutexpo'); }; jquery(window).scroll(function () { var windowtop = jquery(window).scrolltop(); var nmh = $mobilebox.height(); if (windowtop > 100) { jquery(".backtop").stop(false, false).fadein(); } else { jquery(".backtop").stop(false, false).fadeout(); }; if (navitem == 1 && windowtop > nmh) { scrollnav = false; } else { scrollnav = true; }; if (windowtop < w_height && !ismobile) { jquery('.pbanner img').css('margin-top', $(window).scrolltop() / 2); } }); jquery(".hottitle").click(function () { jquery(".hotbox").stop(false, false).animate({ left: 0 }, 400); }); jquery(".hotbox").mouseleave(function () { jquery(".hotbox").stop(false, false).animate({ left: -715 }, 400); }); var $pbanner = jquery(".pbanner"); settimeout(function () { $pbanner.find(".pbtxt .zh1").animate({ top: 0, opacity: "show" }, 400); $pbanner.find(".pbtxt .zh2").delay(200).animate({ top: 0, opacity: "show" }, 400); }, 400); var $abanner = jquery(".abanner"); settimeout(function () { $abanner.find(".abat .en").animate({ top: 0, opacity: "show" }, 400); $abanner.find(".abat .zh").delay(200).animate({ top: 0, opacity: "show" }, 400); }, 400); var $subbanner = jquery(".subbanner"); settimeout(function () { $subbanner.find(".abat .en").animate({ top: 0, opacity: "show" }, 400); $subbanner.find(".abat .zh").delay(200).animate({ top: 0, opacity: "show" }, 400); }, 400); setpopup(jquery(".sharpbox .a1"), "官方微信"); function setpopup(obj, title) { obj.click(function () { var str = '
'; $("body").append(str); jquery(".popupblack").fadein(); jquery(".popup").animate({ margintop: "-127" }, 400); $(".popup .close").click(function () { $(".popupblack").remove(); }); jquery(".popupblack").click(function () { $(".popupblack").remove(); }); return false; }); } $(".header .nav >li.more >a").on('click', function (e) { $(".header").stop().toggleclass('show'); $(this).parents('li').find('.menu-leval').stop().slidetoggle(); }); $(".headerbgs").on('click', function (e) { $(".header").stop().removeclass('show'); $(".menu-leval").slideup(); }); });