function User(_id) {

	// Methods
	this.logOut = User_logOut;
	this.writeToCookie = User_writeToCookie;
	this.getCookie = User_getCookie;
	
	// Standard properties
	var userinfo = this.getCookie("UserInfo");
	if (userinfo) {
		var aCookie = this.getCookie("UserInfo").split("|");
		if (aCookie.length == 5) {
			this.id = aCookie[0];	
			this.name = aCookie[1];
			this.fullName = aCookie[2];
			this.token = aCookie[3];
			this.webroot = aCookie[4];
		}
		else {
			this.id = 1;	
			this.name = "guest";
			this.fullName = "Guest Access";
			this.token = "";
			this.webroot = "";
		}
	}
	else {
		this.id = 1;	
		this.name = "guest";
		this.fullName = "Guest Access";
		this.token = "";
		this.webroot = "";
	}

}
function User_logOut() {
	
	var userinfo = "";
	var cookiePath;
	if (webroot == "")
		cookiePath = "/";
	else
		cookiePath = webroot;
		
	document.cookie = "UserInfo=" + escape(userinfo) + ";path=" + cookiePath;

}

function User_getCookie(whichCookie) {
	
    var dc = document.cookie;
    var prefix = whichCookie + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
	
}

function User_writeToCookie() {
	
	var cookiePath;
	if (webroot == "")
		cookiePath = "/";
	else
		cookiePath = webroot;
	
	var userinfo = this.id + "|" + this.name + "|" + this.fullName + "|" + this.token + "|" + cookiePath;

	document.cookie = "UserInfo=" + escape(userinfo) + ";path=" + cookiePath;

}