$(document).ready(function (){ // Menu $('#menu .dropdown-menu').each(function (){ var menu = $('#menu').offset(); var dropdown = $(this).parent().offset(); var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth()); if (i > 0){ $(this).css('margin-left', '-' + (i + 5) + 'px'); } }); // Ajax refresh captcha 56 $('#tc_refresh').on('click', function (){ var _this = $(this); var _tc_image = $('#tc_image'); var _tc_input = $('#tc_input'); _tc_input.val('').focus(); $.ajax({ url : 'index.php?route=tool/captcha/refresh', beforeSend: function (){ _this.html(''); }, complete : function (){ _this.html(''); }, success : function (){ _tc_image.attr('src', 'index.php?route=tool/captcha#' + new Date().getTime()); } }); }); $(document).delegate('.success img, .warning img, .attention img, .information img', 'click', function (){ $(this).parent().fadeOut('slow', function (){ $(this).remove(); }); }); $('iframe[name=\'google_conversion_frame\']').hide(); $('select').material_select(); $('.materialboxed').materialbox(); $('#menu-icon-click').click(function () { var _this = $(this); var _menu = $('#menu-container-main'); if(_menu.hasClass('open-menu')){ _menu.hide().removeClass('open-menu'); _this.removeClass('a-open-menu'); }else{ _menu.show().addClass('open-menu'); _this.addClass('a-open-menu'); } }); $('#menu > .container > ul').aptMegaMenu(); }); function getURLVar(key){ var value = []; var query = String(document.location).split('?'); if (query[1]){ var part = query[1].split('&'); for (i = 0; i < part.length; i++){ var data = part[i].split('='); if (data[0] && data[1]){ value[data[0]] = data[1]; } } if (value[key]){ return value[key]; } else{ return ''; } } } function addToCart(product_id, quantity){ quantity = typeof(quantity) != 'undefined' ? quantity : 1; $.ajax({ url : 'index.php?route=checkout/cart/add', type : 'post', data : 'product_id=' + product_id + '&quantity=' + quantity, dataType: 'json', success : function (json){ $('.success, .warning, .attention, .information, .error').remove(); if (json['redirect']){ location = json['redirect']; } if (json['success']){ $('#notification').html(''); $('.success').fadeIn('slow'); $('#cart-total').html(json['total']); $('html, body').animate({scrollTop: 0}, 'slow'); } } }); } function addDomainToCart(domain, keyword){ keyword = typeof(keyword) != 'undefined' ? keyword : false; alert('Chức năng đang nâng cấp'); } function addHostingToCart(hotsting_id, quantity){ quantity = typeof(quantity) != 'undefined' ? quantity : 1; alert('Chức năng đang nâng cấp'); } function addEmailServerToCart(email_server_id, quantity){ quantity = typeof(quantity) != 'undefined' ? quantity : 1; alert('Chức năng đang nâng cấp'); } function addSoftwareToCart(hotsting_id){ alert('Chức năng đang nâng cấp'); }