$(document).ready(function() {
$('.menuBtn').append('');
$('.menuBtn').click(function(event) {
$(this).toggleClass('open');
var _winw = $(window).width();
var _winh = $(window).height();
if ($(this).hasClass('open')) {
$('body').addClass('open');
if (_winw <= 1920) {
$('.nav').stop().slideDown();
}
} else {
$('body').removeClass('open');
if (_winw <= 1920) {
$('.nav').stop().slideUp();
}
}
});
var _winw = $(window).width();
if (_winw > 959) {
$('.nav li').hover(function() {
$(this).find('.sub').stop().slideDown();
if ($(this).find('.sub').length) {
$(this).addClass('ok');
$('.header').addClass('on');
} else {
$('.header').removeClass('on');
}
}, function() {
$(this).removeClass('ok');
$(this).find('.sub').stop().slideUp();
});
$('.nav').mouseleave(function(event) {
if ($('.header').hasClass('on')) {
$('.header').removeClass('on');
};
});
} else {
$('.nav .v1').click(function() {
if ($(this).siblings('.sub').length) {
$(this).parents('li').siblings('li').find('.sub').stop().slideUp();
$(this).siblings('.sub').stop().slideToggle();
return false;
}
});
}
$(".TAB_CLICK li").click(function() {
var tab = $(this).parent(".TAB_CLICK");
var con = tab.attr("id");
var on = tab.find("li").index(this);
$(this).addClass('on').siblings(tab.find("li")).removeClass('on');
$(con).eq(on).show().siblings(con).hide();
});
$('.TAB_CLICK').each(function(index, el) {
if ($(this).find('li.on').length) {
$(this).find("li.on").trigger('click');
} else {
$(this).find("li").filter(':first').trigger('click');
}
});
$('.myfancy').click(function() {
var _id = $(this).attr('href');
$(_id).fadeIn("normal");
});
$('.pop-bg,.close').click(function() {
$(this).parents('.m-pop').fadeOut("normal");
});
$('.so_btn').click(function(e) {
$('.so').slideToggle(200);
});
var vNavWaitSlide,NavWaitSlide;
$('#nav > li').hover(
function(){
$(this).find('a:first').addClass("hover");
var current_li=$(this),targ=$(current_li).find('ul:first');
NavWaitSlide = setTimeout(function() {
if(!$(targ).is(':visible'))
{
$(targ).slideDown(200);
}
},100)
},
function(){
clearTimeout(NavWaitSlide);
$(this).find('ul').hide();
$(this).find('a:first').removeClass("hover");
}
);
var backTop = $('.back-top');
var screenH = $(window).height();
var sH = $(window).scrollTop();
function showBacktop(h) {
if (h >= screenH) {
backTop.fadeIn();
} else {
backTop.fadeOut();
}
}
showBacktop(sH);
$(window).on('scroll', function() {
var _sH = $(window).scrollTop();
showBacktop(_sH);
});
$('.back-top').click(function() {
$('body,html').animate({
'scrollTop': 0
}, 500);
});
$("#smenu").bind("click",function(){
if($(".header").is(".active")){
$(".header").removeClass("active");
$(".lan_x1").removeClass("active");
$(".masklayer").hide();
}else{
$(".header").addClass("active");
$(".lan_x1").addClass("active");
$(".masklayer").fadeIn("fast");
}
});
$(".masklayer").bind("click",function(){
$(".header").removeClass("active");
$(".masklayer").hide();
$('body').css("overflow-y",'auto');
});
if($(".xy1-r").length>0){
var myScroll4 = new IScroll($(".xy1-r")[0], {
scrollX: !false,
scrollY: false,
click: true,
tap: true
});
if($(".xy1-r .active").length>0){
myScroll4.scrollToElement($(".xy1-r .active")[0]);
}
}
});