function getEndUserID() {
	var endUserID = getCookie("userid");
	if (endUserID == null) {
		endUserID = generateUniqueID();
		// Create a date far into the future
		var today = new Date();
		today.setTime(today.getTime()+(86400000*18000));
		setCookie("userid", endUserID, today);
	}
	return endUserID;
}

function generateUniqueID() {
	var strId = "";
	for (i = 0; i < 5; i++) {
		strId += String.fromCharCode(getRandomValue(90, 65));
	}
	var today = new Date();
	strId += today.getTime()
	return strId;
}

function getRandomValue(max, min) {
	var span = max-min;
	var d = span*Math.random();
	return d+min;
}

function setCookie(name, value, expire) {
	document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}

function getCookie(name) {
	var search = name + "=";
	if (document.cookie.length > 0) { 
		offset = document.cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
	}
	return null;
}
