	
	// ===============================================================
	// Global Var
	// ===============================================================
	
	// Edit Handler
	// _______________________________________________________________________
	var EDIT_HANDLER = function(){};	
	EDIT_HANDLER.REF_IS_MODIFIED = false;
	EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = false;
	var PROPERTY_PARENT_ID = 0;
	var PROPERTY_PARENT_DESCRIPTION = "";
	var PROPERTY_PARENT_JOLINE = 0;
	
	// Cache
	// _______________________________________________________________________
	var PROPERTY_REC_POSRESERVE_ID = -1;
	var PROPERTY_REC_POSRESERVE_CODE = -1;
	var PROPERTY_EDIT_MODE = false;
	var PROPERTY_EDIT_ROW_INDEX = -1;
	var INPUT_INSTANCE = null;
	var INPUT_INSTANCE2 = null;
	
	// Holder
	// _______________________________________________________________________
	var TOTAL_AMOUNT = 0;
	var PROPERTY_REC_STORAGE_ID = 0;
	var JO_HOLDER = "";
	var JO_LINE_HOLDER = "";
	var RES_HOLDER = "";
	var RES_LINE_HOLDER = "";
	var PROD_HOLDER = "";
	var CUS_HOLDER = "";

	var BRANCH_HOLDER = "";
	
	// Buttons [Optional]
	// _______________________________________________________________________
	var APPROVE_FLAG = 0;
	var APPROVE_BBI = null;
	var ADD_BBI = null;
	var SAVE_BBI = null;
	var DELIVERED_BBI = null;
	var GROSSCALL_BBI = null;
	var ADD_PRODUCT = null;
	var PROCESSING_BBI = null;
	var CUSTOMER_BBI = null;
	var CUSTOMER_SAVE_BBI = null;

	var SEARCH_CMD = null;
	// var PRINT_BBI = null;
	// var EXPORT_BBI = null;

	var IS_PROCESSING = 0;
	
	// Dialog Controls [Optional]
	// _______________________________________________________________________
	var REC_POSRESERVE_ACC_GROUP_ID_CMB = null;
	var REC_POSRESERVE_REC_CLIENT_ID_CMB = null;
	var REC_POSRESERVE_REFERENCE_CODE_TXT = null;
	var REC_POSRESERVE_DATE_EXPECTED_DTP = null;
	var REC_POSRESERVE_REMARKS_TXT = null;
	var REC_POSRESERVE_STATUS_CMB = null;
	var PARAM_REC_POSRESERVE_ID_FILE_FP = null;
	
	// DGV Controls
	// _______________________________________________________________________
	var POS_RESERVE_DGV = null;
	var JOB_ORDER_DGV = null;
	var JOB_ORDER_TASK_DELIVER_DGV = null;
	var JOB_ORDER_TASK_RETURN_DGV = null;

	var IS_APPROVE = 0;
	var IS_JO_STATUS = 0;


	// ===============================================================
	// Initialize Controls
	// ===============================================================     
	function FORM_INITIALIZE()
	{
		// Initialize: Modals
		// ...........................................
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_MODAL") == true)
		{
			// Display Modal
			JSOC_DIALOG.VAR_MODAL("POS_RESERVE_MODAL", false);
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_NEW_MODAL") == true)
		{
			// Display Modal
			JSOC_DIALOG.VAR_MODAL("POS_RESERVE_NEW_MODAL", false);
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("CUSTOMER_MODAL") == true)
		{
			// Display Modal
			JSOC_DIALOG.VAR_MODAL("CUSTOMER_MODAL", false);
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("JOB_ORDER_MODAL") == true)
		{
			// Display Modal
			JSOC_DIALOG.VAR_MODAL("JOB_ORDER_MODAL", false);
		}
		
		// Initialize: Ribbon Buttons [Add Item]
		// ...........................................
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("ADD_BBI"))
		{
  		ADD_BBI = JSOC_ELEMENT.VAR_GET("ADD_BBI");     	
			
			// Add OnClick event [Show Modal]
			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("POS_RESERVE_NEW_MODAL"))
			{
				ADD_BBI.onclick = 
					function()
					{		
						// Display Modal
						PROPERTY_REC_POSRESERVE_ID = FLAG_BIGINT_NULL;
						PROPERTY_EDIT_ROW_INDEX = -1;
						
						if(JSVC_VAR.VAR_ISSET(INPUT_INSTANCE2))
						{
							JSOC_WINDOW.VAR_INPUT_INSTANCE_RESTORE(INPUT_INSTANCE2);
						}
						EDIT_HANDLER.REF_IS_MODIFIED = true;

						//JSOC_CMB.VAR_SELECTED_VALUE("REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB", "");
						JSOC_CMB.VAR_SELECTED_INDEX("REC_POSRESERVE_BRANCH_PRODUCT_ID_CMB", 9999);

						if(PRODUCT_BRANCH_DGV.ROW.COUNT() > 0)
							PRODUCT_BRANCH_DGV.ROW.CLEAR();

						JSOC_DIALOG.VAR_MODAL("POS_RESERVE_NEW_MODAL", true);
					}		
			}
			// Add OnClick event [Show Add/Edit Page]
			else
			{
				
			}
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("CUSTOMER_BBI"))
		{
  		CUSTOMER_BBI = JSOC_ELEMENT.VAR_GET("CUSTOMER_BBI");     	
			
			// Add OnClick event [Show Modal]
			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("CUSTOMER_MODAL"))
			{
				CUSTOMER_BBI.onclick = 
					function()
					{		
						JSOC_DIALOG.VAR_MODAL("CUSTOMER_MODAL", true);
					}		
			}
			// Add OnClick event [Show Add/Edit Page]
			else
			{
				
			}
		}
		
		// Initialize: Ribbon Buttons [Save Changes]
		// ...........................................
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("APPROVE_BBI"))
		{
    		APPROVE_BBI = JSOC_ELEMENT.VAR_GET("APPROVE_BBI");     
			if(JSVC_VAR.VAR_ISSET(HTTP_RESERVE_SAVE))
			{
				// Prepare Save callback
				var CALLBACK_HANDLER = 
					function(IS_SUCCESS)
					{
						// Abort on failure
						if(IS_SUCCESS == false)
						{
							return;
						}
					
						// Show record saved messageBox
						JSVC_INFO.VAR_RECORD_SAVED('');
					}
				
				// Add OnClick event
				APPROVE_BBI.onclick = 
					function()
					{
						IS_APPROVE = 1;
						IS_JO_STATUS = 2;
						IS_PROCESSING = 0;
						//HTTP_SAVE(CALLBACK_HANDLER);
						HTTP_RESERVE_SAVE(CALLBACK_HANDLER);
					}
			}
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PROCESSING_BBI"))
		{
    		PROCESSING_BBI = JSOC_ELEMENT.VAR_GET("PROCESSING_BBI");     
			if(JSVC_VAR.VAR_ISSET(HTTP_RESERVE_SAVE))
			{
				// Prepare Save callback
				var CALLBACK_HANDLER = 
					function(IS_SUCCESS)
					{
						// Abort on failure
						if(IS_SUCCESS == false)
						{
							return;
						}
					
						// Show record saved messageBox
						JSVC_INFO.VAR_RECORD_SAVED('');
						SAMPLE_QUICK_SAVE2();
					}
				
				// Add OnClick event
				PROCESSING_BBI.onclick = 
					function()
					{
						IS_APPROVE = 1;
						IS_JO_STATUS = 2;
						IS_PROCESSING = 1;
						//HTTP_SAVE(CALLBACK_HANDLER);
						HTTP_RESERVE_SAVE(CALLBACK_HANDLER);
					}
			}
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("CUSTOMER_SAVE_BBI"))
		{
    		CUSTOMER_SAVE_BBI = JSOC_ELEMENT.VAR_GET("CUSTOMER_SAVE_BBI");     
			if(JSVC_VAR.VAR_ISSET(HTTP_CUSTOMER_SAVE))
			{
				// Prepare Save callback
				var CALLBACK_HANDLER = 
					function(IS_SUCCESS)
					{
						// Abort on failure
						if(IS_SUCCESS == false)
						{
							return;
						}
					
						// Show record saved messageBox
						JSVC_INFO.VAR_RECORD_SAVED('');
					};
				
				// Add OnClick event
				CUSTOMER_SAVE_BBI.onclick = 
					function()
					{
						HTTP_CUSTOMER_SAVE(CALLBACK_HANDLER);
					};
			}
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("DELIVERED_BBI"))
		{
    		DELIVERED_BBI = JSOC_ELEMENT.VAR_GET("DELIVERED_BBI");     
			if(JSVC_VAR.VAR_ISSET(HTTP_RESERVE_SAVE))
			{
				// Prepare Save callback
				var CALLBACK_HANDLER = 
					function(IS_SUCCESS)
					{
						// Abort on failure
						if(IS_SUCCESS == false)
						{
							return;
						}
					
						// Show record saved messageBox
						JSVC_INFO.VAR_RECORD_SAVED('');
					}
				
				// Add OnClick event
				DELIVERED_BBI.onclick = 
					function()
					{
						IS_APPROVE = 1;
						IS_JO_STATUS = 4;
						IS_PROCESSING = 0;
						//HTTP_SAVE(CALLBACK_HANDLER);
						HTTP_RESERVE_SAVE(CALLBACK_HANDLER);
					}
			}
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("ADD_PRODUCT"))
		{
			ADD_PRODUCT = JSOC_ELEMENT.VAR_GET("ADD_PRODUCT");
			ADD_PRODUCT.onclick = function(){HTTP_ADD_PRODUCT()};
		}

		// Initialize: Ribbon Buttons [Save Changes]
		// ...........................................
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SAVE_BBI"))
		{
    		SAVE_BBI = JSOC_ELEMENT.VAR_GET("SAVE_BBI");     
			if(JSVC_VAR.VAR_ISSET(HTTP_RESERVE_SAVE))
			{
				// Prepare Save callback
				var CALLBACK_HANDLER = 
					function(IS_SUCCESS)
					{
						// Abort on failure
						if(IS_SUCCESS == false)
						{
							return;
						}
					
						// Show record saved messageBox
						JSVC_INFO.VAR_RECORD_SAVED('');
					}
				
				// Add OnClick event
				SAVE_BBI.onclick = 
					function()
					{
						IS_APPROVE = 0;
						IS_JO_STATUS = 0;
						HTTP_RESERVE_SAVE(CALLBACK_HANDLER);
					}
			}
		}

		// Initialize: Ribbon Buttons [Save Changes]
		// ...........................................
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("GROSSCALL_BBI"))
		{
    		GROSSCALL_BBI = JSOC_ELEMENT.VAR_GET("GROSSCALL_BBI");     
			if(JSVC_VAR.VAR_ISSET(HTTP_GROSS_CALL))
			{
				// Prepare Save callback
				var CALLBACK_HANDLER = 
					function(IS_SUCCESS)
					{
						// Abort on failure
						if(IS_SUCCESS == false)
						{
							return;
						}
					
						// Show record saved messageBox
						JSVC_INFO.VAR_RECORD_SAVED('');
					}
				
				// Add OnClick event
				GROSSCALL_BBI.onclick = 
					function()
					{
						HTTP_GROSS_CALL(CALLBACK_HANDLER);
					}
			}
		}

		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_REC_CLIENT_ID_CMB"))
		{
			REC_POSRESERVE_REC_CLIENT_ID_CMB = JSOC_ELEMENT.VAR_GET("REC_POSRESERVE_REC_CLIENT_ID_CMB");      	
			REC_POSRESERVE_REC_CLIENT_ID_CMB.onchange = 
				function()
				{
					if(REC_POSRESERVE_REC_CLIENT_ID_CMB.disabled == false)
					{
						EDIT_HANDLER.REF_IS_MODIFIED = true;
					}
				};
			REC_POSRESERVE_REC_CLIENT_ID_CMB.onkeypress = function(){REC_POSRESERVE_REC_CLIENT_ID_CMB.onchange();};
			REC_POSRESERVE_REC_CLIENT_ID_CMB.onpaste = function(){REC_POSRESERVE_REC_CLIENT_ID_CMB.onchange();};
			//REC_POSRESERVE_REC_CLIENT_ID_CMB.oninput = function(){REC_POSRESERVE_REC_CLIENT_ID_CMB.onchange();};							
		}
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_REFERENCE_CODE_TXT"))
		{
			REC_POSRESERVE_REFERENCE_CODE_TXT = JSOC_ELEMENT.VAR_GET("REC_POSRESERVE_REFERENCE_CODE_TXT");      
			REC_POSRESERVE_REFERENCE_CODE_TXT.onchange = 
				function()
				{
					if(REC_POSRESERVE_REFERENCE_CODE_TXT.disabled == false)
					{
						EDIT_HANDLER.REF_IS_MODIFIED = true;
					}
				};
			REC_POSRESERVE_REFERENCE_CODE_TXT.onkeypress = function(){REC_POSRESERVE_REFERENCE_CODE_TXT.onchange();};
			REC_POSRESERVE_REFERENCE_CODE_TXT.onpaste = function(){REC_POSRESERVE_REFERENCE_CODE_TXT.onchange();};
			//REC_POSRESERVE_REFERENCE_CODE_TXT.oninput = function(){REC_POSRESERVE_REFERENCE_CODE_TXT.onchange();};
		}
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_DATE_EXPECTED_DTP"))
		{
			REC_POSRESERVE_DATE_EXPECTED_DTP = JSOC_ELEMENT.VAR_GET("REC_POSRESERVE_DATE_EXPECTED_DTP");   
			JSOC_ELEMENT.VAR_VALUE(REC_POSRESERVE_DATE_EXPECTED_DTP, JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD" + "T00:00"));
			REC_POSRESERVE_DATE_EXPECTED_DTP.onchange = 
				function()
				{
					if(REC_POSRESERVE_DATE_EXPECTED_DTP.disabled == false)
					{
						EDIT_HANDLER.REF_IS_MODIFIED = true;
					}
				};
			REC_POSRESERVE_DATE_EXPECTED_DTP.onkeypress = function(){REC_POSRESERVE_DATE_EXPECTED_DTP.onchange();};
			REC_POSRESERVE_DATE_EXPECTED_DTP.onpaste = function(){REC_POSRESERVE_DATE_EXPECTED_DTP.onchange();};
			REC_POSRESERVE_DATE_EXPECTED_DTP.oninput = function(){REC_POSRESERVE_DATE_EXPECTED_DTP.onchange();};					
		}
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_POSRESERVE_REMARKS_TXT"))
		{
			REC_POSRESERVE_REMARKS_TXT = JSOC_ELEMENT.VAR_GET("REC_POSRESERVE_REMARKS_TXT");      
			REC_POSRESERVE_REMARKS_TXT.onchange = 
				function()
				{
					if(REC_POSRESERVE_REMARKS_TXT.disabled == false)
					{
						EDIT_HANDLER.REF_IS_MODIFIED = true;
					}
				};
			REC_POSRESERVE_REMARKS_TXT.onkeypress = function(){REC_POSRESERVE_REMARKS_TXT.onchange();};
			REC_POSRESERVE_REMARKS_TXT.onpaste = function(){REC_POSRESERVE_REMARKS_TXT.onchange();};
			//REC_POSRESERVE_REMARKS_TXT.oninput = function(){REC_POSRESERVE_REMARKS_TXT.onchange();};
		}
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_CLIENT_DATE_ISSUED_DTP"))
		{
			JSOC_ELEMENT.VAR_VALUE("SEARCH_REC_CLIENT_DATE_ISSUED_DTP", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD") + "T00:00");
		}
	};