
	var DATE_HOLDER = null;
	var FIRST_TRY = 0;

	if(JSVC_COOKIE.VAR_ISSET("DATE_HOLDER"))
	{
		DATE_HOLDER = JSVC_COOKIE.VAR_READ("DATE_HOLDER");
	}

	function CHECK_ORDER_LIST()
	{
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_JORDER_STATUS', 2);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_JORDER_USER_ASSIGN', 1);

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'REC_JORDER_DATE_POST');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'DESC');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_LIMIT', 1);

		JSCUS_SQL._RECORD._JOB_ORDER.CUS_GET
		(
			GET_MAP_ARRAY,
			HTTP_CHECK_ORDER_LIST_CALLBACK,
			true
		);
	}

	function HTTP_CHECK_ORDER_LIST_CALLBACK(IS_SUCCESS, RESPONSE_STRING)
	{
		JSRC_THREAD.REF_POST_DELAYED
		(
			function(){	CHECK_ORDER_LIST(); },
			60000
		);

		// Disable Dialogs
		// _______________________________________________________________________
		CUS_SEND_DIALOG_TRY_DISMISS();

		// Validate
		// _______________________________________________________________________
		if(IS_SUCCESS === false)
		{
			alert("CONNECTION ERROR: \n" + RESPONSE_STRING);
			return;
		}
		
		// Validate JSON Response
		// _______________________________________________________________________
		var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
		if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
		{
			alert("REQUEST ERROR: \n" + RESPONSE_STRING);
			return;
		}
		
		// JSON Data
		// _______________________________________________________________________
		if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") > 0)
		{
			//DATE_HOLDER
			if(DATE_HOLDER == null)
			{
				//First Run (no popup)
				DATE_HOLDER = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_JORDER_DATE_POST", 1);
			}
			else
			{
				//Second Run (expect popup if date is different)
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_JORDER_DATE_POST", 1) > DATE_HOLDER)
				{
					//CALL POPUP
					Android.CALL
					(
						'PUSHNOTIFY',
						'<TITLE=New Job Order;><MSG=There are new job orders available. Please check your app fro more details.;><URL=' + JSCUS_CACHE.SERVER_URL + '/p/water/rider/job_order.html;>'
					);

					//CHANGE DATE_HOLDER DATA TO LATEST
					DATE_HOLDER = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_JORDER_DATE_POST", 1);
				}
			}

			DATE_CACHE();
		}
	}

	function DATE_CACHE()
	{
		// 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
		(
			'DATE_HOLDER', 
			DATE_HOLDER, 
			60 * 24 * 7, 
			CURRENT_ROOT_PATH
		);
	}



	function FIRST_RUN()
	{
		if(CUS_SEND_REQUEST_HAS_QUEUE() == false)
		{
			CHECK_ORDER_LIST();
		}
		else
		{
			JSRC_THREAD.REF_POST_DELAYED
			(
				function(){	FIRST_RUN(); },
				2000
			);
		}
	}




	FIRST_RUN();

	
