(function ($) {
	'use strict';

	//Button Colors Tabs
	wp.customize(
		'eronex_button_colors_tab',
		function (value) {
			function toggleColors(newVal) {
				if (newVal === 'normal') {
					// Show Normal fields
					$( '#customize-control-eronex_button_color' ).show();
					$( '#customize-control-eronex_button_bg' ).show();
					$( '#customize-control-eronex_button_border' ).show();
					// Hide Hover fields
					$( '#customize-control-eronex_button_hover_color' ).hide();
					$( '#customize-control-eronex_button_hover_bg' ).hide();
					$( '#customize-control-eronex_button_hover_border' ).hide();
				} else {
					// Show Hover fields
					$( '#customize-control-eronex_button_color' ).hide();
					$( '#customize-control-eronex_button_bg' ).hide();
					$( '#customize-control-eronex_button_border' ).hide();
					// Hide Normal fields
					$( '#customize-control-eronex_button_hover_color' ).show();
					$( '#customize-control-eronex_button_hover_bg' ).show();
					$( '#customize-control-eronex_button_hover_border' ).show();
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

	//Pagination Colors Tabs
	wp.customize(
		'eronex_pagination_colors_tab',
		function (value) {
			function toggleColors(newVal) {
				if (newVal === 'normal') {
					// Show Normal fields
					$( '#customize-control-eronex_pagination_color' ).show();
					$( '#customize-control-eronex_pagination_bg' ).show();
					$( '#customize-control-eronex_pagination_border_color' ).show();
					// Hide Hover fields
					$( '#customize-control-eronex_pagination_hover_color' ).hide();
					$( '#customize-control-eronex_pagination_hover_bg' ).hide();
					$( '#customize-control-eronex_pagination_hover_border' ).hide();
					// Hide Active fields
					$( '#customize-control-eronex_pagination_active_color' ).hide();
					$( '#customize-control-eronex_pagination_active_bg' ).hide();
					$( '#customize-control-eronex_pagination_active_border' ).hide();
				} else if (newVal === 'hover') {
					// Hide Normal fields
					$( '#customize-control-eronex_pagination_color' ).hide();
					$( '#customize-control-eronex_pagination_bg' ).hide();
					$( '#customize-control-eronex_pagination_border_color' ).hide();
					// Show Hover fields
					$( '#customize-control-eronex_pagination_hover_color' ).show();
					$( '#customize-control-eronex_pagination_hover_bg' ).show();
					$( '#customize-control-eronex_pagination_hover_border' ).show();
					// Hide Active fields
					$( '#customize-control-eronex_pagination_active_color' ).hide();
					$( '#customize-control-eronex_pagination_active_bg' ).hide();
					$( '#customize-control-eronex_pagination_active_border' ).hide();
				} else {
					// Hide Normal fields
					$( '#customize-control-eronex_pagination_color' ).hide();
					$( '#customize-control-eronex_pagination_bg' ).hide();
					$( '#customize-control-eronex_pagination_border_color' ).hide();
					// Hide Hover fields
					$( '#customize-control-eronex_pagination_hover_color' ).hide();
					$( '#customize-control-eronex_pagination_hover_bg' ).hide();
					$( '#customize-control-eronex_pagination_hover_border' ).hide();
					// Show Active fields
					$( '#customize-control-eronex_pagination_active_color' ).show();
					$( '#customize-control-eronex_pagination_active_bg' ).show();
					$( '#customize-control-eronex_pagination_active_border' ).show();
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

	//Sticky Header
	let sticky_header = false;
	wp.customize('eronex_header_sticky', function (setting) {
		sticky_header = setting.get();
		setting.bind(function (newValue) {
			sticky_header = newValue;
			if(sticky_header){
				$( '#customize-control-eronex_sticky_nav_menu_color' ).show();
				$( '#customize-control-eronex_sticky_nav_submenu_color' ).show();
			}else{
				$( '#customize-control-eronex_sticky_nav_menu_color' ).hide();
				$( '#customize-control-eronex_sticky_nav_submenu_color' ).hide();
			}
		});
	});

	//Menu Colors Tabs
	wp.customize(
		'eronex_nav_menu_colors_tab',
		function (value) {
			function toggleColors(newVal) {
				if (newVal === 'normal') {
					// Show Normal fields
					$( '#customize-control-eronex_sticky_nav_menu_color' ).hide();
					$( '#customize-control-eronex_nav_menu_color' ).show();
					if(sticky_header){
						$( '#customize-control-eronex_sticky_nav_menu_color' ).show();
					}
					// Hide Hover fields
					$( '#customize-control-eronex_nav_menu_hover_color' ).hide();
					$('#customize-control-eronex_sticky_nav_menu_hover_color').hide();
					// Hide Active fields
					$( '#customize-control-eronex_nav_menu_active_color' ).hide();
					$('#customize-control-eronex_sticky_nav_menu_active_color').hide();

				} else if (newVal === 'hover') {
					// Hide Normal fields
					$( '#customize-control-eronex_nav_menu_color' ).hide();
					$( '#customize-control-eronex_sticky_nav_menu_color' ).hide();
					// Show Hover fields
					$( '#customize-control-eronex_nav_menu_hover_color' ).show();
					if(sticky_header) {
						$('#customize-control-eronex_sticky_nav_menu_hover_color').show();
					}
					// Hide Active fields
					$( '#customize-control-eronex_nav_menu_active_color' ).hide();
					$('#customize-control-eronex_sticky_nav_menu_active_color').hide();
				} else {
					// Hide Normal fields
					$( '#customize-control-eronex_nav_menu_color' ).hide();
					$('#customize-control-eronex_sticky_nav_menu_color').hide();
					// Hide Hover fields
					$( '#customize-control-eronex_nav_menu_hover_color' ).hide();
					$('#customize-control-eronex_sticky_nav_menu_hover_color').hide();
					// Show Active fields
					$( '#customize-control-eronex_nav_menu_active_color' ).show();
					if(sticky_header){
					$( '#customize-control-eronex_sticky_nav_menu_active_color' ).show();
					}
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

	//Submenu Colors Tabs
	wp.customize(
		'eronex_nav_submenu_colors_tab',
		function (value) {
			function toggleColors(newVal) {

				if (newVal === 'normal') {
					// Show Normal fields
					$( '#customize-control-eronex_sticky_nav_submenu_color' ).hide();
					$( '#customize-control-eronex_nav_submenu_color' ).show();
					if(sticky_header){
						$( '#customize-control-eronex_sticky_nav_submenu_color' ).show();
					}
					// Hide Hover fields
					$( '#customize-control-eronex_nav_submenu_hover_color' ).hide();
					$('#customize-control-eronex_sticky_nav_submenu_hover_color').hide();
					// Hide Active fields
					$( '#customize-control-eronex_nav_submenu_active_color' ).hide();
					$('#customize-control-eronex_sticky_nav_submenu_active_color').hide();

				} else if (newVal === 'hover') {
					// Hide Normal fields
					$( '#customize-control-eronex_nav_submenu_color' ).hide();
					$( '#customize-control-eronex_sticky_nav_submenu_color' ).hide();
					// Show Hover fields
					$( '#customize-control-eronex_nav_submenu_hover_color' ).show();
					if(sticky_header) {
						$('#customize-control-eronex_sticky_nav_submenu_hover_color').show();
					}
					// Hide Active fields
					$( '#customize-control-eronex_nav_submenu_active_color' ).hide();
					$('#customize-control-eronex_sticky_nav_submenu_active_color').hide();
				} else {
					// Hide Normal fields
					$( '#customize-control-eronex_nav_submenu_color' ).hide();
					$('#customize-control-eronex_sticky_nav_submenu_color').hide();
					// Hide Hover fields
					$( '#customize-control-eronex_nav_submenu_hover_color' ).hide();
					$('#customize-control-eronex_sticky_nav_submenu_hover_color').hide();
					// Show Active fields
					$( '#customize-control-eronex_nav_submenu_active_color' ).show();
					if(sticky_header){
						$( '#customize-control-eronex_sticky_nav_submenu_active_color' ).show();
					}
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

	//Search Toggle
	wp.customize(
		'eronex_search_toggle_colors_tab',
		function (value) {
			function toggleColors(newVal) {
				if (newVal === 'normal') {
					// Show Normal fields
					$( '#customize-control-eronex_search_toggle_color' ).show();
					$( '#customize-control-eronex_search_toggle_bg' ).show();
					$( '#customize-control-eronex_search_toggle_border_color' ).show();
					$( '#customize-control-eronex_sticky_search_toggle_color' ).show();
					$( '#customize-control-eronex_sticky_search_toggle_bg' ).show();
					$( '#customize-control-eronex_sticky_search_toggle_border_color' ).show();
					// Hide Hover fields
					$( '#customize-control-eronex_search_toggle_hover_color' ).hide();
					$( '#customize-control-eronex_search_toggle_hover_bg' ).hide();
					$( '#customize-control-eronex_search_toggle_hover_border' ).hide();
					$( '#customize-control-eronex_sticky_search_toggle_hover_color' ).hide();
					$( '#customize-control-eronex_sticky_search_toggle_hover_bg' ).hide();
					$( '#customize-control-eronex_sticky_search_toggle_hover_border' ).hide();
				} else {
					// Show Hover fields
					$( '#customize-control-eronex_search_toggle_color' ).hide();
					$( '#customize-control-eronex_search_toggle_bg' ).hide();
					$( '#customize-control-eronex_search_toggle_border_color' ).hide();
					$( '#customize-control-eronex_sticky_search_toggle_color' ).hide();
					$( '#customize-control-eronex_sticky_search_toggle_bg' ).hide();
					$( '#customize-control-eronex_sticky_search_toggle_border_color' ).hide();
					// Hide Normal fields
					$( '#customize-control-eronex_search_toggle_hover_color' ).show();
					$( '#customize-control-eronex_search_toggle_hover_bg' ).show();
					$( '#customize-control-eronex_search_toggle_hover_border' ).show();
					$( '#customize-control-eronex_sticky_search_toggle_hover_color' ).show();
					$( '#customize-control-eronex_sticky_search_toggle_hover_bg' ).show();
					$( '#customize-control-eronex_sticky_search_toggle_hover_border' ).show();
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

	//Search Toggle
	wp.customize(
		'eronex_search_input_colors_tab',
		function (value) {
			function inputColors(newVal) {
				if (newVal === 'normal') {
					// Show Normal fields
					$( '#customize-control-eronex_search_input_color' ).show();
					$( '#customize-control-eronex_search_input_bg' ).show();
					$( '#customize-control-eronex_search_input_border_color' ).show();
					$( '#customize-control-eronex_sticky_search_input_color' ).show();
					$( '#customize-control-eronex_sticky_search_input_bg' ).show();
					$( '#customize-control-eronex_sticky_search_input_border_color' ).show();
					// Hide Hover fields
					$( '#customize-control-eronex_search_input_focus_color' ).hide();
					$( '#customize-control-eronex_search_input_focus_bg' ).hide();
					$( '#customize-control-eronex_search_input_focus_border' ).hide();
					$( '#customize-control-eronex_sticky_search_input_focus_color' ).hide();
					$( '#customize-control-eronex_sticky_search_input_focus_bg' ).hide();
					$( '#customize-control-eronex_sticky_search_input_focus_border' ).hide();
				} else {
					// Show Hover fields
					$( '#customize-control-eronex_search_input_color' ).hide();
					$( '#customize-control-eronex_search_input_bg' ).hide();
					$( '#customize-control-eronex_search_input_border_color' ).hide();
					$( '#customize-control-eronex_sticky_search_input_color' ).hide();
					$( '#customize-control-eronex_sticky_search_input_bg' ).hide();
					$( '#customize-control-eronex_sticky_search_input_border_color' ).hide();
					// Hide Normal fields
					$( '#customize-control-eronex_search_input_focus_color' ).show();
					$( '#customize-control-eronex_search_input_focus_bg' ).show();
					$( '#customize-control-eronex_search_input_focus_border' ).show();
					$( '#customize-control-eronex_sticky_search_input_focus_color' ).show();
					$( '#customize-control-eronex_sticky_search_input_focus_bg' ).show();
					$( '#customize-control-eronex_sticky_search_input_focus_border' ).show();
				}
			}
			value.bind(
				function (newVal) {
					inputColors( newVal )}
			);
			inputColors( value.get() );
		}
	);

    //Search Button
    wp.customize(
        'eronex_header_button_colors_tab',
        function (value) {
            function toggleColors(newVal) {
                if (newVal === 'normal') {
                    // Show Normal fields
                    $( '#customize-control-eronex_header_button_color' ).show();
                    $( '#customize-control-eronex_header_button_bg' ).show();
                    $( '#customize-control-eronex_header_button_border_color' ).show();
					$( '#customize-control-eronex_sticky_header_button_color' ).show();
					$( '#customize-control-eronex_sticky_header_button_bg' ).show();
					$( '#customize-control-eronex_sticky_header_button_border_color' ).show();
                    // Hide Hover fields
                    $( '#customize-control-eronex_header_button_hover_color' ).hide();
                    $( '#customize-control-eronex_header_button_hover_bg' ).hide();
                    $( '#customize-control-eronex_header_button_hover_border' ).hide();
					$( '#customize-control-eronex_sticky_header_button_hover_color' ).hide();
					$( '#customize-control-eronex_sticky_header_button_hover_bg' ).hide();
					$( '#customize-control-eronex_sticky_header_button_hover_border' ).hide();
                } else {
                    // Show Hover fields
                    $( '#customize-control-eronex_header_button_color' ).hide();
                    $( '#customize-control-eronex_header_button_bg' ).hide();
                    $( '#customize-control-eronex_header_button_border_color' ).hide();
					$( '#customize-control-eronex_sticky_header_button_color' ).hide();
					$( '#customize-control-eronex_sticky_header_button_bg' ).hide();
					$( '#customize-control-eronex_sticky_header_button_border_color' ).hide();
                    // Hide Normal fields
                    $( '#customize-control-eronex_header_button_hover_color' ).show();
                    $( '#customize-control-eronex_header_button_hover_bg' ).show();
                    $( '#customize-control-eronex_header_button_hover_border' ).show();
					$( '#customize-control-eronex_sticky_header_button_hover_color' ).show();
					$( '#customize-control-eronex_sticky_header_button_hover_bg' ).show();
					$( '#customize-control-eronex_sticky_header_button_hover_border' ).show();
                }
            }
            value.bind(
                function (newVal) {
                    toggleColors( newVal )}
            );
            toggleColors( value.get() );
        }
    );

	//Hamburger Toggle
	wp.customize(
		'eronex_hamburger_toggle_colors_tab',
		function (value) {
			function toggleColors(newVal) {
				if (newVal === 'normal') {
					// Show Normal fields
					$( '#customize-control-eronex_hamburger_toggle_color' ).show();
					$( '#customize-control-eronex_hamburger_toggle_bg' ).show();
					$( '#customize-control-eronex_hamburger_toggle_border_color' ).show();
					$( '#customize-control-eronex_sticky_hamburger_toggle_color' ).show();
					$( '#customize-control-eronex_sticky_hamburger_toggle_bg' ).show();
					$( '#customize-control-eronex_sticky_hamburger_toggle_border_color' ).show();
					// Hide Hover fields
					$( '#customize-control-eronex_hamburger_toggle_hover_color' ).hide();
					$( '#customize-control-eronex_hamburger_toggle_hover_bg' ).hide();
					$( '#customize-control-eronex_hamburger_toggle_hover_border' ).hide();
					$( '#customize-control-eronex_sticky_hamburger_toggle_hover_color' ).hide();
					$( '#customize-control-eronex_sticky_hamburger_toggle_hover_bg' ).hide();
					$( '#customize-control-eronex_sticky_hamburger_toggle_hover_border' ).hide();
				} else {
					// Show Hover fields
					$( '#customize-control-eronex_hamburger_toggle_color' ).hide();
					$( '#customize-control-eronex_hamburger_toggle_bg' ).hide();
					$( '#customize-control-eronex_hamburger_toggle_border_color' ).hide();
					$( '#customize-control-eronex_sticky_hamburger_toggle_color' ).hide();
					$( '#customize-control-eronex_sticky_hamburger_toggle_bg' ).hide();
					$( '#customize-control-eronex_sticky_hamburger_toggle_border_color' ).hide();
					// Hide Normal fields
					$( '#customize-control-eronex_hamburger_toggle_hover_color' ).show();
					$( '#customize-control-eronex_hamburger_toggle_hover_bg' ).show();
					$( '#customize-control-eronex_hamburger_toggle_hover_border' ).show();
					$( '#customize-control-eronex_sticky_hamburger_toggle_hover_color' ).show();
					$( '#customize-control-eronex_sticky_hamburger_toggle_hover_bg' ).show();
					$( '#customize-control-eronex_sticky_hamburger_toggle_hover_border' ).show();
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

	//Hamburger Close Colors Tabs
	wp.customize(
		'eronex_hamburger_close_colors_tab',
		function (value) {
			function toggleColors(newVal) {
				if (newVal === 'normal') {
					$( '#customize-control-eronex_hamburger_close_color' ).show();
					$( '#customize-control-eronex_hamburger_close_bg' ).show();
					$( '#customize-control-eronex_hamburger_close_border_color' ).show();
					$( '#customize-control-eronex_hamburger_close_hover_color' ).hide();
					$( '#customize-control-eronex_hamburger_close_hover_bg' ).hide();
					$( '#customize-control-eronex_hamburger_close_hover_border' ).hide();
				} else {
					$( '#customize-control-eronex_hamburger_close_color' ).hide();
					$( '#customize-control-eronex_hamburger_close_bg' ).hide();
					$( '#customize-control-eronex_hamburger_close_border_color' ).hide();
					$( '#customize-control-eronex_hamburger_close_hover_color' ).show();
					$( '#customize-control-eronex_hamburger_close_hover_bg' ).show();
					$( '#customize-control-eronex_hamburger_close_hover_border' ).show();
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

	//Hamburger Menu Colors Tabs
	wp.customize(
		'eronex_hamburger_menu_colors_tab',
		function (value) {
			function toggleColors(newVal) {
				if (newVal === 'normal') {
					$( '#customize-control-eronex_hamburger_menu_color' ).show();
					$( '#customize-control-eronex_hamburger_menu_hover_color' ).hide();
					$( '#customize-control-eronex_hamburger_menu_active_color' ).hide();
				} else if (newVal === 'hover') {
					$( '#customize-control-eronex_hamburger_menu_color' ).hide();
					$( '#customize-control-eronex_hamburger_menu_hover_color' ).show();
					$( '#customize-control-eronex_hamburger_menu_active_color' ).hide();
				} else {
					$( '#customize-control-eronex_hamburger_menu_color' ).hide();
					$( '#customize-control-eronex_hamburger_menu_hover_color' ).hide();
					$( '#customize-control-eronex_hamburger_menu_active_color' ).show();
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

	//Hamburger Dropdown Icon Colors Tabs
	wp.customize(
		'eronex_hamburger_dropdown_colors_tab',
		function (value) {
			function toggleColors(newVal) {
				if (newVal === 'normal') {
					$( '#customize-control-eronex_hamburger_dropdown_color' ).show();
					$( '#customize-control-eronex_hamburger_dropdown_bg' ).show();
					$( '#customize-control-eronex_hamburger_dropdown_hover_color' ).hide();
					$( '#customize-control-eronex_hamburger_dropdown_hover_bg' ).hide();
				} else {
					$( '#customize-control-eronex_hamburger_dropdown_color' ).hide();
					$( '#customize-control-eronex_hamburger_dropdown_bg' ).hide();
					$( '#customize-control-eronex_hamburger_dropdown_hover_color' ).show();
					$( '#customize-control-eronex_hamburger_dropdown_hover_bg' ).show();
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

	//Hamburger Back Button Colors Tabs
	wp.customize(
		'eronex_hamburger_back_colors_tab',
		function (value) {
			function toggleColors(newVal) {
				if (newVal === 'normal') {
					$( '#customize-control-eronex_hamburger_back_color' ).show();
					$( '#customize-control-eronex_hamburger_back_bg' ).show();
					$( '#customize-control-eronex_hamburger_back_border_color' ).show();
					$( '#customize-control-eronex_hamburger_back_hover_color' ).hide();
					$( '#customize-control-eronex_hamburger_back_hover_bg' ).hide();
					$( '#customize-control-eronex_hamburger_back_hover_border' ).hide();
				} else {
					$( '#customize-control-eronex_hamburger_back_color' ).hide();
					$( '#customize-control-eronex_hamburger_back_bg' ).hide();
					$( '#customize-control-eronex_hamburger_back_border_color' ).hide();
					$( '#customize-control-eronex_hamburger_back_hover_color' ).show();
					$( '#customize-control-eronex_hamburger_back_hover_bg' ).show();
					$( '#customize-control-eronex_hamburger_back_hover_border' ).show();
				}
			}
			value.bind(
				function (newVal) {
					toggleColors( newVal )}
			);
			toggleColors( value.get() );
		}
	);

}(jQuery));