function go2Refresh(url) { url = url ? url : window.location.href; var _s = url.indexOf('#'); if(_s >= 0) { url = url.substr(0, _s); } window.location.href = url; } function go2SetCookie(cookieName, cookieValue, seconds, path, domain, secure) { if(cookieValue == '' || seconds < 0) { cookieValue = ''; seconds = -2592000; } if(seconds) { var expires = new Date(); expires.setTime(expires.getTime() + seconds * 1000); } document.cookie = escape(G_cookiepre + cookieName) + '=' + escape(cookieValue) + (expires ? '; expires=' + expires.toGMTString() : '') + (path ? '; path=' + path : '/') + (domain ? '; domain=' + domain : '') + (secure ? '; secure' : ''); } function go2GetCookie(name, nounescape) { name = G_cookiepre + name; var cookie_start = document.cookie.indexOf(name); var cookie_end = document.cookie.indexOf(";", cookie_start); if(cookie_start == -1) { return ''; } else { var v = document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)); return !nounescape ? unescape(v) : v; } } var alerttimer = null, alertmsg = $(''); $('body').append(alertmsg); function lnpAlertMsg(msg, oWrap) { var obj = alertmsg; if(oWrap && oWrap.length) { oWrap.html(msg).show(); obj = oWrap; } else { var win = $(window); alertmsg.html(msg).show(); alertmsg.css({bottom:win.height()/2, left:(win.width() - alertmsg.width())/2}); } if(alerttimer) { clearTimeout(alerttimer); } alerttimer = setTimeout(function(){ obj.html('').hide(3000); }, 3000); } (function($) { $(function() { //ga('send', 'event', [eventCategory]str, [eventAction]str, [eventLabel]str, [eventValue]num, [fieldsObject]); if(typeof ga !== 'undefined') { $(document).on('click', '[data-ga-event]', function(evt) { var dge = $(this).attr('data-ga-event'), href = $(this).attr('href'); if(dge) { var evtdata = dge.split(':'); if(evtdata[3]) { evtdata[3] = parseFloat(evtdata[3]); } if(evtdata[4]) { evtdata[4] = !! evtdata[4]; } ga('send', 'event', evtdata[0], evtdata[1], evtdata[2], evtdata[3], evtdata[4]); } else if (href) { if(href.indexOf('.pdf') > 0) { ga('send', 'event', 'Download', 'pdf', href, 1); } else if(href.indexOf('.zip') > 0) { ga('send', 'event', 'Download', 'zip', href, 1); } else { ga('send', 'event', 'Clicka', 'href', href, 1); } } }); }//typeof ga if(typeof gtag !== 'undefined') { $(document).on('click', '[data-ga-event],a', function(evt) { var that = $(this), dge = that.attr('data-ga-event'), href = that.attr('href'); if(dge) { var evtdata = dge.split(':'); if(evtdata[3]) { evtdata[3] = parseFloat(evtdata[3]); } else { evtdata[3] = 1; } if(evtdata[4]) { evtdata[4] = !! evtdata[4]; } gtag('event', evtdata[1], {'event_category': evtdata[0], 'event_label': evtdata[2], 'value': evtdata[3]}); } else if (href) { if (href.indexOf('.pdf') > 0) { gtag('event', 'pdf', {'event_category': 'Download', 'event_label': href, 'value': 1}); $.get(G_ajaxurl+'visitstat&href='+href); } else if (href.indexOf('.zip') > 0) { gtag('event', 'zip', {'event_category': 'Download', 'event_label': href, 'value': 1}); $.get(G_ajaxurl+'visitstat&href='+href); } else { gtag('event', 'href', {'event_category': 'Clicka', 'event_label': href, 'value': 1}); } } }); }//typeof gtag $('.toprodnav-catitem').on('mouseover', function(evt){ var that = $(this), menuid = that.attr('data-submenuId'); $('.toprodnav-proditemwrap').removeClass('on'); $('#'+menuid).addClass('on'); $('.toprodnav-catitem').removeClass('on'); that.addClass('on'); }); $(document).on('click', '#back2top', function(evt){evt.preventDefault();$("html, body").animate({ scrollTop: 0 }, 300);}); $(window).on('scroll', function(){ if($(this).scrollTop() > 160) { $('#back2top').show(); } else { $('#back2top').hide(); } }); $('.cookie-notice_okbtn').on('click', function(evt){ evt.preventDefault(); go2SetCookie('accepted_cookie', '1', 7776000); $('#cookie-notice').remove(); }); var oContactForm = $('.contactform'); if(oContactForm.length > 0) { oContactForm.on('submit', function(evt){ evt.preventDefault(); var that = $(this), email = that.find('[type="email"]'), emailval = '', submitbtn = that.find('[type="submit"]'), retmsg = that.find('.retmsg'); submitbtn.prop('disabled', true); if(email.length > 0) { emailval = email.val(); if(emailval == '' || emailval.indexOf('@') == -1) { lnpAlertMsg('Please enter a valid email first!', retmsg); submitbtn.prop('disabled', false); setTimeout(function(){email.focus()}, 10); return; } } var oldbtntxt = submitbtn.html(); submitbtn.html(oldbtntxt+'...'); $.post(G_ajaxurl+'formsubmit', that.serialize(), function(ret){ submitbtn.html(oldbtntxt); if(ret.code < 0) { submitbtn.prop('disabled', false); setTimeout(function(){ if(email.length > 0){ email.focus(); } }, 10); } lnpAlertMsg(ret.msg, retmsg); }); }); }//oContactForm.length /***************carousel *****************/ var oOwl = $('.owl-carousel'); if(!G_isfrontedit && oOwl.length && typeof $.fn.owlCarousel != 'undefined') { oOwl.each(function(){ var that = $(this), _id = that.attr('id'), _items = that.data('owl-items'), _loop = that.data('owl-loop'), _margin = that.data('owl-margin'), _nav = that.data('owl-nav'), _autoplay = that.data('owl-autoplay'), _dot = that.data('owl-dots'), otheropt = that.data('owl-options'), _opt = {autoplayHoverPause:true,navText:''}; _opt.items = _items ? parseInt(_items) : 1; _opt.loop = _loop === 'undefined' ? true : !!_loop; _opt.autoplay = _autoplay === 'undefined' ? true : !!_autoplay; _opt.nav = !!_nav; _opt.dots = !!_dot; if(otheropt) { var tmp = otheropt.split(','); $.each(tmp, function(k, v){ var tt = v.split(':'); var _name = $.trim(tt[0]), _val = $.trim(tt[1]); var _v2 = parseInt(_val); _opt[_name] = isNaN(_v2) ? _val : _v2; }) } //console.log(_opt); if(_margin) { _opt.margin = parseInt(_margin); } if(_opt.items > 1) { _opt.responsive = { 0:{ items:_opt.items > 1 ? 1 : _opt.items }, 420:{ items:_opt.items > 1 ? 2 : _opt.items }, 768:{ items:_opt.items > 1 ? 3 : _opt.items }, 1024:{ items:_opt.items } } } //console.log(_opt); $("#"+_id).owlCarousel(_opt); }) } /******************* responsive top menu icon ******************/ var topnavresponseicon = $('#resmenuicon'), topnavbar = $('.mobile-hide'); if(topnavresponseicon.length) { topnavresponseicon.on('click', function(evt){ evt.preventDefault(); var that = $(this), _show = topnavbar.css('display'); if(!_show || _show == 'none') { topnavbar.css('display', 'block'); that.html(''); } else { topnavbar.css('display', 'none'); that.html(''); } }); } var curUrlPath = window.location.pathname;//alert(window.location.pathname); $('.go2-nav a').each(function(){ var that = $(this), href = that.attr('href'); if((href && href !== '/') && (href == curUrlPath || curUrlPath.indexOf(href) == 0)) { that.addClass('curactive'); } }); });//$(function() { })(jQuery); function go2Htmlspecialchars(str) { if (typeof(str) == "string") { str = str.replace(/&/g, "&"); str = str.replace(/"/g, """); str = str.replace(/'/g, "'"); str = str.replace(//g, ">"); } return str; }