function setCookie(value)
{
	var d = new Date();
	d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
	var expires = "; expires=" + d.toGMTString();
	document.cookie = "memo=" + value + expires + "; path=/";
}

function getCookie()
{
	var pattern = "memo=";
	var dump = document.cookie.split(';');
	for(var i = 0; i < dump.length; i++) {
		var c = dump[i];
		while(c.charAt(0) == ' ') {
			c = c.substring(1, c.length);
		}
		if(c.indexOf(pattern) == 0) {
			return c.substring(pattern.length, c.length);
		}
	}
	return "";
}

function addMemo(item)
{
	var v = getCookie();
	if(v.length > 0) {
		// Check for duplicates.
		var memo = v.split(",");
		for(var i = 0; i < memo.length; i++) {
			if(memo[i] == item)
				return;
		}
		v = v + "," + item;
	}
	else {
		v = item;
	}
	setCookie(v);
}

function getMemo()
{
	return getCookie();
}

function showMemo()
{
	window.open("../notepad/show.php", "memo", "width=432,height=480,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no");
}

function sendMemo()
{
	window.open("../notepad/send.php", "memo", "width=432,height=480,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
}
