var istouch = modernizr.touch, ismobile = false,//区分移动端与pc端 mobile = false,//区分手机端与平板 w_width = 0, w_height = 0, $mtoph = 0, st = 0, navitem = 0, $menubtn = $('.menu-handler'), $menubox = $(".menubox"); //移动端事件和pc事件的切换 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 = $(window).width(); w_height = $(window).height(); $mtoph = $('.mtop').height(); if (w_width <= 1024) { ismobile = true; } else if (w_width > 1024) { ismobile = false; }; if (w_width <= 640) { mobile = true; } else if (w_width > 640) { mobile = false; }; }; pagebox(); $(window).resize(function () { pagebox(); }); $(function () { $('.ad-btn').bind(_click, function() { $(this).addclass('active'); $('.ad-wrap').addclass('show'); }); $('.ad-wrap .close').bind(_click, function() { $('.ad-btn').removeclass('active'); $(this).parents().removeclass('show'); }); var isopen = 0; $('.flinkmore .t').click(function () { if (isopen == 0) { isopen = 1; $(this).addclass('act'); $('.flinkmore ul').stop().slidedown(300); } else { isopen = 0; $(this).removeclass('act'); $('.flinkmore ul').stop().slideup(300); } }); $('.flinkmore').mouseleave(function () { isopen = 0; $(this).removeclass('act'); $('.flinkmore ul').stop().slideup(300); }); /*mobile nav*/ $menubtn.bind(_click, function () { if (navitem == 0) { jquery(this).addclass("active"); $menubox.show().stop(false, false).animate({ top: 0 }); navitem = 1; } else { $(this).removeclass("active"); $menubox.stop(false, false).animate({ top: -100 + "%" }, function () { $(this).hide(); }); navitem = 0; }; }); $('.navmobile dd p a').bind(_click, function (e) { if ($(this).parent().next('.mtnav').length >= 1) { if(!$(this).hasclass('act')){ e.preventdefault(); $('.navmobile dd p a').removeclass('act'); $('.mtnav').stop().slideup(300); $(this).addclass('act'); $(this).parent().next('.mtnav').stop().slidedown(300); }else{ $(this).removeclass('act'); $(this).parent().next('.mtnav').stop().slideup(300); } } }); /* page banner */ settimeout(function () { $('.pbtxts .transy').addclass('transshow'); $('.pbtxts .transx').addclass('transshow'); $('.pbtxts .transx2').addclass('transshow'); }, 100); $(window).scroll(function () { var windowtop = $(window).scrolltop(); if (windowtop < w_height && !ismobile) { $('.pbanner img').css('transform', "translate(0px," + (windowtop) / 1.5 + "px)"); }; }); /* page banner end */ function gethash() { var hash = location.href.split("#")[1]; if (hash) { settimeout(function () { $("html,body").animate({ scrolltop: $("#" + hash).offset().top - $mtoph }, 20); }, 100); } }; gethash(); $('.pnav li').click(function () { var phash = $(this).find('a').attr('href').split("#")[1]; if (phash) { settimeout(function () { $("html,body").animate({ scrolltop: $("#" + phash).offset().top - $mtoph }, 800, 'easeinoutexpo'); }, 250); } }); $('.mtnav a').click(function () { var mhash = $(this).attr('href').split("#")[1]; if (mhash) { $menubtn.removeclass("active"); $menubox.stop(false, false).animate({ top: -100 + "%" }, function () { $(this).hide(); }); navitem = 0; settimeout(function () { $("html,body").animate({ scrolltop: $("#" + mhash).offset().top - $mtoph }, 800, 'easeinoutexpo'); }, 250); } }); $('.flink a').click(function () { var fhash = $(this).attr('href').split("#")[1]; if (fhash) { settimeout(function () { $("html,body").animate({ scrolltop: $("#" + fhash).offset().top - $mtoph }, 800, 'easeinoutexpo'); }, 250); } }); //back top -- 回到顶部 $('#top').click(function () { $('html,body').stop().animate({ scrolltop: 0 }, 500, "easeinoutexpo"); }); //weixin setpopup($('.weixin'), "官方微信"); 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; }); }; }); var objplay; var video = { load: function (objs) { objplay = jwplayer(objs.vcontainer).setup({ flashplayer: 'js/video/flashplay.swf', html5player: 'js/video/html5player.js', file: objs.vfiles, image: objs.vfimg, width: '100%', height: '100%', aspectratio: '16:9', stretching: 'fill', controls: 'true', autostart: objs.isautoplay }); return objplay; } }; 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 }); }; }; $(".search-tx").keyup(function (event) { var keyvalue = event.which; var keyword = $(this).val(); if (keyvalue == 13) { if (keyword == '') { $(this).focus(); alert("查询内容不能为空!"); return; } else { window.location = "search.aspx?keyword=" + keyword; } } }) $(".search-btn").click(function () { var keyword = $(".search-tx").val(); if (keyword == "") { $(".search-tx").focus(); alert("查询内容不能为空!"); return; } else { window.location = "search.aspx?keyword=" + keyword; } });