// CATEGORY_ADDRESS_COUNTRY GET
JSCUS_SQL.ACCOUNT_MEMBER = function(){};

	/** 
	 * SP_GET Cache of ParameterSet (Array) 
	 */
	JSCUS_SQL.ACCOUNT_MEMBER["PROPERTY_CACHED_QUERY"] = null;

	
	/** 
	 * =======================================================================================================
	 * Perform SQL GET request to the table ACCOUNT_MEMBER. Returns DataSet.
	 *
	 * @param VAR_PARAMETER_ARRAY String() Array with Request ParameterSet.
	 * @param CALLBACK_ADDRESS(bool, String) A callback method when the server response is received.
	 *
	 * @param SQL_KEEP_PARAMETER_TO_CACHE bool (Optional) If TRUE save to cache, for easier paging request.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET = function
	(
		VAR_PARAMETER_ARRAY,
		CALLBACK_ADDRESS,
		
		SQL_KEEP_PARAMETER_TO_CACHE
	)
	{
		// Parameter Validation
		// _______________________________________________________________________
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(VAR_PARAMETER_ARRAY, 'VAR_PARAMETER_ARRAY', 'ARRAY');
		
		// Handle Optionals
		// _______________________________________________________________________		
		SQL_KEEP_PARAMETER_TO_CACHE = JSVC_VAR.VAR_OPTIONAL(SQL_KEEP_PARAMETER_TO_CACHE, false);
		
		// Process SQL Request
		// _______________________________________________________________________
		var PARAM_SET = "";			
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_ID', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_ID"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_SERVER_ID', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_SERVER_ID"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_LEVEL_ID', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_LEVEL_ID"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_GROUP_ID', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_GROUP_ID"]);
		
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_USERNAME', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_USERNAME"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_NAME', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_NAME"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_FIRST_NAME', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_FIRST_NAME"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_MIDDLE_NAME', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_MIDDLE_NAME"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_LAST_NAME', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_LAST_NAME"]);

		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_GENDER_ID', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_GENDER_ID"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_POSITION', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_POSITION"]);
		
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_STATUS', VAR_PARAMETER_ARRAY["PARAM_ACCOUNT_STATUS"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_SYSTEM_GENERATED', VAR_PARAMETER_ARRAY["PARAM_SYSTEM_GENERATED"]);
		
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ORDER_FIELD', VAR_PARAMETER_ARRAY["PARAM_ORDER_FIELD"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ORDER_TYPE', VAR_PARAMETER_ARRAY["PARAM_ORDER_TYPE"]);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_SKIP', VAR_PARAMETER_ARRAY["PARAM_LIMIT"]);
				
		// Copy Parameter To Cache
		// _______________________________________________________________________
		if(SQL_KEEP_PARAMETER_TO_CACHE == true)
		{
			JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY = PARAM_SET;
		}
							
		// Send SQL Request
		// _______________________________________________________________________					
		CUS_SEND_REQUEST
		(
			CALLBACK_ADDRESS,
			'<!--[#SITE_URL;]-->/Account/member/get',
			'<!--[#SITE_URL;]-->/System/nonce/get',
			PARAM_SET
		);	
	}
	
	/** 
	 * =======================================================================================================
	 * Populate SP-GET request request parameters with default value.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET = function()
	{
		// Initialize
		var RESULT_MAPARRAY = [];

		// Populate default fields
		RESULT_MAPARRAY["PARAM_ACCOUNT_ID"] = FLAG_BIGINT_NULL;
		RESULT_MAPARRAY["PARAM_ACCOUNT_SERVER_ID"] = FLAG_BIGINT_NULL;
		RESULT_MAPARRAY["PARAM_ACCOUNT_LEVEL_ID"] = FLAG_BIGINT_NULL;
		RESULT_MAPARRAY["PARAM_ACCOUNT_GROUP_ID"] = FLAG_BIGINT_NULL;
		
		RESULT_MAPARRAY["PARAM_ACCOUNT_USERNAME"] = FLAG_NVARCHAR_NULL;
		RESULT_MAPARRAY["PARAM_ACCOUNT_NAME"] = FLAG_NVARCHAR_NULL;
		RESULT_MAPARRAY["PARAM_ACCOUNT_FIRST_NAME"] = FLAG_NVARCHAR_NULL;
		RESULT_MAPARRAY["PARAM_ACCOUNT_MIDDLE_NAME"] = FLAG_NVARCHAR_NULL;
		RESULT_MAPARRAY["PARAM_ACCOUNT_LAST_NAME"] = FLAG_NVARCHAR_NULL;
		
		RESULT_MAPARRAY["PARAM_ACCOUNT_GENDER_ID"] = FLAG_BIGINT_NULL;
		RESULT_MAPARRAY["PARAM_ACCOUNT_POSITION"] = FLAG_NVARCHAR_NULL;
		
		RESULT_MAPARRAY["PARAM_ACCOUNT_STATUS"] = FLAG_TINYINT_NULL;
		RESULT_MAPARRAY["PARAM_SYSTEM_GENERATED"] = FLAG_TINYINT_NULL;
			
		// Paging Parameters
		RESULT_MAPARRAY["PARAM_ORDER_FIELD"] = "ACCOUNT_FIRST_NAME";
		RESULT_MAPARRAY["PARAM_ORDER_TYPE"] = "ASC";
		RESULT_MAPARRAY["PARAM_SKIP"] = 0;
		RESULT_MAPARRAY["PARAM_LIMIT"] = 300;

		// Return prepared MapArray
		return RESULT_MAPARRAY;
	}
	
	/** 
	 * =======================================================================================================
	 * Perform SQL LOGIN request to the table ACCOUNT_MEMBER. Returns DataSet.
	 *
	 * @param CALLBACK_ADDRESS(bool, String) A callback method when the server response is received.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_LOGIN = function
	(
		PARAM_ACCOUNT_USERNAME,
		PARAM_ACCOUNT_PASSWORD,
		CALLBACK_ADDRESS
	)
	{
		// Process SQL Request
		// _______________________________________________________________________
		var PARAM_SET = "";			
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_USERNAME', PARAM_ACCOUNT_USERNAME);
		PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_ACCOUNT_PASSWORD', PARAM_ACCOUNT_PASSWORD);
							
		// Send SQL Request
		// _______________________________________________________________________					
		CUS_SEND_REQUEST
		(
			CALLBACK_ADDRESS,
			'<!--[#SITE_URL;]-->/Account/member/login',
			'<!--[#SITE_URL;]-->/System/nonce/get',
			PARAM_SET
		);	
	}
	
	/** 
	 * =======================================================================================================
	 * Perform SQL LOGOUT request to the table ACCOUNT_MEMBER. Returns DataSet.
	 *
	 * @param VAR_PARAMETER_ARRAY String() Array with Request ParameterSet.
	 * @param CALLBACK_ADDRESS(bool, String) A callback method when the server response is received.
	 *
	 * @param SQL_KEEP_PARAMETER_TO_CACHE bool (Optional) If TRUE save to cache, for easier paging request.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_LOGOUT = function
	(
		CALLBACK_ADDRESS
	)
	{
		// Process SQL Request
		// _______________________________________________________________________
		var PARAM_SET = "";			
							
		// Send SQL Request
		// _______________________________________________________________________					
		CUS_SEND_REQUEST
		(
			CALLBACK_ADDRESS,
			'<!--[#SITE_URL;]-->/Account/member/logout',
			'<!--[#SITE_URL;]-->/System/nonce/get',
			PARAM_SET
		);	
	}
	
	/** 
	 * =======================================================================================================
	 * Perform SQL LOGOUT request to the table ACCOUNT_MEMBER. Returns DataSet.
	 *
	 * @param VAR_PARAMETER_ARRAY String() Array with Request ParameterSet.
	 * @param CALLBACK_ADDRESS(bool, String) A callback method when the server response is received.
	 *
	 * @param SQL_KEEP_PARAMETER_TO_CACHE bool (Optional) If TRUE save to cache, for easier paging request.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_ME = function
	(
		CALLBACK_ADDRESS
	)
	{
		// Process SQL Request
		// _______________________________________________________________________
		var PARAM_SET = "";			
							
		// Send SQL Request
		// _______________________________________________________________________					
		CUS_SEND_REQUEST
		(
			CALLBACK_ADDRESS,
			'<!--[#SITE_URL;]-->/Account/member/me',
			'<!--[#SITE_URL;]-->/System/nonce/get',
			PARAM_SET
		);	
	}
	
	
	/** 
	 * =======================================================================================================
	 * Reload current page in query, stored at SQL cache.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_CACHE = function
	(
		CALLBACK_ADDRESS
	)
	{
		JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET
		(
				JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY,
			CALLBACK_ADDRESS
		);
	}
				
	/** 
	 * =======================================================================================================
	 * Load First page in query, stored at SQL cache.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_CACHE_MOVE_FIRST = function
	(
		CALLBACK_ADDRESS
	)
	{
		// Adjust Paging
		// ...........................................
		JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY["PARAM_SKIP"] = 0;

		// Return ParameterSet
		// ...........................................
		JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_CACHE(CALLBACK_ADDRESS);
	}


	/**
     * =======================================================================================================
	 * <summary>Load Previous page in query, stored at SQL cache.</summary>
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_CACHE_MOVE_PREV = function
	(
		CALLBACK_ADDRESS
	)
	{
		// Initialize
		// ...........................................
		var PARAM_SKIP = JSVC_NUM.VAR_NVALL(JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY("PARAM_SKIP"));
		var PARAM_LIMIT = JSVC_NUM.VAR_NVALL(JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY("PARAM_LIMIT"));

		// Adjust Paging
		// ...........................................
		if(PARAM_SKIP > PARAM_LIMIT)
		{
			JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY["PARAM_SKIP"] = PARAM_SKIP - PARAM_LIMIT;
		}
		else
		{
			JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY["PARAM_SKIP"] = 0;
		}

		// Request Query
		// ...........................................
		if(JSVC_NUM.VAR_NVALL(PROPERTY_CACHED_QUERY.VAR_READ("PARAM_SKIP")) != PARAM_SKIP)
		{
			JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_CACHE(CALLBACK_ADDRESS);
			return true;
		}
		else
		{
			return false;	
		}		
	}


	/**
	 * =======================================================================================================
	 * Load Next page in query, stored at SQL cache.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_CACHE_MOVE_NEXT = function
	(
		CALLBACK_ADDRESS
	)
	{
		// Initialize
		// ...........................................
		var PARAM_SKIP = JSVC_NUM.VAR_NVALL(JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY("PARAM_SKIP"));
		var PARAM_LIMIT = JSVC_NUM.VAR_NVALL(JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY("PARAM_LIMIT"));

		// Adjust Paging
		// ...........................................
		JSCUS_SQL.ACCOUNT_MEMBER.PROPERTY_CACHED_QUERY["PARAM_SKIP"] = PARAM_SKIP + PARAM_LIMIT;

		// Request Query
		// ...........................................
		JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_CACHE(CALLBACK_ADDRESS);
	}
	
	// =======================================================================================================
	
	JSCUS_SQL.ACCOUNT_MEMBER["CUS_GET_THEN_POPULATE_EXECUTE_CACHE_CALLBACK_ADDRESS"] = [];
	JSCUS_SQL.ACCOUNT_MEMBER["CUS_GET_THEN_POPULATE_EXECUTE_CACHE_CONTROL_VAR"] = [];
	JSCUS_SQL.ACCOUNT_MEMBER["CUS_GET_THEN_POPULATE_EXECUTE_CACHE_KEEP_RECORD"] = [];
	JSCUS_SQL.ACCOUNT_MEMBER["CUS_GET_THEN_POPULATE_EXECUTE_CACHE_RECORD_STATUS"] = [];
	
	/**
	 * =======================================================================================================
	 * Perform SQL GET requests to the table ACCOUNT_MEMBER, and populate Form/ComboBox/DataGridViewComboBoxColumn with the request result.
	 * Form/ComboBox/DataGridViewComboBoxColumn to Populate.
	 *
	 * @param Method CALLBACK_ADDRESS A Method to be called on Completion.
	 * @param Control CONTROL_VAR A Control to Populate.
	 * @param Boolean KEEP_RECORD If TRUE keeps the current items when populating ComboBox/ListBox.
	 * @param Byte RECORD_STATUS For Filtering a status of retrieving query.
	 *
	 * @return JSON String used to populate the control. (At Callback Address)
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE = function
	(
		CALLBACK_ADDRESS,
		
		CONTROL_VAR, 
		KEEP_RECORD,
		RECORD_STATUS,
		
		PARAM_CAT_COUNTRY_ID 
	)
	{	
		// Parameter Validation
		// _______________________________________________________________________
		JSVC_AV.VAR_VALIDATE_NULL(CONTROL_VAR, "CONTROL_VAR")
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(KEEP_RECORD, 'KEEP_RECORD', 'BOOLEAN');
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(RECORD_STATUS, 'RECORD_STATUS', 'NUMERIC');
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(PARAM_CAT_COUNTRY_ID, 'PARAM_CAT_COUNTRY_ID', 'NUMERIC');
		
		// Handle Optionals
		// _______________________________________________________________________
		PARAM_CAT_COUNTRY_ID = JSVC_VAR.VAR_OPTIONAL(PARAM_CAT_COUNTRY_ID, FLAG_BIGINT_NULL);
		
		// Initialize
		// _______________________________________________________________________
		var MAPPED_ARRAY_PARAMS = JSCUS_SQL.ACCOUNT_MEMBER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET;
		MAPPED_ARRAY_PARAMS["PARAM_CAT_COUNTRY_ID"] = PARAM_CAT_COUNTRY_ID;
		MAPPED_ARRAY_PARAMS["PARAM_CAT_COUNTRY_STATUS"] = RECORD_STATUS;
	
		// Push to Cache
		// _______________________________________________________________________
		JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_CALLBACK_ADDRESS.push(CALLBACK_ADDRESS);
		JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_CONTROL_VAR.push(CONTROL_VAR);
		JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_KEEP_RECORD.push(KEEP_RECORD);
		JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_RECORD_STATUS.push(RECORD_STATUS);
	
		JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_PARAM_CAT_COUNTRY_ID.push(PARAM_CAT_COUNTRY_ID);
	
		// Request Query
		// _______________________________________________________________________
		JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_CACHE(CALLBACK_ADDRESS);
		
	}
	
	/**
	 * Continuation on CUS_GET_THEN_POPULATE_EXECUTE(). Handles response from server.
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_ON_RESPONSE = function
	(
		IS_SUCCESS, 
		RESPONSE_STRING
	)
	{
		// Request failure (connection)
		// ...........................................
		if(IS_SUCCESS != true)
		{
			return null;
		}

		// Request failure (server)
		// ...........................................
		
		
		// Initialize
		// ...........................................
		var CALLBACK_ADDRESS = JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_CALLBACK_ADDRESS.shift();
		
		var CONTROL_VAR = JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_CONTROL_VAR.shift(); 
		var KEEP_RECORD = JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_KEEP_RECORD.shift();
		var RECORD_STATUS = JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_RECORD_STATUS.shift();
		
		var PARAM_CAT_COUNTRY_ID = JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_EXECUTE_CACHE_PARAM_CAT_COUNTRY_ID.shift();
	
		// Populate ComboBox
		// ...........................................
		if(JSOC_ELEMENT.VAR_IS_SELECT(CONTROL_VAR))
		{
			JSOC_CMB.VAR_ADD_FROM_JSON
				(
					CONTROL_VAR, RESPONSE_STRING,
					"CAT_COUNTRY_ID",
					"CAT_COUNTRY_DESCRIPTION",
					KEEP_RECORD, true
				);		
			return RESPONSE_STRING;
		}
							
		// Populate Form
		// ...........................................
		if(JSOC_ELEMENT.VAR_IS_PANEL(CONTROL_VAR))
		{
			JSOC_WINDOW.VAR_POPULATE_FROM_QUERY(CONTROL_VAR, RESPONSE_STRING, ["2", "1"]);
		}
		
		// Return Result
		// ...........................................
		return RESPONSE_STRING;
	}

	/**
	 * =======================================================================================================
	 * Perform SQL GET requests to the table ACCOUNT_MEMBER, and populate Form with the request result. Should be called when the combobox.
	 * @param FORM_VAR ComboBox to Populate.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_FORM = function
	(
		FORM_VAR, 
		RECORD_STATUS,
		PARAM_CAT_COUNTRY_ID
	)
	{
		return CUS_GET_THEN_POPULATE_EXECUTE(FORM_VAR, false, RECORD_STATUS, PARAM_CAT_COUNTRY_ID);
	}
		
		
	
	/**
	 * =======================================================================================================
	 * Perform SQL GET requests to the table ACCOUNT_MEMBER, and populate ComboBox with the request result.
	 * @param COMBOBOX_VAR ComboBox to Populate.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_COMBOBOX = function 
	(
		COMBOBOX_VAR,
		KEEP_RECORD,
		RECORD_STATUS
	)
	{
		return CUS_GET_THEN_POPULATE_EXECUTE 
			(
				COMBOBOX_VAR,
				KEEP_RECORD,
				RECORD_STATUS
			);
	}
				
	/** 
	 * =======================================================================================================
	 * <summary>Perform SQL GET requests to the table ACCOUNT_MEMBER, and populate DataGridViewComboBoxColumn with the request result.</summary>
	 * <param name="COMBOBOX_VAR">DataGridViewComboBoxColumn to Populate.</param>
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_GET_THEN_POPULATE_DGV = function
	(
		COMBOBOX_VAR, 
		KEEP_RECORD,
		RECORD_STATUS
	)
	{
		return CUS_GET_THEN_POPULATE_EXECUTE
			(
				COMBOBOX_VAR, 
				KEEP_RECORD,
				RECORD_STATUS
			);		
	}
	// =======================================================================================================
	
	/** 
	 * =======================================================================================================
	 * Perform SQL SAVE request to the table ACCOUNT_MEMBER. Returns DataSet.
	 *
	 * @param VAR_PARAMETER_ARRAY Array with Request ParameterSet.
	 * @param CALLBACK_ADDRESS(bool, String) A callback method when the server response is received.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_SAVE = function
	(
		VAR_PARAMETER_ARRAY,
		CALLBACK_ADDRESS
	)
	{
		// Parameter Validation
		// _______________________________________________________________________
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(VAR_PARAMETER_ARRAY, 'VAR_PARAMETER_ARRAY', 'ARRAY');
		
		// Process SQL Request
		// _______________________________________________________________________
		var PARAM_SET = "";	
		var ARRAY_INDEX = 0;
		
		if(JSVC_VAR.VAR_IS_ARRAY(VAR_PARAMETER_ARRAY[0]) == true)
		{
			// Check limits per request 
			if(VAR_PARAMETER_ARRAY.length >= CUSTOM_SITE_ARRAY_REQUEST_LIMIT)
			{
				throw "HTTP request is too large for single request. Limit : " + CUSTOM_SITE_ARRAY_REQUEST_LIMIT;
			}
			
			// Populate Array Items
			while(VAR_PARAMETER_ARRAY.length > 0 && ARRAY_INDEX < CUSTOM_SITE_ARRAY_REQUEST_LIMIT)
			{
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_CAT_COUNTRY_ID[]', VAR_PARAMETER_ARRAY[0]["PARAM_CAT_COUNTRY_ID"]);
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_CAT_COUNTRY_CODE[]',  VAR_PARAMETER_ARRAY[0]["PARAM_CAT_COUNTRY_CODE"]);
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_CAT_COUNTRY_DESCRIPTION[]',  VAR_PARAMETER_ARRAY[0]["PARAM_CAT_COUNTRY_DESCRIPTION"]);
				PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_CAT_COUNTRY_STATUS[]',  VAR_PARAMETER_ARRAY[0]["PARAM_CAT_COUNTRY_STATUS"]);

				
				VAR_PARAMETER_ARRAY.shift();
				ARRAY_INDEX ++;
			}					
		}
		else
		{
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_CAT_COUNTRY_ID[]', VAR_PARAMETER_ARRAY[ARRAY_INDEX]["PARAM_CAT_COUNTRY_ID"]);
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_CAT_COUNTRY_CODE[]',  VAR_PARAMETER_ARRAY[ARRAY_INDEX]["PARAM_CAT_COUNTRY_CODE"]);
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_CAT_COUNTRY_DESCRIPTION[]',  VAR_PARAMETER_ARRAY[ARRAY_INDEX]["PARAM_CAT_COUNTRY_DESCRIPTION"]);
			PARAM_SET = JSRC_HTTP.REF_ADD(PARAM_SET, 'PARAM_CAT_COUNTRY_STATUS[]',  VAR_PARAMETER_ARRAY[ARRAY_INDEX]["PARAM_CAT_COUNTRY_STATUS"]);
		}

		// Send SQL Request
		// _______________________________________________________________________		
		CUS_SEND_REQUEST
		(
			CALLBACK_ADDRESS,
			'<!--[#SITE_URL;]-->/Account/member/save',
			'<!--[#SITE_URL;]-->/System/nonce/get',
			PARAM_SET
		);	
	}
	
	/** 
	 * =======================================================================================================
	 * Populate SP-SAVE request parameters with default value.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE = function()
	{
		// Initialize
		var RESULT_MAPARRAY = [];

		// Populate default fields
		RESULT_MAPARRAY["PARAM_CAT_COUNTRY_ID"] = FLAG_BIGINT_NULL;
		RESULT_MAPARRAY["PARAM_CAT_COUNTRY_CODE"] = FLAG_NVARCHAR_NULL;
		RESULT_MAPARRAY["PARAM_CAT_COUNTRY_DESCRIPTION"] = FLAG_NVARCHAR_NULL;
		RESULT_MAPARRAY["PARAM_CAT_COUNTRY_STATUS"] = FLAG_TINYINT_NULL;

		// Return prepared MapArray
		return RESULT_MAPARRAY;		
	}
	
	/** 
	 * =======================================================================================================
	 * Add SP-GET request for multiple record save request.
	 * =======================================================================================================
	 */	
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_ADD_MAPPED_ARRAY_FOR_SAVE = function
	(
		VAR_GROUPED_PARAMETER_ARRAY,
		VAR_ADD_PARAMETER_ARRAY
	)
	{
		// Parameter Validation
		// _______________________________________________________________________
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(VAR_GROUPED_PARAMETER_ARRAY, 'VAR_GROUPED_PARAMETER_ARRAY', 'ARRAY');
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(VAR_ADD_PARAMETER_ARRAY, 'VAR_ADD_PARAMETER_ARRAY', 'ARRAY');
		
		// Push ParameterSet
		// _______________________________________________________________________
		VAR_GROUPED_PARAMETER_ARRAY.push(VAR_ADD_PARAMETER_ARRAY);
		return VAR_GROUPED_PARAMETER_ARRAY;
	}
	/** 
	 * =======================================================================================================
	 * Perform SQL DELETE request to the table ACCOUNT_MEMBER. Returns DataSet.
	 *
	 * @param PARAM_CAT_COUNTRY_ID Primary Key ID, Can be Array.
	 * @param CALLBACK_ADDRESS(bool, String) A callback method when the server response is received.
	 * =======================================================================================================
	 */
	JSCUS_SQL.ACCOUNT_MEMBER.CUS_DELETE = function
	(
		PARAM_CAT_COUNTRY_ID,
		CALLBACK_ADDRESS
	)
	{
		// Parameter Validation
		// _______________________________________________________________________
		JSVC_AV.VAR_VALIDATE_ARGUMENT_TYPE(VAR_PARAMETER_ARRAY, 'VAR_PARAMETER_ARRAY', 'ARRAY, NUMERIC');
	
		// Process SQL Request
		// _______________________________________________________________________	
		var PARAM_SET = "";
		var ARRAY_INDEX = 0;
		
		if(JSVC_VAR.VAR_IS_ARRAY(PARAM_CAT_COUNTRY_ID) == true)
		{
			// Check limits per request 
			if(PARAM_CAT_COUNTRY_ID.length >= CUSTOM_SITE_ARRAY_REQUEST_LIMIT)
			{
				throw "HTTP request is too large for single request. Limit : " + CUSTOM_SITE_ARRAY_REQUEST_LIMIT;
			}
			
			// Populate Array Items
			while(PARAM_CAT_COUNTRY_ID.length > 0 && ARRAY_INDEX < CUSTOM_SITE_ARRAY_REQUEST_LIMIT)
			{
				PARAM_SET = JSRC_HTTP.REF_ADD('', 'PARAM_CAT_COUNTRY_ID[]', PARAM_CAT_COUNTRY_ID[ARRAY_INDEX]);
			
				PARAM_CAT_COUNTRY_ID.shift();
				ARRAY_INDEX ++;
			}	
		}
		else
		{
			PARAM_SET = JSRC_HTTP.REF_ADD('', 'PARAM_CAT_COUNTRY_ID[]', PARAM_CAT_COUNTRY_ID);
		}

		// Send SQL Request
		// _______________________________________________________________________				
		CUS_SEND_REQUEST
		(
			CALLBACK_ADDRESS,
			'<!--[#SITE_URL;]-->/Account/member/delete',
			'<!--[#SITE_URL;]-->/System/nonce/get',
			PARAM_SET
		);	
	}