'use strict';

!function($) {

	$('select[name="shrk_vc_woo_products"]').on('change', function () {
		var param_name = $(this).attr('data-param-name');
		var param_val = $(this).val()
		if( typeof(param_val) !== 'string' ) {
			if ( param_val === null ) {
				param_val = '';
				$(this).next('.multi-count').html('');
			} else {
				if ( typeof(param_val) === 'object' ) {
					$(this).next('.multi-count').html(param_val.length+' selected')
				}	
				param_val = param_val.join();			
			}
		}
		$('input[name="'+param_name+'"]').val(param_val);
	});

	$('select[name="shrk_vc_woo_categories"]').on('change', function () {
		var param_name = $(this).attr('data-param-name');
		var param_val = $(this).val()
		if( typeof(param_val) !== 'string' ) {
			if ( param_val === null ) {
				param_val = '';
				$(this).next('.multi-count').html('');
			} else {
				if ( typeof(param_val) === 'object' ) {
					$(this).next('.multi-count').html(param_val.length+' selected')
				}
				param_val = param_val.join();			
			}
		}
		$('input[name="'+param_name+'"]').val(param_val);
	});
	
}(window.jQuery);