document.cookie = 'hasCookie=true;%20path=/index.html';

function setSessionCookieValue(name, value){
	// only set cookie if cookies are enabled; if cookies are disabled, you don't want to keep prompting over and over again
	if(getCookieValue('hasCookie')){
		document.cookie = name + '=' + value + '; path=/';
	}
}

function getCookieValue(name) {
	var b = document.cookie.split("; ");
	for (var i=0; i < b.length; i++) {
		var nb = b[i].split("=", 1);
		if (nb[0] == name) {
			if (b[i].indexOf("=") >= 0)
				return unescape(b[i].substr(b[i].indexOf("=")+1));
			else return "";
		}
	}
	return null;
}

function getCookieSubValue(name, subkey) {
	var b = document.cookie.split("; ");
	for (var i=0; i < b.length; i++) {
		var nb = b[i].split("=", 1);
		if (nb[0] == name) {
			if (b[i].indexOf("=") >= 0) {
				var c = unescape(b[i].substr(b[i].indexOf("=")+1)).split("&");
				for (var j = 0; j < c.length; j++) {
					var nc = c[j].split("=");
					if (nc[0] == subkey) {
						return unescape(nc[1]);
					}
				}
			} else return "";
		}
	}
	return null;
}

function emptyStringForNull(str) {
	if (str == null) return ""
	else return str;
}

