function showCert(id){ $('.cert .item').removeClass('color_title'); $('.cert .item[alt='+id+']').addClass('color_title'); var curr = $(this); $.ajax({ type: "POST", url: '/index.php?task=ajax_load_cert', data: 'id='+id , success: function(response) { $('.div_load_ajax_cert').html(response).slideDown('slow'); //curr.parent('div').find('.triangle').slideDown('slow'); setTimeout(function(){ if($(window).width() == 768){ $('body').scrollTo( $('.div_load_ajax_cert .div_banner_area').offset().top -140, 400); }else if($(window).width() > 576){ $('body').scrollTo( $('.div_load_ajax_cert .div_banner_area').offset().top -150, 400); }else{ $('body').scrollTo( $('.div_load_ajax_cert .div_banner_area').offset().top -80, 400); } }, 500); }, error: function(){ alert('System busy...'); } }); } function init_pd_owl(c , margin ,item, opt , startPosition){ var obj = $(c); var m = JSON.parse(margin); var it = JSON.parse(item); var o = JSON.parse(opt); obj.owlCarousel({ loop: o.loop, autoplay: o.autoplay, responsiveClass: true, navText: ['',''], navContainer: c+ '~.div_owl_nav .div_owl_btn', dotsContainer: c+ '~.div_owl_nav .div_owl_dot', responsive: { 0: { items: it.sm *1, nav: true, margin: m.w0 *1, startPosition:startPosition }, 600: { items: it.w600 *1, nav: false, margin: m.w600 *1, startPosition:startPosition }, 768:{ items:it.w600 *1, nav:true, margin:m.w600 *1, startPosition:startPosition }, 1000: { items: it.w1000 *1, nav: true, margin: m.w1000 *1, startPosition:startPosition } } }); } $(document).ready(function(){ if($(window).width() < 991){ $('.div_content_main').click(function(){ if(!$('.navbar-toggler').hasClass('collapsed')){ $('.navbar-collapse').removeClass('show'); }else{ } }) } if($(window).width() < 576){ if($('body').hasClass('product_detail')){ if($('body').hasClass('cn')){ window.setTimeout( moveTop(240), 300 ); }else{ window.setTimeout( moveTop(280), 300 ); } } $('.home .div_group_1 .fs_topic').each(function(){ $(this).html( $(this).html().replace(' ','
') ); $(this).html( $(this).html().replace('

','
') ); $(this).html( $(this).html().replace('

','
') ); }) $('.navbar-toggler').click(function(){ $('.navbar-collapse').css('height', $(window).height()-60); }) }else{ } $('.adv_product .div_zoom').each(function(){ $(this).css('height' , $(this).width()* 0.66 + 85 ); }) $('.product_detail .div_zoom').each(function(){ $(this).css('height' , $(this).width()); }) function moveTop(y){ $("html, body").animate({ scrollTop: y+"px" },1000); } $('.btn_toTop').click(function(){ if($(window).width() < 576){ if($('body').hasClass('product_detail')){ window.setTimeout( moveTop(280), 300 ); }else{ moveTop(0); } }else{ moveTop(0); } document.body.scrollTop=0; document.documentElement.scrollTop = 0; }) //$('.news .owl-carousel').parent('div').css('height', '370px').css('overflow','hidden'); /* $('.txt_autoComplete').keyup(function(){ var key = $(this).val(); var field = $(this).attr('id'); if(key.length>2){ $.ajax({ type: "POST", url: '/index.php?task=searchPD', data: 'key='+ key + '&field=' + field, success: function(response) { $('#autoCompleteList_'+field).html(response); } }); } })*/ select_item = function (obj) { var obj = $(obj); var html = obj.html(); html = html.replace(/option_val/ig,'selected_val'); obj.parents('td.content').find('.selectedAutoComplete').append( '
  • ' + html + '
  • '); obj.remove(); } remove_item = function (obj) { var obj = $(obj); obj.parents('li').remove(); } $('.btn_show_download').click(function(){ $('.list_data').slideUp(); $('.div_leaflet_2,.list_data').css('border-top',"0px").css('border',"0px"); if($('.div_content_main').hasClass('adv_product')){ if(!$(this).parents('.div_leaflet_2').find('.list_data').is(':visible')){ $(this).parents('.div_leaflet_2').find('.list_data').css('border-top',"1px solid rgb(224, 224, 224)"); $(this).parents('.div_leaflet_2').css('border',"1px solid #000"); $(this).parents('.div_leaflet_2').find('.list_data').slideDown(); }else{ $(this).parents('.div_leaflet_2').css('border',"0px solid #000"); } }else{ if(!$(this).parents('.div_leaflet_2').find('.list_data').is(':visible')){ $(this).parents('.div_leaflet_2').find('.list_data').css('border-top',"1px solid rgb(224, 224, 224)"); $(this).parents('.div_leaflet_2').css('border',"1px solid #000"); $(this).parents('.div_leaflet_2').find('.list_data').slideDown(); }else{ $(this).parents('.div_leaflet_2').css('border',"0px solid #000"); } } }) $('body').click(function(){ if($('.div_leaflet_2').height() >59){ $('.div_download').find('.list_data').slideUp(); $('.div_leaflet_2').css('border',"0px solid #000"); } }) $(".technical .title .fa-plus-circle").click(function() { $(".technical .title .fa-minus-circle").removeClass("fa-minus-circle").addClass("fa-plus-circle"); $('.div_hide').removeClass('active'); if( $(this).parents('.div_action').find('.fs_desc').height() > 200){ //close $(this).parents().next('.div_hide').removeClass('active'); $(this).addClass("fa-plus-circle"); $(this).removeClass("fa-minus-circle"); }else{ $(this).parents().next('.div_hide').addClass('active'); $(this).removeClass("fa-plus-circle"); $(this).addClass("fa-minus-circle"); } $('.div_hide').each(function(){ if($(this).hasClass('active')){ $(this).show().animate({height:"290px"},1000,function(){}); }else{ $(this).animate({height:"0px"},1000,function(){}); } }) }); var arr_opt = '{ "loop":true,"autoplay":false}'; var arr_margin = '{ "w1000":"0","w600":"0","w0":"0"}'; var arr_item = '{ "w1000":"1","w600":"1","sm":"1"}'; init_pd_owl('#owl_1',arr_margin , arr_item , arr_opt,0); var arr_opt = '{ "loop":true,"autoplay":false}'; var arr_margin = '{ "w1000":"50","w600":"50","w0":"30"}'; var arr_item = '{ "w1000":"4","w600":"3","sm":"2"}'; init_pd_owl('#owl_2',arr_margin, arr_item ,arr_opt,0); $('.div_leaflet .btn_leaflet').click(function(){ $('.div_title').removeClass('color_title'); $(this).find('.div_title').addClass('color_title'); $('.triangle').hide(); //$(' .div_load_ajax_leaflet').slideUp('slow'); var curr = $(this); $.ajax({ type: "POST", url: '/index.php?task=ajax_load_leaflet', data: 'cate_id='+$(this).attr('alt') + '&page=1', success: function(response) { $('.div_load_ajax_leaflet').html(response).slideDown(200, function(){ if($(window).width() > 576){ $('body').scrollTo( $('.div_load_ajax_leaflet').offset().top -150 , 400 ); curr.parent('div').find('.triangle').slideDown('slow'); }else{ $('body').scrollTo( $('.div_load_ajax_leaflet').offset().top -80 , 400 ); } }); }, error: function(){ alert('System busy...'); } }); }); var div_cate_height = 0; var div_dl_height = { cate:"0", cert:"0", leaflet:"0" } $( window ).resize(function() { var div_cate_height = 0; div_dl_height['cate'] = 0; div_dl_height['cert'] = 0; div_dl_height['leaflet'] = 0; $('.adv_product .div_zoom').each(function(){ $(this).css('height' , $(this).width()* 0.66 + 85 ); }) }); $('.download .cate , .download .cert , .download .leaflet').click(function(){ var c = $(this).attr('class'); if(div_dl_height[c]==0){ div_dl_height[c] = $('.div_banner_area.'+c).offset().top; } if($(window).width() > 576){ $('body').scrollTo( div_dl_height[c] - 110, 400); }else{ $('body').scrollTo( div_dl_height[c] - 50, 400); } }); $('.product .btn_category').click(function(){ $('.div_title').removeClass('color_title'); $(this).find('.div_title').addClass('color_title'); if(div_cate_height==0){ div_cate_height = $('.div_load_ajax_category').offset().top; } if($(window).width() > 576 && $(window).width() < 992){ console.log(div_cate_height) $('body').scrollTo( div_cate_height - 75, 400); }else if($(window).width() > 576){ console.log(div_cate_height) $('body').scrollTo( div_cate_height - 90, 400); }else if($(window).width() < 576){ console.log("< 576"); $('body').scrollTo( div_cate_height -13, 400); }else{ $('body').scrollTo( div_cate_height - 30, 400); } $('.triangle').hide(); //$(' .div_load_ajax_category').slideUp('slow'); var curr = $(this); $.ajax({ type: "POST", url: '/index.php?task=ajax_load_category', data: 'cate_id='+$(this).attr('alt') + '&page=1', success: function(response) { $('.div_load_ajax_category').html(response).slideDown(200); curr.parent('div').find('.triangle').slideDown(300); }, error: function(){ alert('System busy...'); } }); }); $(".fancybox").fancybox(); $('.div_sticky').sticky({topSpacing:0}); $('.div_pageing input[type=number]').keyup(function(e){ if (e.keyCode == 13) { window.location = '//news/page/' + $(this).val(); } }) $( ".txt_search" ).autocomplete({ source: "/index.php?task=searchPD", minLength: 2, select: function( event, ui ) { window.location = '//product/' + ui.item.cate + '/'+ ui.item.label + '/'+ui.item.id ; },keypress: function(event,ui){ } } ).keyup(function(e){ if (e.keyCode == 13) { if($(this).val().length>4){ window.location = '//search/'+ $(this).val(); } } $(".ui-helper-hidden-accessible").hide(); event.preventDefault(); }); $('.home .btn_s').click(function(){ $('.slides li:not(#slide_'+$(this).attr('alt')+')').hide().removeClass('slide_anime'); $('#slide_'+$(this).attr('alt')).show().addClass('slide_anime'); }) $('.btn_contact_send ').click(function(){ $('.err').each(function(){ $(this).html(''); }); var err = 0; $('.required').each(function(){ if( fixStr($(this).val())==''){ $(this).parent('div').find('.err').html(''); err= 1; } }); if(!isEmail(fixStr($('.txt_email').val()))){ $('.txt_email').parent('div').find('.err').html(''); err= 2; } if(err==0){ $.ajax({ type: "POST", url: '/index.php?task=send_contact', data: 'name=' + fixStr($('.txt_name').val()) + '&g-recaptcha-response='+$('#g-recaptcha-response').val()+ '&company='+fixStr($('.txt_company').val())+ '&country=' + fixStr($('.txt_country').val()) + '&tel='+fixStr($('.txt_tel').val()) + '&email='+fixStr($('.txt_email').val()) + '&msg='+fixStr($('.txt_msg').val()) , success: function(response) { var obj = JSON.parse(response); $('#popup').modal('hide'); $('.required').val(''); $('#popup_msg .modal-body').html(obj.msg); $('#popup_msg').modal('show'); setTimeout(function(){ $('#popup_msg').modal('hide'); }, 3000); /*if(obj['status']==1){ $('#popup_msg').show(); setTimeout(function(){ $('#popup_msg').modal('hide'); }, 3000); }else{ $('#popup_msg').show(); setTimeout(function(){ $('#popup_msg').modal('hide'); }, 3000); }*/ } }); } }); }); $(window).scroll(function() { var win_width = $(window).width(); if ($(this).scrollTop() > 100) { $('.back-to-top').fadeIn('slow'); if(win_width > 768){ $('.div_sticky').addClass('sticky_top'); }else{ } } else { $('.back-to-top').fadeOut('slow'); if(win_width > 768){ $('.div_sticky').removeClass('sticky_top'); }else{ $('.div_sticky').addClass('sticky_top'); } } $('.text.bg-light').hide(); var top_of_element = $(".div_why_choose").offset().top; var bottom_of_element = $(".div_why_choose").offset().top + $(".div_why_choose").outerHeight(); var bottom_of_screen = $(window).scrollTop() + $(window).innerHeight(); var top_of_screen = $(window).scrollTop(); if ((bottom_of_screen > top_of_element) && (top_of_screen < bottom_of_element)){ $('.div_why_choose .right').each(function(){ $(this).animate({'left':"-15%"},1000); // set the bar position }) $('.div_why_choose .left').each(function(){ $(this).animate({'left':"50%"},1000); // set the bar position }) $('.div_why_choose .float-left img').each(function(){ $(this).animate({'right':"0%"},1000); }) } else { // the element is not visible, do something else } }); function changeBanner(){ var id = $('.slide_anime').attr('id').replace("slide_",''); var max_id = "0"; id ++; if(id > max_id){ id = 1; } $('.btn_s').removeClass('action'); $('.btn_s[alt='+id+']').click().addClass('action'); } (function($){ $.fn.hasScrollBar = function() { return this.get(0).scrollHeight > 150; } })(jQuery);