function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}

function SetCookie (name, value,expires,path,domain,secure) {
	document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null)	   ? "" : ("; path=" + path)) +
		((domain == null)  ? "" : ("; domain=" + domain)) +
		((secure == true)  ? "; secure" : "");
}

function NoVolverAMostrarDis(distrito)
{
	var Kill = new Date();
	Kill.setDate(Kill.getDate() + 5);
	var value = GetCookie("POPDIS");
	if (value==null){
		SetCookie("POPDIS", distrito, Kill,"/",".telepolis.com",false);
	}else if (value.indexOf(distrito) == -1){
		SetCookie("POPDIS", value+'#'+distrito, Kill,"/",".telepolis.com",false);
	}
	window.close();
}

function NoVolverAMostrar()
{
	var Kill = new Date();
	Kill.setDate(Kill.getDate() + 5);
	var value = GetCookie("POPUP");
	if (value==null){
		SetCookie("POPUP", document.location, Kill,"/",".telepolis.com",false);
	}else if (value.indexOf(document.location) == -1){
		SetCookie("POPUP", value+'#'+document.location, Kill,"/",".telepolis.com",false);
	}
	window.close();
}


function NoVolverAMostrarNoClose()
{
	var Kill = new Date();
	Kill.setDate(Kill.getDate() + 5);
	var value = GetCookie("POPUP");
	if (value==null){
		SetCookie("POPUP", document.location, Kill,"/",".telepolis.com",false);
	}else if (value.indexOf(document.location) == -1){
		SetCookie("POPUP", value+'#'+document.location, Kill,"/",".telepolis.com",false);
	}

}

function HomeCadCookie()
{
	var value = GetCookie("HOME");
	if (value!=null){
		SetCookie("HOME", value, null,"/",".telepolis.com",false);
	}
}

function AbrirPopupCookie(url,ancho,alto)
{
	var dia = new Date();
	var value = GetCookie("POPUP");
	if(value == null || value.indexOf(url) == -1)
	{
		window.open(url,'popup' + dia.getSeconds() ,'width='+ancho+',height='+alto+',top=50,left=50');
	}
}

function AbrirPopupDis(distrito,ancho,alto)
{
	var dia = new Date();
	var value = GetCookie("POPDIS");
	if(value == null || value.indexOf(distrito) == -1)
	{
		window.open('http://www.telepolis.com/cgi-bin/distritos/apuntate?distrito='+distrito+'&accion=promo','popup' + dia.getSeconds() ,'width='+ancho+',height='+alto+',top=50,left=50');
	}
}

function VolverAMostrarTodo()
{
	var Kill = new Date();
	Kill.setDate(Kill.getDate() - 5);
	
	SetCookie("POPUP", "", Kill,"/",".telepolis.com",false);
	alert('Cookie POPUP eliminada');
	
}