$(function() {
//console.log($(document).scrollTop());
dmfull_height();
dmmenuonepage();
dmnodetab();
sdexpand();
makeimg100();
counter();
jstabhover();
backtotop();
menusimple();
ahrefscroll();
tradeinquery();
//alert($(document).width());
if ($('body').width() > 1024) {
superfish();
dmedit();
menutop_subhover();
} else {
dmmobjs();
$(".dmmenumobi,.menuonepage a").click(function() {
$(".dmmenumobi").toggleClass("opennavmenu");
$(".menu").toggleClass("menushow");
});
//--------
// $('.menu').height(0);
//-----
}
//------------------
if($('.menuone_subtoindex').length>0) {
if (!$('body').hasClass('page_index')) {
$('.menuone_subtoindex a').each(function(e) {
var hash = $(this).attr('href');
var indexv = hash.indexOf('#');
var indexvv = hash.substr(indexv);
var newhash = 'index.php' + indexvv;
$(this).attr('href', newhash);
});
}
}
//--------------------
$('.jssearchinput button').click(function() {
//var v = $(this).closest('.topsearchbox').find('input').attr('placeholder');
var errorv = $(this).closest('.jssearchinput').find('input').data('error');
var val = $(this).closest('.jssearchinput').find('input').val();
val = $.trim(val);
//if(val==v || val=='') {
if (val == '') {
alert(errorv);
return false;
}
});
$('.detailfontsize a').click(function() {
var indexv = $(this).index();
if (indexv == 0) {
var sizev = $('.detailfontsize').data('size');
if (sizev > 12) sizev = sizev - 4;
} else {
var sizev = $('.detailfontsize').data('size');
if (sizev < 36) sizev = sizev + 4;
}
$('.detailfontsize').data('size', sizev);
if (sizev < 20) lhv = '25px';
else lhv = '50px';
$('.content_size p,.content_size').css({
'font-size': sizev,
'line-height': lhv
});
});
/*-----newstab toggledesp----------*/
$(".toggledesp .despjj").eq(0).show();
$(".toggledesp li").hover(function() {
$(this).siblings().find(".despjj").hide();
$(this).find(".despjj").show();
}, function() {
});
//-----------------
if ($('.homenoticejs .cnt').length > 0) {
var id = $('.homenoticejs .dmpopupbk').attr('id');
popcookie = dmgetCookie(id);
if (popcookie == null) {
$.fancybox.open({
src: '#' + id,
})
}
if ($('.homenoticejs').hasClass('popup_onlyone')) dmsetCookie(id, true);
}
if ($('.dmpopupbkjs').length > 0) {
var id = $('.dmpopupbkjs').attr('id');
popcookie = dmgetCookie(id);
if (popcookie == null) {
$.fancybox.open({
src: '#' + id,
})
}
if ($('.dmpopupbkjs').hasClass('popup_onlyone')) dmsetCookie(id, true);
}
onlineqq();
tabs_js();
jssearchrg();
jssearchrg_pop();
clicknextshow();
dmcounterjs();
jscopyblockid();
//change video width and height
$('.videodesp iframe,.videodesp embed').attr('style', '');
$('.videodesp iframe,.videodesp embed').attr('width', '100%').attr('height', '100%');
//--------end ready---
});
function jscopyblockid(){
if($('.jscopyblockid').length>0){
$('.jscopyblockid').click(function () {
var v = $(this).prev().text();
//alert(v);
clipboard.writeText(v);
})
}
}
// counterUp
function dmcounterjs(){
if($('.dmcounterjs').length>0) {
$(".dmcounterjs").counterUp({
delay: 10,
time: 1000
});
}
}
//-----------
function sdexpand(){
if($('.sdexpand').length>0) {
//-----------
if($('.sdmaincate_cur').length>0) { //濡傛灉鏄富锛屽垯绗竴涓猻ub鏄剧ず銆
$('.sdmaincate_cur ul.sub').hide();
$('.sdmaincate_cur>li').eq(0).find('.sub').show();
$('.sdmaincate_cur>li').eq(0).find('.sdlevel_1').addClass('expanding');
}
else {
$('.sdexpand ul.sub').hide();
$('.mainactive ul.sub').show();
/*$('.sdlevel_1').click(function(e){
if($(this).next().length>0){
e.preventDefault();
$('.sdexpand ul.sub').hide();
$(this).next().show();
$(this).addClass('expanding');
}
})
*/
if($('.sdli_1.mainactive').length>0) {
if($('.sdli_1.mainactive .sub').length>0) {
$('.sdli_1.mainactive').addClass('expanding');
}
}
}
//-------------
}
}
//-------------
// a href anchor id scroll
function ahrefscroll(){
$("a").click(function (e) {
var $id = $(this).attr("href");
if(typeof $id != 'undefined'){
if($id.substr(0,4)!=='http') {
if($($id).length>0){
$("html, body").animate({scrollTop: $($id).offset().top -60+ "px"}, 500);
e.preventDefault();
}
}
}
});
}
// trade inquery
function tradeinquery(){
$('#tradeinquery').click(function(){
if($('#tradeinquery').length>0){
$('.nodetabhd span').removeClass('cur');
$('.nodetabhd #tabform').addClass('cur');
$('.nodetab .nodetabcntinc').hide();
$('.nodetab #tabformtext').show();
}
});
}
//-------------
function menutop_subhover() {
if ($('.sidermenutop .sub').length > 0) {
$('.sidermenutop>li').hover(function() {
$(this).find('.sub').show();
}, function() {
$(this).find('.sub').hide();
});
}
}
function menusimple() {
if ($('.menusimple').length > 0) {
$('.menusimpletoggle').click(function() {
if ($(this).hasClass('on')) {
$(this).removeClass('on');
$('.menusimpletext').hide();
} else {
$(this).addClass('on');
$('.menusimpletext').show();
}
});
}
}
function clicknextshow() {
$('.clicknextshow').click(function(event) {
$(this).next().toggle(); //slideToggle
});
}
function jssearchrg() {
if ($('.jssearchrg').length > 0) {
$('.jssearchrg').click(function() {
$(this).next().find(".topsearchbox").slideToggle();
});
}
}
function jssearchrg_pop() {
if ($('.jssearchrg_pop').length > 0) {
$('.jssearchrg_pop').click(function() {
$(".searchpopbox").fadeIn(600);
});
$('.searchpopclose,.searchpopbox_close').on('click', function() {
$(".searchpopbox").fadeOut(600);
});
}
}
function dmedit() {
$('.block').hover(function() {
$(this).find('.dmedit').show();
}, function() {
$(this).find('.dmedit').hide();
});
$('.regionbox').hover(function() {
$(this).find('.dmeditregion').show();
}, function() {
$(this).find('.dmeditregion').hide();
});
$('.contentwrap,.pageregionwrap').hover(function() {
$(this).find('.dmeditnode').show();
}, function() {
$(this).find('.dmeditnode').hide();
});
}
function makeimg100() { //cancel ...
var cntwidth = $('body').width() - 10;
//alert(cntwidth);
// $('.content_desp img,.albumupdown img,.caseright img,.perimgwrap img').each(function(){
$('body img').each(function() {
// console.log(cntwidth);
if ($(this).width() > cntwidth) {
$(this).attr('style', '');
$(this).addClass('perimgmax100');
//$(this).attr('max-width','98%');
//alert(cntwidth);
}
});
}
/*-counter--*/
function counter() {
if ($('.counteritem').length > 0) {
$('.counteritem i').counterUp({
delay: 10,
time: 1000
});
}
}
//-----------------------------
function superfish() {
if ($('.needsuperfish ul.m').length > 0) {
$('.needsuperfish ul.m').superfish({
//useClick: true
});
}
}
//-----------------
function dmmobjs() {
$(".menu").find("li ul.sub").each(function() {
$(this).parent().prepend('')
});
$('.sub-nav-toggle').click(function() {
$(this).toggleClass("plus");
//if($(this).siblings("ul.sub").hasClass('show')) $(this).siblings("ul.sub").removeClass('show');
// else $(this).siblings("ul.sub").addClass('show');
// $(this).siblings("ul.sub").toggleClass('show');
if ($(this).siblings("ul.sub").css("display") == "none") {
$(this).siblings("ul.sub").slideDown(500);
} else $(this).siblings("ul.sub").slideUp(500);
});
//------------
}
//-----------------------------
function onlineqq() {
$('.onlineopen').click(function() {
$(this).hide();
$('.onlinecontent').show();
$('.onlineclose').show();
});
$('.onlineclose').click(function() {
$(this).hide();
$('.onlinecontent').hide();
$('.onlineopen').show();
});
$('.sitecolorchange .onlineclosecolor').click(function() {
$('.sitecolorchange').hide();
});
}
function tabs_js() {
$('.tabs_js .tabs_headerjs li').click(function() {
var curVal = $(this).index();
if (!$(this).hasClass('active')) {
// $('.tabs_js .tabs_headerjs li').removeClass('active');
$(this).closest(".tabs_headerjs").find('li').removeClass('active');
$(this).addClass('active');
$(this).closest(".tabs_js").find('.tabs_content').hide();
$(this).closest(".tabs_js").find('.tabs_content').eq(curVal).fadeIn();
//$('.tabs_js .tabs_content').hide();
// $('.tabs_js .tabs_content').eq(curVal).fadeIn();
return false;
}
});
}
//----------------------
function backtotop() {
if ($('#backtotop').length) {
jQuery('#backtotop a').click(function() {
jQuery('body,html').animate({
scrollTop: 0
}, 500);
return false;
});
}
}
/*----------scrollscroll-------------------------------*/
$(window).scroll(function() {
//var scrolldistance = $(document).scrollTop();
if ($('.stickytop').length) {
stickyfunc('.stickytop');
}
if ($('body').width() > 1024) {
if ($('.stickytoppc').length) {
stickyfunc('.stickytoppc');
}
} else {
if ($('.stickytopmobi').length) {
stickyfunc('.stickytopmobi');
}
}
//-----
if ($(this).scrollTop() > 150) {
$('#backtotop').fadeIn();
} else {
$('#backtotop').fadeOut();
}
//-------------
});
function stickyfunc(v) {
var strickyScrollPos = 25;
var strickyScrollPos2 = 100;
if ($('body').width() > 800) {
var strickyScrollPos = 50;
var strickyScrollPos2 = 300;
}
if ($(window).scrollTop() > strickyScrollPos2) { //avoid pingfan scroll
//$(v).removeClass('fadeIn animated');
$(v).addClass('stricky-fixed');
//$(v).css{'position','absolute'}
} else if ($(this).scrollTop() <= strickyScrollPos) {
$(v).removeClass('stricky-fixed');
//$(v).addClass('slideIn animated');
}
}
function dmfull_height() {
var windowhg = window.innerHeight; //not use $(window).height();/
$('.dmfull_height').css('height', windowhg);
$('.dmfull_height li').css('height', windowhg);
$(window).resize(function() {
$('.dmfull_height li').css('height', windowhg);
});
// windowhg22 = windowhg -30;
//if($('.dmfull_height .slick-dots').length>0) $('.dmfull_height .slick-dots').css('top',windowhg22);
}
function dmmenuonepage() {
if($('ul.menuonepage').length>0) {
//----------
$(".menuonepage a").on("click", function(event) {
//event.preventDefault();
topv = 100;
if ($(this.hash).length > 0) topv = $(this.hash).offset().top - 60;
if (this.hash == '#home') topv = 0;
// $(".menuonepage a").removeClass('active');
//$(this).addClass('active');
// if($('.menucollapse').length>0) $('.menucollapse').toggleClass('show');
$('html,body').animate({
scrollTop: topv
}, 700);
});
//--------------
}
}
function dmnodetab() {
$('.nodetabhd span').click(function() {
var index = $(this).index();
$('.nodetabhd span').removeClass('cur');
$('.nodetabhd span').eq(index).addClass('cur');
$('.nodetab .nodetabcntinc').hide();
$('.nodetab .nodetabcntinc').eq(index).show();
});
}
function jstabhover() {
$('.jstabhoverwrap .jstabhover').hover(function() {
var indexv = $(this).index();
if ($('body').width() < 1024) {
$('.jstabhoverwrap .jstabhover').attr('href', 'javascript:void(0)');
}
// console.log(indexv);
$(this).closest('.jstabhoverwrap').find('.jstabhover').removeClass('active').eq(indexv).addClass('active');
$(this).closest('.jstabhoverwrap').find('.jstabhovercnt').hide().eq(indexv).show();
}, function() {
});
}
/*begin form js*/
function dmformvalid(parentv) {
//$('.formblock .error').hide();
parentv.find('.error').hide();
var content = '';
var thisvalue = '';
var errorhint = false;
//$('.formblock .jsline').each(function(){
parentv.find('.jsline').each(function() {
var thiskey = $(this).find('.key span').text();
var thistype = $(this).find('.key').data('typeinput');
var thiserror = $(this).find('.key').data('error');
if (thistype == 'text' || thistype == 'textarea') {
thisvalue = $.trim($(this).find('.value').val());
if (thiserror == 'error1' && thisvalue == '') {
$(this).find('.error').show();
errorhint = true;
}
if (thiserror == 'error2' && !checkphone(thisvalue)) {
$(this).find('.error').show();
errorhint = true;
}
if (thiserror == 'error3' && !checkemail(thisvalue)) {
$(this).find('.error').show();
errorhint = true;
}
if (thiserror == 'error4' && !checknumber(thisvalue)) {
$(this).find('.error').show();
errorhint = true;
}
}
if (thistype == 'checkbox') {
thisvalue = '';
$(this).find('input:checkbox:checked').each(function() {
thisvalue = thisvalue + $(this).val() + ',';
});
if ($(this).find('input:checkbox:checked').length == 0) {
$(this).find('.error').show();
errorhint = true;
}
}
if (thistype == 'radio') {
thisvalue = $(this).find('input:radio:checked').val();
if ($(this).find('input:radio:checked').length == 0) {
$(this).find('.error').show();
errorhint = true;
}
}
if (thistype == 'select') {
thisvalue = $(this).find('select').val();
if (thisvalue == '') {
$(this).find('.error').show();
errorhint = true;
}
}
var thiscnt = thiskey + thisvalue + '
';
content = content + thiscnt;
});
//alert(errorhint);
if (errorhint) return false;
return content;
}
function dmformajax(parentv, contentv, formdatajson) {
parentv.find('.submitloading').show();
formSumbitHave = formdatajson.formSumbitHave;
formSumbitOk = formdatajson.formSumbitOk;
formSumbitRepeat = formdatajson.formSumbitRepeat;
contentv = '琛ㄥ崟鏍囬锛? + formdatajson.formtitle + '
' + contentv;
//return false;
//var content = '鏄电О锛?+$('.homeliuyan .inp_name').val()+'
鐢靛瓙閭锛?+$('.homeliuyan .inp_email').val()+'
鎵嬫満锛?+$('.homeliuyan .inp_phone').val()+'
鍐呭锛?+$('.homeliuyan .inp_content').val();
jQuery.ajax({
type: 'POST',
url: formdatajson.ajaxformurl,
dataType: "json",
data: {
content: contentv,
nodepidname: formdatajson.nodepidname,
tokenhour: formdatajson.tokenhour,
pid: formdatajson.formpidname
},
success: function(data) {
if (data.id == 'norepeat') {
$.fancybox.open('