
function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays*24*60*60*1000);
	document.cookie = c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ("; expires=" + exdate.toGMTString()))+ "; path=/";
}

function readCookie(name) {
	var nameEQ = 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(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	setCookie(name,"",null);
//	alert("erase");
}


function ToggleView(id) {
	var box = document.getElementById("box" + id);
	//var w = box.offsetWidth;

	if (box.style.display != "none") {
		setCookie('box' + id, "hidden", null);
		//document.cookie = "box" + id+ "=hidden; path=/";
		box.style.display = "none";
	}
	else {
		//document.cookie = "box" + id+ "=; path=/";
		eraseCookie('box' + id);
		box.style.display = "block";
		//setCookie('box' + id, "", -1);
	}
	//alert(box.offsetWidth);
}

function onloadToggleView() {
	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("box") == 0) {
			var id = c.substring(3, c.indexOf("="));
			var value = c.substring(c.indexOf("=")+1, c.length);
			if (value == 'hidden' && document.getElementById('box'+id) != null) {
			    document.getElementById('box'+id).style.display = "none";
			}
		}
	}
}

