function existeix(vcookie)
{
	var tot=top.document.cookie;

	if (tot.indexOf(vcookie+"=")>-1)
		return true;
	else 
		return false;
}

function guardaCookie(vcookie,vvalor)
{

	if (!existeix(vcookie))
		top.document.cookie=vcookie+"="+vvalor+";path=/";

}
function llegeixCookie(vcookie)
{
	if (existeix(vcookie))
	{
		var tot=top.document.cookie;
		var pos=0;
		var posfi=0;
		if ((pos=tot.indexOf(vcookie+"="))>-1)
		{
			if ((posfi=tot.indexOf(";",pos+vcookie.length+1))==-1)
				posfi=tot.length;
			tot=tot.substring(pos+vcookie.length+1,posfi);
			return tot;
			
		}	
	}
	return false;
}

function treureCookie(vcookie)
{

	if (existeix(vcookie))
	{
		var data=new Date();
		data.setTime(0);
		top.document.cookie=vcookie+"="+top.llegeixCookie(vcookie)+";path=/;expires="+data.toGMTString();
		return true;
	}
	return false;
}
