//This is for custom sticky header, in combination with css
jQuery(window).scroll(function() {    
    var scroll = jQuery(window).scrollTop();

    if (scroll >= 118) {
        jQuery('.custom-header-menu').addClass('custom-fixed-menu');
		jQuery("#main-content").addClass('on-fixed-header');
    } else {
		jQuery('.custom-header-menu').removeClass('custom-fixed-menu');
		jQuery("#main-content").removeClass('on-fixed-header');
	}
});


jQuery(document).ready(function() {
	//This wraps Title and Caption of Gallery items into one container for easier styling, see css
	jQuery('.custom-gallery-module .et_pb_gallery_title').each(function() {
		jQuery(this).next('.et_pb_gallery_caption').andSelf().wrapAll('<div class="custom-gallery-overlay-text"></div>');
	});
	
	//This should scrape the overlay bg color selected in the module and assign that color to the title and caption background
	var galleryOverlayBG = jQuery('.custom-gallery-module .et_pb_gallery_image .et_overlay').css('backgroundColor');
	jQuery('.custom-gallery-module .custom-gallery-overlay-text').css('background-color', galleryOverlayBG);
	
	//This triggers the click of native overlay, since it is invisible in front end
	jQuery('.custom-gallery-module .custom-gallery-overlay-text').on('click', function() {
		jQuery(this).prev().find('.et_overlay').click();
	});
	
	//This scrapes the gallery pagination color selected inside the module and assigns it as background color so the number are transformed into dots. Set timeout is used so Divi does not override the function. Delete if you want to use numbered pagination instead
	setTimeout(function() {
		var paginationColor = jQuery('.custom-gallery-module .et_pb_gallery_pagination .page a').css('color');	
		jQuery('.custom-gallery-module .et_pb_gallery_pagination .page a').css('background-color', paginationColor);
    }, 2000);
	
	//This code is to clear text from search box labels on the sidebar, so the icon can be injected with css
	jQuery('.widget_search #searchform .screen-reader-text').text('');
	jQuery('.widget_search #searchform #s').attr('placeholder', 'Search Here');
	
});