var setCookie = function(p_name,p_value,p_days)
{
 var dataAtual = new Date();
 var numDias	  = (p_days)?p_days:0;
 var expires   = "";
	
 if(numDias)
 {
	dataAtual.setTime(dataAtual.getTime() + (numDias * 24 * 60 * 60 * 1000));
	expires = "; expires=" + dataAtual.toGMTString();
 }
 document.cookie = p_name + "=" + p_value + expires + "; path=/";
}

var getCookie = function(p_name)
{
 var nomeCookie = p_name + "=";
 var cookies	= document.cookie.split(';');

 for(var i = 0; i < cookies.length; i++)
 {
	var cookieValue = cookies[i];
	
	while(cookieValue.charAt(0) == ' ')
	{
		cookieValue = cookieValue.substring(1,cookieValue.length);
	}
	
	if(cookieValue.indexOf(nomeCookie) == 0)
	{
	  return cookieValue.substring(nomeCookie.length,cookieValue.length);
	}
 }
return null;
}
