/* Release 5.2 */

/* 
 * ua.mp.js
 * 
 * Created: Nov 2010
 * Author: United.com Front-End Team (RSO)
 * Release: 
 * 
 * Dependencies:
 * ua.js
 * 
 * MileagePlus functionality
 * 
 */


ua.mp = new function(){
	
};

ua.mp.utils  = new function(){
	/*
	 * @PRIVATE - Create "M" object, populated with member information.
	 */
	var createMemberObject = function(){
		ua.mp.M = {};
		ua.mp.loggedin = false; /* Default unless proven otherwise */
		
 		var splitValue = [],
			tempObj = {};
			
		if (ua.cookies.hasOwnProperty('rememberProfile')) {
			splitValue = unescape(ua.cookies.rememberProfile).split("||");
			ua.mp.M = {
				mpiNumber: 	splitValue[0],
				firstName: 	splitValue[1],		// Obsolete. Set from myInformation
				lastName: 	splitValue[2],		// Obsolete. Set from myInformation
				mpLevel: 	splitValue[3],
				mpBal: 		splitValue[4] * 1,	// Convert to number
				homeArpt: 	splitValue[5]
			};
			
			/* Original logic to determine "logged in":
			 * if (isDefined(myCookies['rememberProfile']) && isDefined(myCookies['isSecure']) && myCookies['isSecure'] == "true") {}
			 * SHD says that "isSecure" isn't necessary anymore, so we do not test against its existence 
			 */
			ua.mp.loggedin = true;
		}
		if (ua.cookies.hasOwnProperty('mpInformation')) {
			splitValue = unescape(ua.cookies.mpInformation).split("||");
			tempObj = {
				prefix: 		splitValue[0],
				firstName:		splitValue[1],
				middleinit:		splitValue[2],
				lastName:		splitValue[3],
				suffix:			splitValue[4],
				emlErrFlg:		splitValue[5],
				addrErrFlg:		splitValue[6],
				pbaoStatus:		splitValue[7],
				epaStatus:		splitValue[8],
				rccStatus:		splitValue[9],
				cardholderFlg:	splitValue[10],	// String Y/N
				cardtypeFlg:	splitValue[11]	// Comma-delimited list of values (ex: FC,S1,DB)
			};
			$.extend(ua.mp.M, tempObj);
		}
		
		/* 
		 * Since many scripts use the window version of this object, 
		 * let's be sure to make it backwards-compatible 
		 * */ 
		if (typeof window.M === 'undefined') {
			window.M = ua.mp.M;
		}
	}();
};
/* missing legacy function */
function HPSearch(frm) {
	return true;
}

/* missing legacy function */
function HPSearch(frm) {
	return true;
}

