;(function($){
	'use strict';
	jQuery(document).on("exwfqv_updated_shipping_fee", function(event){
		var url_cr = $('input[name=exwf_current_url]').val();
		if(jQuery('.exwf-ckblock-sc .exwf-loc-field select.exck-loc').length){ 
			var $loc = jQuery('.exwf-ckblock-sc .exwf-loc-field select.exck-loc').val();
            if($loc!='' && $loc!=null){
                if (url_cr.indexOf("?") > -1){
                    url_cr = url_cr+"&loc="+$loc;
                }else{
                    url_cr = url_cr+"?loc="+$loc;
                }
            }
        }
		window.location = url_cr;
        return false;
	});
	function exwf_default_data(){
		var _time_del = $('.exwf-ckblock-sc .exwf-deli-field #exwfood_time_deli').val();
		var _date_del = $('.exwf-ckblock-sc .exwf-deli-field #exwfood_date_deli').val();
		var _loc = jQuery('.exwf-ckblock-sc .exwf-loc-field select.exck-loc').val();
		var _person = jQuery('.exwf-ckblock-sc .exwf-loc-field #exwfood_person_dinein').val();
		var param = {
			action: 'exwf_ckblock_data',
			date: _date_del,
			time: _time_del,
			loc: _loc,
			person: _person,
		};
		var $url_ajax  = jQuery('.ex-fdlist input[name=ajax_url]').val();
		$.ajax({
			type: "post",
			url: $url_ajax,
			dataType: 'json',
			data: (param),
			success: function(data){
				$(document).trigger('exwf_ckblock_dtchange');
				return false;
			}
		});
	}
	$('body').on('input', '.exwf-ckblock-sc .exwf-deli-field input#exwfood_time_deli,.exwf-ckblock-sc .exwf-deli-field input#exwfood_person_dinein', function() {
		setTimeout(function(){
			exwf_default_data();
		}, 200);
	});
	jQuery(document).on("exwf_time_delivery_slots_loaded", function(event){
		setTimeout(function(){
			exwf_default_data();
		}, 200);
	});
}(jQuery));