var timerId = 0;
function onloadproc()
{
	document.getElementById("name").value = unescape(getCookie("name"));
	var reloadtime = Number(unescape(getCookie("reload")));
	if (reloadtime < 5) reloadtime = 15;
	document.getElementById("reload").value = reloadtime;
	changeReloadTime(document.getElementById("reload").value);
}
function timerproc()
{
	location.reload();
}
function onsubmitproc(name)
{
	setCookie("name", escape(name), "Tue, 1-Jan-2030 00:00:00 GMT");
}
function changeReloadTime(time)
{
	setCookie("reload", escape(time), "Tue, 1-Jan-2030 00:00:00 GMT");
	clearTimeout(timerId);
	timerId = setTimeout(timerproc, time * 1000);
}
function getCookie(key)
{
	var cookie = document.cookie.split("; ");
	for (var i=0; i < cookie.length; i++) {
		var tmp = cookie[i].split("=");
		if (key == tmp[0] && tmp[1])
			return tmp[1];
	}
	return "";
}
function setCookie(key, value, expires)
{
	document.cookie = key + "=" + value + "; expires=" + expires + ";";
}
