jQuery(document).ready(function() {
	"use strict";

			//jQuery('.fbbttm-checkout-page-info .fbbttm-fbbttm_place_order').click(function(){

				jQuery(".fbbttm-checkout-page-info #fbbttm_form_place_order").on("submit", function(e){


					
					let remid = jQuery('#fbbttm_form_place_order #fbbttm_place_order').attr('data-id');

					
					var alldata = jQuery('#fbbttm_form_fbbttm_place_order').serialize();
					var target = jQuery('#redirect_url').val();


					let formData = new FormData(this);
				    // Add additional data if needed
			        formData.append('action', 'place_order'); // WordPress AJAX action
			        formData.append('security', ajax_object.nonce); // Nonce for security

					if(jQuery('input[name="fbbttm-payment-method"]:checked').length === 0) {
						  
						jQuery('.fbbttm-error.fbbttm-payment-method').html('Please select payment method').fadeIn('slow');
						jQuery('.fbbttm-error.fbbttm-payment-method').delay(8000).fadeOut('slow');
						return false;
					}
			
					if(remid!=''){

						jQuery('#fbbttm_form_place_order .fbbttm-loader').removeClass('hide');
						jQuery('#fbbttm_form_place_order .fbbttm_place_order').prop('disabled', true);

						jQuery.ajax({
						    method: 'POST',
						    dataType: 'json',
						    url: ajax_object.ajax_url, 
						    data: formData, 
						    processData: false, // Do not process data (required for FormData)
            				contentType: false, // Do not set content-type header (required for FormData)
			    			success: function(response) {	
			    				//return false;
			    				jQuery('.fbbttm-ordersuccess-message').html(response.success);
			    				
			    				var orderkey = response.orderkey;	
			    				let redirecturl = target +'?fbbttmkey='+orderkey;
								if(response.success){

									jQuery('#fbbttm_form_place_order .fbbttm-loader').addClass('hide');
									jQuery('#fbbttm_form_place_order .fbbttm_place_order').prop('disabled', false);

									setTimeout(function() {
									  window.location.href = redirecturl;
									}, 1000);
								 }
								else{

								}

			    			}
			  			});

			  			return false;
					}
				return false;
			});


			


			jQuery('.fbbttm-leftsidebar .fbbttmmenu').click(function(){

				jQuery('.fbbttm-leftsidebar .fbbttmmenu').removeClass('active');
				jQuery(this).addClass('active');
				var divclassname = jQuery(this).attr('data-id');
				jQuery('.fbbttm-myaccountcontent').hide();
				jQuery('.fbbttm-myaccountcontent.'+divclassname).show();
    
			});

			jQuery('.fbbttm-delivery').click(function(){

				jQuery('.fbbttm-deliveryaddress-info.fbbttm-myaccountcontent').show();

			});

			jQuery("#fbbttm-loginform").on("submit", function(e){		

				e.preventDefault();

	  			var formdata = jQuery('#fbbttm-loginform').serialize();

	  			let formData = new FormData(this);
				// Add additional data if needed
				formData.append('action', 'fbbttm_login'); // WordPress AJAX action
       			formData.append('security', ajax_object.nonce); // Nonce for security

	  			jQuery('#fbbttm-loginform .fbbttm-loader').removeClass('hide');
						
				jQuery('#fbbttm-submitlogin').prop('disabled', true);

 	  			jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url: ajax_object.ajax_url, 
			    data: formData, 
			    processData: false, // Do not process data (required for FormData)
	            contentType: false, // Do not set content-type header (required for FormData)
    			success: function(response) {	
    				if(response.message){
    					
						//jQuery('#result').html(response.success);
						jQuery('.fbbttm-login-registerpage .fbbttm-loginform-message').html(response.message).fadeIn('slow');
						jQuery('.fbbttm-loginform-message').html(response.message).fadeIn('slow');

						jQuery('#fbbttm-loginform .fbbttm-loader').removeClass('hide');
						
						jQuery('#fbbttm-loginform #fbbttm-submitlogin').prop('disabled', true);

						if(response.loggedin == true)
						{
							 location.reload();
						}
						else
						{
							jQuery('#fbbttm-loginform .fbbttm-loader').addClass('hide');
							jQuery('#fbbttm-loginform #fbbttm-submitlogin').prop('disabled', false);
						}
					 }
			      }
    		});


				return false;

			});


		//	jQuery('#fbbttm-submitregister').click(function(e){

			jQuery("#fbbttm-registerform").on("submit", function(e){	
				e.preventDefault();
				//var formdata = jQuery('#fbbttm-registerform').serialize();
				let formData = new FormData(this);
				// Add additional data if needed
       			formData.append('action', 'fbbttm_register'); // WordPress AJAX action
       			formData.append('security', ajax_object.nonce); // Nonce for security

				jQuery('#fbbttm-registerform .fbbttm-loader').removeClass('hide');
				jQuery('#fbbttm-submitregister').prop('disabled', true);

				jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url: ajax_object.ajax_url, 
			    data: formData,
	            processData: false, // Do not process data (required for FormData)
	            contentType: false, // Do not set content-type header (required for FormData)
    			success: function(response) {	
    				jQuery('#fbbttm-registerform .fbbttm-error').html(' ');
    				if(response.success){
    					jQuery('#fbbttm-registerform .fbbttm-loader').addClass('hide');
						jQuery('#fbbttm-submitregister').prop('disabled', false);
						jQuery('.fbbttm-login-registerpage .fbbttm-registerform-message').html(response.success).fadeIn('slow');
						jQuery('.fbbttm-login-registerpage .fbbttm-registerform-message').delay(3000).fadeOut('slow');
						jQuery('#fbbttm-registerform').trigger("reset");
					}
					else
					{
						jQuery('#fbbttm-registerform .fbbttm-loader').addClass('hide');
						jQuery('#fbbttm-submitregister').prop('disabled', false);
						jQuery.each(response.error_message, function(key,valueObj){
							jQuery('#fbbttm-registerform .fbbttm-error.'+key).html(valueObj);  
						});																	 
					}
				}
   			});

			return false;	
			});	
			
			
			jQuery('.fbbttm-lostpassword-chk').click(function(e){
				jQuery('.fbbttm-lostpasswordform').removeClass('hide');
				jQuery('#fbbttm-lostpassword').removeClass('hide');
				jQuery('#fbbttm-lostpassword').fadeIn('slow');

				});	
			
			jQuery('.fbbttm-lostpassword').click(function(e){
			
				jQuery('#fbbttm-lostpassword').removeClass('hide');
				jQuery('#fbbttm-lostpassword').fadeIn('slow');
			});	

		    jQuery("#fbbttm-lostpasswordform").on("submit", function(e){
				
				e.preventDefault();
				
				let formData = new FormData(this);
				formData.append('action', 'fbbttm_lostpassword'); // WordPress AJAX action
       			formData.append('security', ajax_object.nonce); // Nonce for security

				jQuery('#fbbttm-lostpasswordform .fbbttm-loader').removeClass('hide');
				jQuery('#fbbttm-submitlostpass').prop('disabled', true);

				jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url: ajax_object.ajax_url, 
			    data: formData,
	            processData: false, // Do not process data (required for FormData)
	            contentType: false, // Do not set content-type header (required for FormData)
    			success: function(response) {	
    				jQuery('.fbbttm-error').html(' ');
    				if(response.success){
						jQuery('#fbbttm-lostpassword .fbbttm-lostpasswordform-message').html(response.success).fadeIn('slow');
						jQuery('#fbbttm-lostpassword .fbbttm-lostpasswordform-message').delay(3000).fadeOut('slow');
						jQuery('#fbbttm-lostpasswordform .fbbttm-loader').addClass('hide');
						jQuery('#fbbttm-submitlostpass').prop('disabled', false);
						jQuery('#fbbttm-lostpasswordform').trigger("reset");
					}
					else
					{
						jQuery('#fbbttm-lostpasswordform .fbbttm-loader').addClass('hide');
						jQuery('#fbbttm-submitlostpass').prop('disabled', false);
						jQuery.each(response.error_message, function(key,valueObj){
							jQuery('#fbbttm-lostpassword .fbbttm-error.'+key).html(valueObj);  
						});
					}
				  }
    			});


				
				return false;


			});	

			 function validateEmail($email) {
			  var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			  return emailReg.test( $email );
			}

			jQuery(".fbbttm-checkout-page-info #fbbttm-email").on('change keyup paste', function(e) {

				var emailval = jQuery(this).val();

				if( !validateEmail(emailval)) { 
					console.log('email not validate'); 
					jQuery('.fbbttm-error.fbbttm-email').text('Please enter valid email address').fadeIn('slow');
					jQuery('.fbbttm-error.fbbttm-email').delay(2000).fadeOut('slow');
					jQuery('.fbbttm-checkout-page-info .fbbttm-cehckout-deliveryinfo').hide();
					return false;
					}else{
						console.log('email validate');



				e.preventDefault();
			
				


				jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url: ajax_object.ajax_url,  
			    data: { 
			    	security: ajax_object.nonce,
					action:'fbbttm_checkemail',
					emailid:emailval
    			}, 
    			success: function(response) {	

    				jQuery('.fbbttm-error').html(' ');

    				if(response.success){
						jQuery('.fbbttm-contact-info .fbbttm-email-class-exist').html(response.success).fadeIn('slow');

						if(response.extramessage.useravailindata == '1')
						{
							jQuery('.fbbttm-checkout-page-info .fbbttm-login-content').show().fadeIn('slow');
							jQuery('.fbbttm-checkout-page-info .fbbttm-cehckout-deliveryinfo').hide();
						}
						else if(response.success.newemail == 1){
							jQuery('.fbbttm-checkout-page-info .fbbttm-login-content').hide();
							jQuery('.fbbttm-checkout-page-info .fbbttm-cehckout-deliveryinfo').show().fadeIn('slow');
							
						}

					}
					else
					{
						jQuery.each(response.error_message, function(key,valueObj){
							jQuery('.fbbttm-checkout-page-info .fbbttm-contact-info .fbbttm-error.'+key).html(valueObj);  
						});
					}
					

    			}

				
    			});

				}


			});


			//jQuery('#addtocartrenew').click(function(e){
			jQuery("#fbbttm_add_to_cart_renew").on("submit", function(e){
			e.preventDefault();


			var alldata = jQuery('#fbbttm_add_to_cart_renew').serialize();

			jQuery('#fbbttm_add_to_cart_renew .fbbttm-loader').removeClass('hide');
						
			jQuery('#fbbttm_add_to_cart_renew #addtocartrenew').prop('disabled', true);

			let formData = new FormData(this);
		    // Add additional data if needed
	        formData.append('action', 'fbbttm_my_dataaddto_cart'); // WordPress AJAX action
	        formData.append('security', ajax_object.nonce); // Nonce for security


			jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url: ajax_object.ajax_url, 
			    data: formData,
			    processData: false, // Do not process data (required for FormData)
            	contentType: false, // Do not set content-type header (required for FormData)
    			success: function(response) {	

    				jQuery('#fbbttm_add_to_cart_renew .fbbttm-error').html(' ');
    				
					if(response.successmessage){

						jQuery('.fbbttm-packageaddcart-message').html(response.successmessage).fadeIn('slow');
						jQuery('.fbbttm-packageaddcart-message').delay(5000).fadeOut('slow');

						setTimeout(function(){ 
						jQuery('#fbbttm_add_to_cart_renew .fbbttm-loader').addClass('hide');
						
						jQuery('#fbbttm_add_to_cart_renew #addtocartrenew').prop('disabled', false);

						jQuery('.fbbttm-foodboxbooker-cartinfo-content').html(response.cartinfoafteradd).fadeIn('slow');
							 //		location.reload(); 
						}, 3000);


						jQuery("#foodboxbooker-model-bg").css("display","none");
						jQuery("#foodboxbooker-model").css("display","none");

						jQuery('#fbbttm_add_to_cart_renew').trigger("reset");
					


					}
					else
					{
						
						jQuery('#fbbttm_add_to_cart_renew .fbbttm-loader').addClass('hide');
						
						jQuery('#fbbttm_add_to_cart_renew #addtocartrenew').prop('disabled', false);

						jQuery('#fbbttm_add_to_cart_renew .fbbttm-error').html(' ');

						jQuery.each(response.error_message, function(key,valueObj){
							
							jQuery('#fbbttm_add_to_cart_renew .fbbttm-error.'+key).html(valueObj).fadeIn('slow');  
							jQuery('#fbbttm_add_to_cart_renew .fbbttm-error.'+key).delay(5000).fadeOut('slow');

						});
					}

    			}
  			});





			});


			//jQuery('#addtocart').click(function(e){
			jQuery("#fbbttm_add_to_cart").on("submit", function(e){	
		
			e.preventDefault();

			var packid = jQuery('#hiddenpackid').val();
			var food_time = jQuery('.food_time').val();
			var alldata = jQuery('#add_to_cart').serialize();

			jQuery('.fbbttm-loader').removeClass('hide');
			jQuery('#addtocart').prop('disabled', true);

			let formData = new FormData(this);
		    // Add additional data if needed
	        formData.append('action', 'fbbttm_my_dataaddto_cart'); // WordPress AJAX action
	        formData.append('security', ajax_object.nonce); // Nonce for security

			jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url: ajax_object.ajax_url, 
			    data:formData, 
			    processData: false,
           		contentType: false, 
    			success: function(response) {	
    				


    				jQuery('#fbbttm_add_to_cart .fbbttm-error').html(' ');
    				
					 if(response.successmessage){
	
						jQuery('.fbbttm-packageaddcart-message').html(response.successmessage).fadeIn('slow');
						jQuery('.fbbttm-packageaddcart-message').delay(5000).fadeOut('slow');
						  setTimeout(function(){ 
						  	jQuery('.fbbttm-loader').addClass('hide');
						  	jQuery('#addtocart').prop('disabled', false);

								jQuery("#foodboxbooker-model-bg").css("display","none");
								jQuery("#foodboxbooker-model").css("display","none");
								jQuery('.fbbttm-foodboxbooker-cartinfo-content').html(response.cartinfoafteradd).fadeIn('slow');
							 	//	location.reload(); 
							}, 3000);
					}	
					else
					{	

						jQuery('.fbbttm-loader').addClass('hide');

						jQuery('#addtocart').prop('disabled', false);
						
						jQuery('#fbbttm_add_to_cart .fbbttm-error').html(' ');

						jQuery.each(response.error_message, function(key,valueObj){
							
							jQuery('#fbbttm_add_to_cart .fbbttm-error.'+key).html(valueObj).fadeIn('slow');  
							jQuery('#fbbttm_add_to_cart .fbbttm-error.'+key).delay(4000).fadeOut('slow');

							if(key=='fbbttm-datemessge')
							{
								jQuery('#datemessge').val('1');		
							}

							if(key=='fbbttm-datemessge-blank')
							{
								jQuery('#datemessge_blank').val('1');		
							}

						});
					}

    			}
  			});

		return false;	

			});


				jQuery('.fbbttm-subscribe').click(function(e){

					e.preventDefault();

					jQuery('#fbbttm_add_to_cart').trigger("reset");
					jQuery('.packbooking-content').show();
					jQuery('.fbbttm-customday-show').addClass('hide');
					
					var packid = jQuery(this).attr('data-id');
					var packname = jQuery(this).attr('data-name');
					var totalmount = jQuery(this).attr('data-totalmount');
					var specialprice = jQuery(this).attr('data-specialprice');
					var price = jQuery(this).attr('data-price');
					var day = jQuery(this).attr('data-day');
					var specialpricewithsymobl = jQuery(this).attr('data-swsymbol');
					var packimage = jQuery(this).attr('data-image');
					var packdesc = jQuery(this).attr('data-desc');
					
					jQuery('#hiddenpackid').val(packid);

					jQuery('.fbbttm-packcontent-info-details .fbbttm-packname').html(packname);
					
					if(specialprice > '0.00'){
				
						jQuery('.fbbttm-packcontent-info-details .fbbttm-baseprice').addClass('specialprice-available');
						jQuery('.fbbttm-packcontent-info-details .fbbttm-specialprice').html(specialpricewithsymobl);

					}
					else
					{
				
						jQuery('.fbbttm-packcontent-info-details .fbbttm-baseprice').removeClass('specialprice-available')
						jQuery('.fbbttm-packcontent-info-details .fbbttm-specialprice').html(' ');
					}

					jQuery('.fbbttm-packcontent-info-details .fbbttm-baseprice').html(price);
					jQuery('.fbbttm-packcontent-info-details .pack-day-val').html(day);
					jQuery('.fbbttm-packcontent-info-details .fbbttm-totalamount-price').html(totalmount);
					jQuery('.fbbttm-packcontent-info-details .fbbttm-pack-img_wraper img').attr('src',packimage);
					jQuery('.fbbttm-packcontent-info-details .fbbttm-pack-info').html(packdesc);


					

					jQuery("#foodboxbooker-model-bg").css("display","block");
					jQuery("#foodboxbooker-model").css("display","block");


				});

			jQuery('.single-fbbttm_fooditems #foodboxbooker-model .cancel').click(function(event){
					event.preventDefault();
					jQuery("#foodboxbooker-model-bg").css("display","none");
					jQuery("#foodboxbooker-model").css("display","none");

			});	

			jQuery('form#fbbttm_add_to_cart input:radio, form#fbbttm_add_to_cart_renew input:radio').click(function() {

			var radioval = jQuery(this).val();
		

			if(radioval == 'custom')
			{
				jQuery('.fbbttm-customday-show').removeClass('hide');
			}
			else
			{
				jQuery('.fbbttm-customday-show').addClass('hide');
			}

		});

		jQuery('.removeitem').click(function(){

				let remid = jQuery(this).attr('data-id');

				jQuery(this).siblings('.fbbttm-loader').removeClass('hide');
				

				jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url: ajax_object.ajax_url, 
			    data: { 
			    	security: ajax_object.nonce,
					action:'remove_item_cart',
					remid:remid
    			}, 
    			success: function(response) {	

    				//jQuery(this).siblings('.fbbttm-loader').addClass('hide');
    				location.reload(); 
    		
    			}
  			});
		return false;		

	 });

		
 jQuery('.fbbttm-orderenewblock #foodboxbooker-model .cancel').click(function(e){

	jQuery(".fbbttm-orderenewblock #foodboxbooker-model-bg").css("display","none");
	jQuery(".fbbttm-orderenewblock #foodboxbooker-model").css("display","none");
	jQuery('.fbbttm-orderenewblock #fbbttm_add_to_cart_renew').trigger("reset");

  });
	

