function getCookie(NameOfCookie)
{

// Existeix cookie?
   if (document.cookie.length > 0) 
    {              
    begin = document.cookie.indexOf(NameOfCookie+"=");       
      if (begin != -1) 
      {           
      begin += NameOfCookie.length+1;       
      end = document.cookie.indexOf(";", begin);
      if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(begin, end));
      } 
    }

  return null;
}

function setCookie(NameOfCookie,value, expiredays) 
{
//fica una cookie mes
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

document.cookie = NameOfCookie + "=" + escape(value) +
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) 
{

//Es converteix a data imposible i ja està
if (getCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
} 

function JaHanVisitat()
{//retorna true o false
	idioma=getCookie('idioma');
	if(idioma!=null)
 	{		
		return true;
 	}
 	else
 	{
  		return false;
 	}
	
}
function MarcaVisitat(lenguaje)
{
//utilitzable també per actualitzar el cookie
	setCookie('idioma',lenguaje,365);
}


