	// ===============================================================
	// Load Parent Information Flags
	// ===============================================================	
	function HTTP_PARENT_LOAD()
	{
	}
	

	// ===============================================================
	// EditHandler Flags
	// ===============================================================	
	
	function HTTP_LOAD(CALLBACK_FUNCTION)
	{
		// Escape if new item
		// ...........................................
		if(JSRC_FLAG.IS_NULL_BIGINT(PROPERTY_ACC_BFIP_ID, 1, 1))
		{
			return;
		}
		
		
		// Load DB data of item
		// ...........................................
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._ACCOUNT._BFIP.CUS_GET_THEN_POPULATE_FORM
		(
			function()
			{
				CUS_SEND_DIALOG_TRY_DISMISS();
				if(JSVC_VAR.VAR_ISSET(CALLBACK_FUNCTION))
				{
					CALLBACK_FUNCTION();
				}
			},
			
			"BFIP_MODAL", 
			FLAG_TINYINT_NULL, 
			PROPERTY_ACC_BFIP_ID
		);
		
		
		// Clear Changes due to loading
		// ...........................................
		
		
	}


	// ===============================================================
	// Trims empty spaces and perform convertion for numeric fields.
	// ===============================================================
	function FIX_INPUT()
	{
		// Fix String Fields
		// ...........................................
		JSOC_INPUT_TEXT.CTL_TRIM(ACC_BFIP_IP_TXT);
		JSOC_INPUT_TEXT.CTL_TRIM(ACC_BFIP_DESCRIPTION_TXT);
		
		
		// Fix Numeric Fields (if field type is not number.)
		// ...........................................
			JSOC_INPUT_TEXT.CTL_NVAL(ACC_BFIP_FAIL_COUNT_TXT);
			JSOC_INPUT_TEXT.CTL_NVAL(ACC_BFIP_LOCK_COUNT_TXT);
			JSOC_INPUT_TEXT.CTL_NVAL(ACC_BFIP_SUCCESS_COUNT_TXT);


		// Fix Password Fields
		// ...........................................
	}

		
	// ===============================================================
	// Request Save
	// ===============================================================
	function HTTP_SAVE(CALLBACK_METHOD)
	{

		// Sanitize User Inputs
		// _______________________________________________________________________
		FIX_INPUT();
	
	
		// Check Edit Status
		// _______________________________________________________________________
		if(EDIT_HANDLER.REF_IS_MODIFIED == false)
		{
			JSVC_INFO.VAR_NOTHING_TO_SAVE(function(){CALLBACK_METHOD(false);})	
			return;		
		}


		// Validate Null [String Input]
		// _______________________________________________________________________
		if(JSOC_INPUT_TEXT.CTL_VALIDATE(ACC_BFIP_IP_TXT, "IP Address", null, 1, 255) == false)
		{
			ACC_BFIP_IP_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
			ACC_BFIP_IP_TXT.focus();
			return false;
		}
		if(JSOC_INPUT_TEXT.CTL_VALIDATE(ACC_BFIP_DESCRIPTION_TXT, "Description", null, 1, 255) == false)
		{
			ACC_BFIP_DESCRIPTION_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
			ACC_BFIP_DESCRIPTION_TXT.focus();
			return false;
		}
		
		
		// Validate Zero [Numeric Input]
		// _______________________________________________________________________
	
	
		// Validate Negative [Numeric Input]
		// _______________________________________________________________________
		if(JSOC_INPUT_TEXT.CTL_NVAL(ACC_BFIP_FAIL_COUNT_TXT) < 0)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Fail Count cannot be negative.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					ACC_BFIP_FAIL_COUNT_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					ACC_BFIP_FAIL_COUNT_TXT.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		if(JSOC_INPUT_TEXT.CTL_NVAL(ACC_BFIP_LOCK_COUNT_TXT) < 0)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Lockout Count cannot be negative.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					ACC_BFIP_LOCK_COUNT_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					ACC_BFIP_LOCK_COUNT_TXT.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		if(JSOC_INPUT_TEXT.CTL_NVAL(ACC_BFIP_SUCCESS_COUNT_TXT) < 0)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Success Count cannot be negative.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					ACC_BFIP_SUCCESS_COUNT_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					ACC_BFIP_SUCCESS_COUNT_TXT.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		
		
		// Validate Range [Numeric Input]
		// _______________________________________________________________________	


		// Foreign key check
		// _______________________________________________________________________
		

		// Validate Duplicates
		// _______________________________________________________________________
		var EXCEPTION_ROW_INDEX = -1;
		if(PROPERTY_ACC_BFIP_ID >= 0)
		{
			EXCEPTION_ROW_INDEX = PROPERTY_EDIT_ROW_INDEX;
		}
			

		
		
		// Password Items (if available)
		// _______________________________________________________________________
		
		
		// CheckBox Items (if available)
		// _______________________________________________________________________

	
		// File is required
		// _______________________________________________________________________
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_ACC_BFIP_ID_FILE_FP") &&
			PARAM_ACC_BFIP_ID_FILE_FP.files.length <= 0
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_MISSING_INPUT("Upload File", false), 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					PARAM_ACC_BFIP_ID_FILE_FP.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					CALLBACK_METHOD(false);
				}
			);		
			return;	
		}
		
	
		// File is too large (Sample Code : 3mb)
		// _______________________________________________________________________
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_ACC_BFIP_ID_FILE_FP") &&
			PARAM_ACC_BFIP_ID_FILE_FP.files[0].size > 1024 * 1024 * 3
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Selected file is too large. File size is restricted to 3mb or below',
				'Information',
				'OK', 'ERROR',
				function()
				{
					CALLBACK_METHOD(false);
				}
			);	
		   PARAM_ACC_BFIP_ID_FILE_FP.value = "";
		   return;
		};
		
		 

		
		// Save item [Prepare]
		// _______________________________________________________________________
		var SAVE_MAP_ARRAY = JSCUS_SQL._ACCOUNT._BFIP.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
		// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_PARENT_ID', PROPERTY_PARENT_ID);		// Parent ID Sample
		// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_PARENT_ID', INPUT_FILE_ELEMENT_FP);		// File Upload Sample
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_ACC_BFIP_ID", PROPERTY_ACC_BFIP_ID);				
		
			
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_ACC_BFIP_IP", JSOC_ELEMENT.VAR_VALUE(ACC_BFIP_IP_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_ACC_BFIP_DESCRIPTION", JSOC_ELEMENT.VAR_VALUE(ACC_BFIP_DESCRIPTION_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_ACC_BFIP_FAIL_COUNT", JSVC_NUM.VAR_NVALL(JSOC_ELEMENT.VAR_VALUE(ACC_BFIP_FAIL_COUNT_TXT)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_ACC_BFIP_LOCK_COUNT", JSVC_NUM.VAR_NVALL(JSOC_ELEMENT.VAR_VALUE(ACC_BFIP_LOCK_COUNT_TXT)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_ACC_BFIP_SUCCESS_COUNT", JSVC_NUM.VAR_NVALL(JSOC_ELEMENT.VAR_VALUE(ACC_BFIP_SUCCESS_COUNT_TXT)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_ACC_BFIP_STATUS", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(ACC_BFIP_STATUS_CMB)));
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_ACC_BFIP_ID_FILE_FP"))
		{
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_ACC_BFIP_ID_FILE", PARAM_ACC_BFIP_ID_FILE_FP);
		}
		
		
		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = 			
			function(IS_SUCCESS, HTTP_RESPONSE)
			{
				// Disable Dialogs
				// ...........................................
				CUS_SEND_DIALOG_TRY_DISMISS();
				
				// Handle Error
				// ...........................................
				if(IS_SUCCESS === false)
				{
					METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);	
					return;
				}
				
				// Catch JSON Error
				// ...........................................
				else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
				{
					METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
					return;			
				}
					
				// Read Response
				// ...........................................
				else
				{
					// Load Response
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
					if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
					{
						METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
						return;
					}
					
			
					// Post Save Action
					else
					{				
						// Update Changes to DataGridView
						if(PROPERTY_ACC_BFIP_ID > 0)
						{
							HTTP_SEARCH(PROPERTY_ACC_BFIP_ID, PROPERTY_EDIT_ROW_INDEX);
						}
						
						// Load new item into the DataGridView
						else
						{
							// Retrieve Inserted ID
							PROPERTY_ACC_BFIP_ID = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", "1"));
							
							// Add new line
							BFIP_DGV.ROW.INSERT_AT(0);
							HTTP_SEARCH(PROPERTY_ACC_BFIP_ID, 0);
						}	

						// Lift edit and Exit EditMode
						EDIT_HANDLER.REF_IS_MODIFIED = false;
						EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;			
						if
						(
							JSOC_ELEMENT.VAR_ELEMENT_EXISTS('BFIP_MODAL') == true
						)
						{
							JSOC_DIALOG.VAR_MODAL('BFIP_MODAL', false);
						}
						
						//SWAP_EDIT_MODE(false);
						CALLBACK_METHOD(true);											
					}
				}
			};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._ACCOUNT._BFIP.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		
	}
	
	
	// ===============================================================
	// Request Delete
	// ===============================================================
	function HTTP_DELETE(CALLBACK_METHOD, ROW_INDEX)
	{
		// Escape if Disabled
		// _______________________________________________________________________
		if(JSVC_VAR.VAR_ISSET(DELETE_BBI) && DELETE_BBI.Enabled == false)
		{
			CALLBACK_METHOD(false);
			return;
		}

		// Escape if nothing selected
		// _______________________________________________________________________
		if(ROW_INDEX < 0)
		{
			JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_NOTHING_SELECTED(true);
			CALLBACK_METHOD(false);
			return;
		}
		
		// Initialize
		// _______________________________________________________________________
		var DELETE_ITEM_DESCRIPTION = BFIP_DGV.CELL.VALUE('ACC_BFIP_IP', ROW_INDEX);
		
		
		
		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = function
		(
			IS_SUCCESS, 
			HTTP_RESPONSE
		)
		{
			// Disable Dialogs
			// ...........................................
			CUS_SEND_DIALOG_TRY_DISMISS();
				
				
			// Handle Error
			// ...........................................
			if(IS_SUCCESS === false)
			{
				METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);
				return;
			}
			
			// Catch JSON Error
			// ...........................................
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
				return;			
			}
			
			
			// Read Response
			// ...........................................
			else
			{
				// Load Response
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
					return;
				}
				
				// Post Delete Action
				else
				{
					BFIP_DGV.ROW.REMOVE_AT(ROW_INDEX);
					BFIP_DGV.COLUMN.ROW_COUNT_PRINT('ROW_COUNT');
					JSVC_INFO.VAR_RECORD_DELETED
					(
						DELETE_ITEM_DESCRIPTION, 
						function()
						{
							CALLBACK_METHOD(true);
						}
					);		
				}
			}
		};
		
		
		// Request User Verification for Delete
		// _______________________________________________________________________
		JSVC_INFO.VAR_VERIFY_DELETE
		(
			DELETE_ITEM_DESCRIPTION,
			function(VERIFY_RESULT) 
			{
				// Abort if rejected by user.
				// ...........................................
				if(VERIFY_RESULT != JSOC_DIALOG.MSGBOX_YES)
				{

					CALLBACK_METHOD(false);
					return;
				}
				
				
				//Delete Item
				// ...........................................
				JSOC_DIALOG.VAR_LOADING_SPINNER(true);
				JSCUS_SQL._ACCOUNT._BFIP.CUS_DELETE
				(
					BFIP_DGV.CELL.VALUE('ACC_BFIP_ID', ROW_INDEX),
					RESPONSE_HANDLER
				)
			}
		);
	}
	
	
	// ===============================================================
	// Request Void
	// ===============================================================
	function HTTP_VOID(CALLBACK_METHOD, ROW_INDEX)
	{
		
		// Escape if Disabled
		// _______________________________________________________________________
		if
		(
			JSVC_VAR.VAR_ISSET(BFIP_DGV.CELL.ELEMENT('ACC_BFIP_STATUS', ROW_INDEX)) && 
			BFIP_DGV.CELL.ELEMENT('ACC_BFIP_STATUS', ROW_INDEX).Enabled == false
		)
		{
			CALLBACK_METHOD(false);
			return;
		}

		// Escape if nothing selected
		// _______________________________________________________________________
		if(ROW_INDEX < 0)
		{
			JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_NOTHING_SELECTED(true);
			CALLBACK_METHOD(false);
			return;
		}
		
		// Abort if already Voided (Status = 3)
		// _______________________________________________________________________
		if(BFIP_DGV.CELL.VALUE('ACC_BFIP_STATUS', ROW_INDEX) == 3)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'This item is already Voided', 
				'Information',
				'OK', 'INFO',
				null
			);		
			return;
		}		
		
		// Notify User to Void	
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_MESSAGE_BOX
		(
			'Do you want to void the selected item?', 
			'Information',
			'YESNO', 'QUESTION',
			function(VERIFY_RESULT)
			{
				if(VERIFY_RESULT == JSOC_DIALOG.MSGBOX_YES)
				{
					PROPERTY_REC_VOUCHER_ID = BFIP_DGV.CELL.VALUE('4285', ROW_INDEX);
					PROPERTY_EDIT_ROW_INDEX = ROW_INDEX;
					HTTP_LOAD
					(
						function()
						{
							JSOC_CMB.VAR_SELECTED_VALUE(ACC_BFIP_STATUS_CMB, 3);
							JSOC_DIALOG.VAR_MODAL("BFIP_MODAL", true);
							EDIT_HANDLER.REF_IS_MODIFIED = true;				
						}
					);
				}
			}
		);
		
	}