<!--

function setJCookie(name, value, domain, path, expires, secure)
{
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie(Name)
{
	var search = Name + "=";
	if (document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
	}
}

function deleteCookie(name, path, domain)
{
       if (getCookie(name))
       {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
       }
}

function getUserCookie()
{
	var STAT_COOKIE_OLD = "EPStat";
	var STAT_COOKIE = "JVID";
	var REGISTERED_COOKIE = "EPactive";
	var DOMAIN = ".clppy.it";
	var PATH = "/";

	var today = new Date();
	var unique = today.getUTCDate()+""+parseInt((Math.random()*(Date.parse(new Date()))))+parseInt((Math.random()*(Date.parse(new Date()))));
	var expire = new Date(today.getTime() + ((1000*60*60*24*365)/2));//expire to six Mont

	if (getCookie(STAT_COOKIE_OLD) == null)
		setJCookie(STAT_COOKIE_OLD, unique, DOMAIN, PATH, expire);

	if (getCookie(STAT_COOKIE) == null)
		setJCookie(STAT_COOKIE, unique, DOMAIN, PATH, expire);

	// modify the customer-cookie domain if related to ".clappy.it"
	if (getCookie(REGISTERED_COOKIE) != null)
	{
		var usr = getCookie(REGISTERED_COOKIE);
		deleteCookie(REGISTERED_COOKIE,PATH,".clappy.it")
		setJCookie(REGISTERED_COOKIE, usr, "www.clappy.it", PATH, expire);
	}

}
//-->
