// the following code is modified from quirksmode.org
// I added the path option
// no support for the domain or secure options, but they could be added easily
function write_cookie(name, value, days, path) {
	if(days) {
		var date = new Date();
		date = date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var exp = "; expires=" + date.toGMTString;
	}
	else { var exp = ""; }
	if(!path) path = "/";
	document.cookie = name + "=" + value + exp + "; path=" + path;
}

// returns value of specified cookie or null if not found
function read_cookie(name) {
	var c, ca = document.cookie.split(';'), nameEQ = name + "=";
	
	for(var i = 0; i < ca.length; i++) {
		c = ca[i];
		while(c.charAt(0) == ' ') c = c.substring(1, c.length);
		if(c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}

function erase_cookie(name) { write_cookie(name, "", -1); }
