/**
 * package scripts.classes.customer.User
 * 
 * This object holds the user data.
 * The member variables are set in inc_autologin.isml
 * 
 */
var User = User || {
	
	/**
	 * define the members
	 */
	
	loggedIn : null,
	lastName : null,
	firstName : null,
	customerType : null,
	userId : null,
	autoLoginAllowed : null,
	
	
	/**
	 * define constants
	 */
	
	USER_COOKIE_NAME : "BV_UserID",
	DAYS_UNTIL_USER_COOKIE_EXPIRES : 365,
	
	/**
	 * getter and setter methods 
	 */
	
	setLoggedIn : function (loggedIn) {
		if (loggedIn === "true") {
			this.loggedIn = true;
		} else {
			this.loggedIn = false;
		}
	},
	isLoggedIn : function () {
		return this.loggedIn;
	},
	setLastName : function (lastName) {
		this.lastName = lastName;
	},
	getLastName : function () {
		return this.lastName;
	},
	setFirstName : function (firstName) {
		this.firstName = firstName;
	},
	getFirstName : function () {
		return this.firstName;
	},
	setCustomerType : function (customerType) {
		this.customerType = customerType;
	},
	getCustomerType : function () {
		return this.customerType;
	},
	getUserId : function () {
		return this.userId;
	},
	getUserIdFromCookie : function () {
		return jQuery.cookies.get(User.USER_COOKIE_NAME);
	},
	setUserId : function (userId) {
		this.userId = userId;
	},
	isAutoLoginAllowed : function () {
		return this.autoLoginAllowed;
	},
	setAutoLoginAllowed : function (autoLoginAllowed) {
		this.autoLoginAllowed = autoLoginAllowed;
	},
	setUserCookie : function (userId) {
		var exp = new Date();
		exp.setTime(exp.getTime() + (User.DAYS_UNTIL_USER_COOKIE_EXPIRES * 24 * 60 * 60 * 1000));
		jQuery.cookies.set(User.USER_COOKIE_NAME, userId, { expiresAt: exp, path: '/', secure: false });
	},
	deleteUserCookie : function () {
		jQuery.cookies.del(User.USER_COOKIE_NAME);
	}
};
