	// ===============================================================
	// 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 = "";
	
	
	// Cache
	// _______________________________________________________________________
	var PROPERTY_REC_INVAUDIT_ID = -1;
	var PROPERTY_REC_STORAGE_ID = -1;
	var PROPERTY_REC_BRANCH_PRODUCTS = [];
	
	var PROPERTY_EDIT_MODE = false;
	var PROPERTY_EDIT_ROW_INDEX = -1;
	var INPUT_INSTANCE = null;
	
	
	// Buttons [Optional]
	// _______________________________________________________________________
	var ADD_BBI = null;
	var SEARCH_BBI = null;
	var SAVE_BBI = null;
	
	
	// Dialog Controls [Optional]
	// _______________________________________________________________________
	var REC_INVAUDIT_ACC_GROUP_ID_CMB = null;
	var REC_INVAUDIT_CAT_STORAGE_ID_CMB = null;
	var REC_INVAUDIT_STATUS_CMB = null;
	var CAT_STORAGE_CMB = null;
	var PARAM_REC_INVAUDIT_ID_FILE_FP = null;
	
	
	// DGV Controls
	// _______________________________________________________________________
	var INVAUDIT_DGV = null;
	var INVENTORY_AUDIT_LINE_DGV = null;
	var JSON_ACCOUNT_GROUP = null;


	// ===============================================================
	// Initialize Controls
	// ===============================================================     
	function FORM_INITIALIZE()
	{
		// Load Cache Parent Data [Add Redirects if this is a required data.]
		// ...........................................
		if(JSVC_COOKIE.VAR_ISSET("PROPERTY_PARENT_ID_INVAUDIT"))
		{
			PROPERTY_PARENT_ID = JSVC_COOKIE.VAR_READ("PROPERTY_PARENT_ID_INVAUDIT");
		}	
		else
		{
			//window.location = JSCUS_CACHE.AUTH_REDIRECT_URL[JSCUS_CACHE.LOGIN_CLASS];
			//window.close();
		}
		if(JSVC_COOKIE.VAR_ISSET("PROPERTY_PARENT_DESCRIPTION_INVAUDIT"))
		{
			PROPERTY_PARENT_DESCRIPTION = JSVC_COOKIE.VAR_READ("PROPERTY_PARENT_DESCRIPTION_INVAUDIT");
			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PAGE_PARENT_DESCRIPTION_TXT") == true)
			{
				JSOC_ELEMENT.VAR_VALUE("PAGE_PARENT_DESCRIPTION_TXT", PROPERTY_PARENT_DESCRIPTION);			
			}
			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PAGE_PARENT_DESCRIPTION_LBL") == true)
			{
				JSOC_ELEMENT.VAR_VALUE("PAGE_PARENT_DESCRIPTION_LBL", PROPERTY_PARENT_DESCRIPTION);			
			}
			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PAGE_TITLE_LBL") == true)
			{
				JSOC_ELEMENT.VAR_VALUE("PAGE_TITLE_LBL", JSOC_ELEMENT.VAR_VALUE("PAGE_TITLE_LBL") + " : " + PROPERTY_PARENT_DESCRIPTION);	
			}
		}	
		else
		{
			//window.location = JSCUS_CACHE.AUTH_REDIRECT_URL[JSCUS_CACHE.LOGIN_CLASS];	
		}
	
		// Restore Cache on reload
		// ...........................................	
		if
		(
			JSVC_COOKIE.VAR_ISSET("PROPERTY_PARENT_ID_INVAUDIT") || 
			JSVC_COOKIE.VAR_ISSET("PROPERTY_PARENT_DESCRIPTION_INVAUDIT")
		)
		{
			  window.onbeforeunload = function(event)
			  {
					// Get Current Root path
					var CURRENT_ROOT_PATH = JSCUS_CACHE.ROOT_PATH + JSVC_STR.VAR_MID(JSVC_STR.VAR_DLEFT(JSCUS_CACHE.AUTH_REDIRECT_URL[JSCUS_CACHE.LOGIN_CLASS], JSCUS_CACHE.SERVER_URL.length), 1, 1);
				
					// Cache Primary Key
					JSVC_COOKIE.VAR_ADD
					(
						'PROPERTY_PARENT_ID_INVAUDIT', 
						PROPERTY_PARENT_ID, 
						5, 
						CURRENT_ROOT_PATH
					);
					
					// Cache Description
					JSVC_COOKIE.VAR_ADD
					(
						'PROPERTY_PARENT_DESCRIPTION_INVAUDIT', 
						PROPERTY_PARENT_DESCRIPTION, 
						5, 
						CURRENT_ROOT_PATH
					);
			  };
		}
		
 		// Cache Class Properties
		// ...........................................
		if(JSVC_COOKIE.VAR_ISSET("PROPERTY_REC_INVAUDIT_ID"))
		{
			PROPERTY_REC_INVAUDIT_ID = JSVC_COOKIE.VAR_READ("PROPERTY_REC_INVAUDIT_ID");
		}	
		if(JSVC_COOKIE.VAR_ISSET("PROPERTY_EDIT_MODE"))
		{
			PROPERTY_EDIT_MODE = JSVC_COOKIE.VAR_READ("PROPERTY_REC_INVAUDIT_ID");
		}
	
		// Initialize: Modals
		// ...........................................
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("INVAUDIT_MODAL") == true)
		{
			// Display Modal
			JSOC_DIALOG.VAR_MODAL("INVAUDIT_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("INVAUDIT_MODAL"))
			{
				ADD_BBI.onclick = 
					function()
					{	
							// Display Modal
							PROPERTY_REC_INVAUDIT_ID = FLAG_BIGINT_NULL;
							PROPERTY_EDIT_ROW_INDEX = -1;
							
							if(JSVC_VAR.VAR_ISSET(INPUT_INSTANCE))
							{
								JSOC_WINDOW.VAR_INPUT_INSTANCE_RESTORE(INPUT_INSTANCE);
							}
							EDIT_HANDLER.REF_IS_MODIFIED = false;

							if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SAVE_BBI"))
							{
								JSOC_ELEMENT.VAR_GET("SAVE_BBI").style.visibility = "";
							}
							if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_INVAUDIT_ACC_GROUP_ID_DLG_BLOCK"))
							{
								JSOC_ELEMENT.VAR_GET("REC_INVAUDIT_ACC_GROUP_ID_DLG_BLOCK").style.display = "";
							}
							if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_INVAUDIT_ACC_GROUP_ID_LBL"))
							{
								JSOC_ELEMENT.VAR_GET("REC_INVAUDIT_ACC_GROUP_ID_LBL").style.display = "none";
							}		
												
							if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("CAT_STORAGE_CMB_BLOCK"))
							{
								JSOC_ELEMENT.VAR_GET("CAT_STORAGE_CMB_BLOCK").style.display = "";
							}
							if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("AT_STORAGE_LBL"))
							{
								JSOC_ELEMENT.VAR_GET("AT_STORAGE_LBL").style.display = "none";
							}								
						
							JSOC_ELEMENT.VAR_VALUE("MODAL_TITLE_MM", "New ");
							JSOC_DIALOG.VAR_MODAL("INVAUDIT_MODAL", true);
							INVENTORY_AUDIT_LINE_DGV.ROW.CLEAR();
							
					}		
			}
			// Add OnClick event [Show Add/Edit Page]
			else
			{
				
			}
		}	
		
		// 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_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()
					{
						HTTP_SAVE(CALLBACK_HANDLER);
					}
			}
		}


		// Initialize: Ribbon Buttons [Search Changes]
		// ...........................................
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_BBI"))
		{
    		SEARCH_BBI = JSOC_ELEMENT.VAR_GET("SEARCH_BBI");     
			SEARCH_BBI.onclick = function()
			{
				if(JSVC_VAR.VAR_ISSET(HTTP_SEARCH))
				{
					// Add OnClick event
					HTTP_SEARCH();
				}
			};
		}		
		
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("CANCEL_BBI"))
		{
    		CANCEL_BBI = JSOC_ELEMENT.VAR_GET("CANCEL_BBI");      		
		}
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_INVAUDIT_ACC_GROUP_ID_CMB"))
		{
    		REC_INVAUDIT_ACC_GROUP_ID_CMB = JSOC_ELEMENT.VAR_GET("REC_INVAUDIT_ACC_GROUP_ID_CMB");    
			REC_INVAUDIT_ACC_GROUP_ID_CMB.onchange = function()
			{
				if(REC_INVAUDIT_ACC_GROUP_ID_CMB.disabled == false)
				{
					if(0 > JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_INVAUDIT_ACC_GROUP_ID_CMB)))
					{
						return;
					}
					/*
					var GROUP_ID = JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_INVAUDIT_ACC_GROUP_ID_CMB));
					
					HTTP_BRANCH_PRODUCTS(GROUP_ID);
					HTTP_NEW_LOAD
					(
						GROUP_ID, 
						function(){}
					);
					*/
					HTTP_STORAGE();				
				}
			};	
		}		
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("CAT_STORAGE_CMB"))
		{
			CAT_STORAGE_CMB = JSOC_ELEMENT.VAR_GET("CAT_STORAGE_CMB");
			CAT_STORAGE_CMB.onchange = function()
			{
				if(CAT_STORAGE_CMB.disabled == false)
				{
					if(0 > JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(CAT_STORAGE_CMB)))
					{

						return;
					}
					
					var GROUP_ID = JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_INVAUDIT_ACC_GROUP_ID_CMB));
					var STORAGE_ID = JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(CAT_STORAGE_CMB));

					console.log(GROUP_ID);
					console.log(STORAGE_ID);
					
					HTTP_BRANCH_PRODUCTS(GROUP_ID, STORAGE_ID);
					// HTTP_NEW_LOAD
					// (
					// 	GROUP_ID, 
					// 	STORAGE_ID,
					// 	function(){}
					// );		
				}
			};	 
		}
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_INVAUDIT_DATE_AUDIT_FROM_DTP"))
		{
			JSOC_ELEMENT.VAR_VALUE
			(
				"SEARCH_REC_INVAUDIT_DATE_AUDIT_FROM_DTP", 
				JSVC_DATE.VAR_BEGIN_OF_DAY
				(
					JSVC_DATE.VAR_ADD('DAY', -7, JSVC_DATE.VAR_NOW())
				)
			);
		}		
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_INVAUDIT_DATE_AUDIT_TO_DTP"))
		{
			JSOC_ELEMENT.VAR_VALUE
			(
				"SEARCH_REC_INVAUDIT_DATE_AUDIT_TO_DTP", 
				JSVC_DATE.VAR_BEGIN_OF_DAY
				(	
					JSVC_DATE.VAR_NOW()
				)
			);
		}			
	}