// source --> https://claibon.co.uk/app/themes/claibon/js/scripts.js?ver=6.9.4 
jQuery(function( $ ){
	if ($('.custom_job_filter').length > 0) {
		/* Home job_manager_chosen_multiselect_args */
		$(".job-manager-category-dropdown").select2({ width: '100%' })
	}

	/* Shrink Header */
	$(window).scroll(function() {    
	    var scroll = $(window).scrollTop();

	    if (scroll >= 500) {
	        $(".navbar-light").addClass("affix");
	    } else {
	        $(".navbar-light").removeClass("affix");
	    }
	});

	// Show application form in single listing page 
	if ( $( 'body' ).hasClass( 'single-job_listing' ) ) {
		$(window).load(function() {
			$('.application_details').css('display','block');
		})
	}

	$(document).on('favorites-updated-single', function(event, favorites, post_id, site_id, status){
		location.reload();
	});

	$(document).on('favorites-cleared', function(event, button){
		location.reload();
	}); 

	// Batch Apply to Jobs
	$(".nameBatch").keyup(function (){
	$(".nameSingle").val($(this).val());
	});
	
	$(".phoneBatch").keyup(function(){
	$(".phoneSingle").val($(this).val())
	});

	$(".emailBatch").keyup(function(){
	$(".emailSingle").val($(this).val())
	});

	$(".messageBatch").keyup(function(){
	$(".messageSingle").val($(this).val())
	});

	$(".resumeBatch").keyup(function(){
	$(".resumeSingle").val($(this).val())
	});

	$(".resumeBatch").change(function(){
		var $this = $(this), $clone = $this.clone();
		$('.resumeSingle').remove();
		$this.after($clone).appendTo('div.formOne .your-resume');
	});

	$(".applyToAll").click(function(){
		$(".applyNow").click();
	});

	if ( $( "#job-code-input input" ).length && $( "#job-code-actual" ).length ) {
		$( "#job-code-input input" ).val( $( "#job-code-actual" ).html() );
	}
});



document.addEventListener( 'wpcf7mailsent', function( event ) {
	var favoriteBtn = document.getElementsByClassName("my_jobs_button")[0]
	var favoriteClr = document.getElementsByClassName("simplefavorites-clear")[0]
	if (favoriteBtn) {
		var hasAppliedClass = favoriteBtn.classList.contains('applied')
		if(hasAppliedClass) {
		favoriteBtn.click();
		}
	}
	if (favoriteClr) {
		favoriteClr.click();
	}
},

    false
);