function setCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name) {
	var temp = name + "=";
	var ca = document.cookie.split(";");
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==" ") c = c.substring(1,c.length);
		if (c.indexOf(temp) == 0) return c.substring(temp.length,c.length);
	}
	return null;
}

function clearCookie(name) {
	setCookie(name,"",-1);
}

function initCheckBox(id, cookie) {
	var checkbox = document.getElementById(id);
	if (checkbox) {
		if (!cookie) cookie = id;
		var value = getCookie(cookie);
		checkbox.checked = (value === "yes") ? true : false;
		checkbox.cookie = cookie;
		checkbox.onclick = function(e) {
			setCookie(this.cookie, this.checked ? "yes" : "no" );
			location.reload();
		};
	}
}
