// NOTE: [This JS must loaded as last item]


	// ===============================================================
	// Initialize Form
	// ===============================================================
	function FORM_LOAD()
	{
		// Initialize
		// _______________________________________________________________________	
		var DGV_ELEMENT_CHILD = null;
		var DGV_ELEMENT_CHILD_INDEX = 0;
		
		
		// DGV OnClick Event
		// _______________________________________________________________________	
		INVOICE_LINE_DGV = DataGridView("INVOICE_LINE_DGV");
		var AUTO_COMPUTE_BLOCKS = [];
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'SUBTOTAL', 					// Target Column
				'(`REC_INVOICELIST_PRICE` * `REC_INVOICELIST_QUANTITY`) - `REC_INVOICELIST_DISCOUNT`',
				true							// Apply CFormat
			]
		);
		INVOICE_LINE_DGV.COLUMN.AUTO_COMPUTE_CREATE(AUTO_COMPUTE_BLOCKS);		
	
		var AUTO_TOTAL_COLUMNS = [];
		AUTO_TOTAL_COLUMNS.push('REC_INVOICELIST_PRICE');
		AUTO_TOTAL_COLUMNS.push('REC_INVOICELIST_QUANTITY');
		AUTO_TOTAL_COLUMNS.push('REC_INVOICELIST_DISCOUNT');
		AUTO_TOTAL_COLUMNS.push('SUBTOTAL');
		
		/*
		INVOICE_LINE_DGV.COLUMN.TOTAL_CREATE
		(
			AUTO_TOTAL_COLUMNS,
			'CAT_PRODUCT_DESCRIPTION',
			[]
		);
		*/		
	
		
		// DGV OnClick Event
		// _______________________________________________________________________	
		INVOICE_RTN_DGV = DataGridView("INVOICE_RTN_DGV");
		AUTO_COMPUTE_BLOCKS = [];
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'SUBTOTAL', 					// Target Column
				'(`REC_INVOICERTN_PRICE` * `REC_INVOICERTN_QUANTITY`) - `REC_INVOICERTN_DISCOUNT`',
				true							// Apply CFormat
			]
		);
		INVOICE_RTN_DGV.COLUMN.AUTO_COMPUTE_CREATE(AUTO_COMPUTE_BLOCKS);		
		
		AUTO_TOTAL_COLUMNS = [];
		AUTO_TOTAL_COLUMNS.push('REC_INVOICERTN_PRICE');
		AUTO_TOTAL_COLUMNS.push('REC_INVOICERTN_QUANTITY');
		AUTO_TOTAL_COLUMNS.push('REC_INVOICERTN_DISCOUNT');
		AUTO_TOTAL_COLUMNS.push('SUBTOTAL');
		
		/*
		INVOICE_RTN_DGV.COLUMN.TOTAL_CREATE
		(
			AUTO_TOTAL_COLUMNS,
			'CAT_PRODUCT_DESCRIPTION',
			[]
		);
		*/		
		
		
		
		// Show Progress
		// _______________________________________________________________________	
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		
		// Requires Authentication
		// _______________________________________________________________________	
		PAGE_AUTH_REQUIRES_LOGIN(HTTP_POPULATE_RESULT);			
		
		
		// Disable Dialogs
		// _______________________________________________________________________	
		CUS_SEND_DIALOG_TRY_DISMISS();
	};
	
	
	// ===============================================================
	// Populate Foreign Keys
	// ===============================================================
	function HTTP_POPULATE_RESULT(IS_SUCCESS, HTTP_RESPONSE)
	{
		// Disable Dialogs
		CUS_SEND_DIALOG_TRY_DISMISS();
			
		// Handle Error
		if(IS_SUCCESS === false)
		{
			alert("Unable to populate lists.");
		}
		else
		{
			// Disable Dialogs
			if(CUS_SEND_REQUEST_HAS_QUEUE() == false)
			{
				HTTP_LOAD(function()
				{
					JSOC_ELEMENT.VAR_INNER_HTML("REC_INVOICE_DATE_DELIVERY_LBL", JSVC_DATE.VAR_FORMAT(JSOC_ELEMENT.VAR_INNER_HTML("REC_INVOICE_DATE_DELIVERY_LBL"), "MM/DD/YYYY"));
					JSOC_ELEMENT.VAR_INNER_HTML("REC_INVOICE_DATE_DUE_LBL", JSVC_DATE.VAR_FORMAT(JSOC_ELEMENT.VAR_INNER_HTML("REC_INVOICE_DATE_DUE_LBL"), "MM/DD/YYYY"));
				});
			}
		}
	};
	
				
	// ===============================================================
	// Begin Processing the Page
	// ===============================================================
	FORM_INITIALIZE();
	FORM_LOAD();