jQuery('.fbbttm-renewlink .fbbttmreneworder').click(function(e){

		e.preventDefault();

	 	

		var bokitemid = jQuery(this).attr('data-id');

		jQuery('#foodboxbooker-model').css('overflow-y','auto');


			jQuery.ajax({
					    method: 'POST',
					    dataType: 'json',
					    url: ajax_object.ajax_url, 
					    data: { 
					    	security: ajax_object.nonce,
							action:'renew_get_packinfo',
							bokitemid:bokitemid
		    			}, 
		    			success: function(response) {
		    			
		    			var packid = response.fbbttm_pack_id;
		    			var packinfo = response.packinfodiv;
		    			
		    			jQuery('#hiddenpackid').val(packid);
		    			jQuery('#fbbttm-packinfo-block').html(packinfo);

		    			jQuery("#foodboxbooker-model-bg").css("display","block");
						jQuery("#foodboxbooker-model").css("display","block");
						jQuery('.row.packbooking-content').fadeIn('slow');
		    				
		    			}
			});






		return false;	


	});



	
	jQuery("#fbbttm-reset-password").on("submit", function(e){	

		e.preventDefault();

		var alldata = jQuery('#fbbttm-reset-password').serialize();


		jQuery('#fbbttm-reset-password .fbbttm-loader').removeClass('hide');
		jQuery('.fbbttm-resetpassword #fbbttm-reset-submit').prop('disabled', true);

		let formData = new FormData(this);
	    // Add additional data if needed
        formData.append('action', 'fbbttm_resetpass'); // WordPress AJAX action
        formData.append('security', ajax_object.nonce); // Nonce for security


			jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url: ajax_object.ajax_url, 
			    data: formData, 
			    processData: false, // Do not process data (required for FormData)
				contentType: false, // Do not set content-type header (required for FormData)
				success: function(response) {
					jQuery('#fbbttm-reset-password .fbbttm-error').html(' ');
						if(response.successmessage){
							jQuery('#fbbttm-reset-password .fbbttm-successmsg').html(response.successmessage).fadeIn('slow');
							jQuery('#fbbttm-reset-password .fbbttm-successmsg').delay(2000).fadeOut('slow');
							setTimeout(function(){ 
								var rdurl = response.redirct_url;
								window.location.href = rdurl;
							}, 3000);
						}
						else
						{
							
							jQuery('#fbbttm-reset-password .fbbttm-loader').addClass('hide');
				
							jQuery('.fbbttm-resetpassword #fbbttm-reset-submit').prop('disabled', false);

							jQuery('#fbbttm-reset-password .fbbttm-error').html(' ');

							jQuery.each(response.error_message, function(key,valueObj){
							
								jQuery('#fbbttm-reset-password .fbbttm-error.'+key).html(valueObj);  

							});
						}
					    			
		    			
		    			}
			});




		return false;

	});

	
	jQuery("#edit-account").on("submit", function(e){	

 	  	e.preventDefault();

 	  	// var formdata = jQuery('#edit-account').serialize();

	  	jQuery('#edit-account .fbbttm-loader').removeClass('hide');
		jQuery('#edit-account #fbbttm-editsubmit').prop('disabled', true);


		let formData = new FormData(this);
	    // Add additional data if needed
        formData.append('action', 'account_edit_formsubmit'); // WordPress AJAX action
        formData.append('security', ajax_object.nonce); // Nonce for security

 	  	 jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url: ajax_object.ajax_url, 
			    data: formData, 
			    processData: false, // Do not process data (required for FormData)
           		contentType: false, // Do not set content-type header (required for FormData)
    			success: function(response) {	

    				jQuery('#edit-account .fbbttm-loader').addClass('hide');
		 			jQuery('#edit-account #fbbttm-editsubmit').prop('disabled', false);

    				if(response.success){

						//jQuery('#result').html(response.success);
						jQuery('#result_editaccount .successcontent').html(response.success).fadeIn('slow');

						jQuery('#password_current').val('');
						jQuery('#password_1').val('');
						jQuery('#password_2').val('');
					}
					else{

						jQuery('.fbbttm-error').html(' ');

						jQuery.each(response.error_message, function(key,valueObj){

						jQuery('.fbbttm-error.'+key).html(valueObj); 
						jQuery('.fbbttm-error.'+key).delay(5000).fadeOut('slow'); 

						});

						return false;

					}

    			}

				
    			});
 	  	 });


		if (jQuery('#fbbttm-useraddressid').length) {

			var fbbuseraddressid = jQuery('#fbbttm-useraddressid').val();

			if(fbbuseraddressid!='')
			{
				jQuery('#fbbttm_form_placeorder').removeClass('hide');
				jQuery('#fbbttm_form_place_order').removeClass('hide');
			}
		}


	 	 if (jQuery('#fbbttm-hiddencid').length) {
		 	var hdncid = jQuery('#fbbttm-hiddencid').val();

	 	 	if(hdncid!=''){
		 	 	setTimeout(function(){ 
		 	 	   	jQuery('#fbbttm-country').trigger("change"); 
		 	 	}, 2000);	
	 		 }
	 	 }


 	 	 jQuery('#fbbttm-country').change(function(){

 	 	  	var id = jQuery(this).val();
	 	  	var hdnsid = jQuery('#fbbttm-hiddensid').val();

	 	  	if(id !='' ){

			 jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			   url: ajax_object.ajax_url, 
			    data: { 
					action:'get_state_as_country',
					id:id,
					hdnsid:hdnsid
    			}, 
    			success: function(response) {	
    				//return false;
					if(response.stateoption){

						jQuery('#fbbttm-state').html(response.stateoption);

					}
				}
  			});
			}
		return false;	

 	  });

 	//  jQuery('#fbbttm-submit').on('click', function(e){
 	    jQuery("#fbbttm-deliveryaddress").on("submit", function(e){	
 	    	e.preventDefault();

			//var tablename = jQuery('#hidtablename').val();

    		let formData = new FormData(this);
	    	// Add additional data if needed
        	formData.append('action'    , 'delivery_formsubmit'); // WordPress AJAX action
        	formData.append('security'  , ajax_object.nonce); // Nonce for security
			        
    		jQuery('#fbbttm-deliveryaddress .fbbttm-loader').removeClass('hide');
						
			jQuery('#fbbttm-deliveryaddress #fbbttm-submit').prop('disabled', true);

			var hidcheckoutpage = jQuery('#hidcheckoutpage').val();

    		jQuery.ajax({
			    method: 'POST',
			    dataType: 'json',
			    url:ajax_object.ajax_url, 
			    data: formData, 
			    processData: false, // Do not process data (required for FormData)
            	contentType: false, // Do not set content-type header (required for FormData)
    			success: function(response) {	
				  jQuery('#fbbttm-deliveryaddress .fbbttm-loader').addClass('hide');
				  jQuery('#fbbttm-deliveryaddress #fbbttm-submit').prop('disabled', false);
					if(response.success)
					 {
						jQuery('#result').html(response.success).fadeIn('slow');
						  if(hidcheckoutpage!=''){
							  if(response.userid && response.useravail==''){
							 	jQuery('#fbbttm_form_place_order #fbbttmuserid').val(response.userid);
							 	jQuery('#fbbttm_form_place_order .fbbttm_place_order').attr('data-id',response.userid);
							 	jQuery('.fbbttm-cehckout-orderlaststep').show();
							 	location.reload();
							  }
							  else
							  {
							  	jQuery('#fbbttm_form_place_order').removeClass('hide');
							  	jQuery('.fbbttm-cehckout-orderlaststep').show();
							  }
						  }
					 }
					else{

						jQuery.each(response.error_message, function(key,valueObj){
							jQuery('.fbbttm-error.'+key).text(valueObj).fadeIn('slow');
							jQuery('.fbbttm-error.'+key).delay(5000).fadeOut('slow');  
						});
						return false;

					}

    			}
  			});

    		
    		return false;

    	});	


	 if (jQuery('#resetpasswordlost').length) {
	 	  var resetpasswordlost = jQuery('#resetpasswordlost').val();

	 	  if(resetpasswordlost!='')
	 	  {
	 	  	jQuery('#fbbttm-lostpassword').removeClass('hide');
	 	  }	
	}	


 
 	
 	

 	 



});