var w3cookies = {
	date: new Date(),

	// w3cookies.create("nome_do_cookie", "valor", dias_para_expirar);
	create: function(strName, strValue, intDays)
	{
		if (intDays)
		{
			this.date.setTime(this.date.getTime() + (intDays * 24 * 60 * 60 * 1000));
			var expires = "; expires=" + this.date.toGMTString();
		}
		else
		{
			var expires = "";
		}
		document.cookie = strName + "=" + strValue + expires + "; path=/";
	},

	// w3cookies.read("nome_do_cookie");
	read: function(strName)
	{
		var strNameIgual = strName + "=";
		var arrCookies = document.cookie.split(";");
		for (var i = 0, strCookie; strCookie = arrCookies[i]; i++)
		{
			while ( strCookie.charAt(0) == " ")
			{
				strCookie = strCookie.substring(1,strCookie.length);
			}
			if ( strCookie.indexOf(strNameIgual) == 0 )
			{
				return strCookie.substring(strNameIgual.length,strCookie.length);
			}
		}
		return null;
	},

	// w3cookies.erase("nome_do_cookie");
	erase: function(strName)
	{
		this.create(strName, "", -1);
	}
}


function setList(check, valor)
{
	var int_dias = 3;
	var v_atual  = w3cookies.read("selecao_lista");

	if (check)
	{
		if (!v_atual)
		{
			w3cookies.create("selecao_lista", valor, int_dias);
		}
		else
		{
			valor = v_atual + "," + valor;
			w3cookies.create("selecao_lista", valor, int_dias);
		}
	}
	else
	{
		if (!v_atual)
		{
			clearList();
		}
		else
		{
			v_atual = "," + v_atual;
			v_atual = v_atual.replace("," + valor, "");
			v_atual = v_atual.substr(1, v_atual.length);
			w3cookies.create("selecao_lista", v_atual, int_dias);
		}
	}
}

function clearList()
{
	w3cookies.erase("selecao_lista");
	window.location.href = 'index.asp';
}