jQuery(document).ready(function ($) {
	$('.pixelio-cart-abandon-recovery-more-multi-tab-switcher').each(function () {
		var $switcher = $(this);
		var $tabs = $switcher.find('.pixelio-cart-abandon-recovery-more-tab');
		var $indicator = $switcher.find('.pixelio-cart-abandon-recovery-more-tab-indicator');
		var $content = $switcher.find('.pixelio-cart-abandon-recovery-more-tab-content');

		if ($tabs.length > 0) {
			var $firstTab = $tabs.eq(0);
			$firstTab.addClass('pixelio-cart-abandon-recovery-more-active');
			$indicator.width($firstTab.outerWidth());
			$indicator.css('left', $firstTab.position().left);
			triggerCallback($firstTab.data('callback'));
		}

		$tabs.on('click', function () {
			var $tab = $(this);

			$indicator.stop(true).animate({
				width: $tab.outerWidth(),
				left: $tab.position().left
			}, 300);

			$tabs.removeClass('pixelio-cart-abandon-recovery-more-active');
			$tab.addClass('pixelio-cart-abandon-recovery-more-active');

			triggerCallback($tab.data('callback'));
		});

		function triggerCallback(callbackName) {
			if (callbackName && typeof window[callbackName] === 'function') {
				window[callbackName]($content);
			}
		}
	});
});
