var domain = window.location.host.substr(window.location.host.lastIndexOf(".", window.location.host.lastIndexOf(".")-1));
function Cookie(name, value)
{
  this.name = name;
  this.value = value;
  this.expires = new Date();
  this.path = "/";
  this.domain = domain;
  this.CookieSet = CookieSet;
  return this;
}
function CookieSet()
{
  var c = "";
  c += this.name + "=" + escape(this.value);
  if (this.expires != null)
    c += "; expires=" + this.expires.toGMTString();
  if (this.path != null)  
    c += "; path=" + this.path;
  if (this.domain != null)  
    c += "; domain=" + this.domain;
  document.cookie = c;
}
function CookieGet(name)
{
  var cookies = document.cookie;
  var pos1 = cookies.indexOf(name + "=");
  if (pos1==-1) return null;
  var pos2 = cookies.indexOf(";", pos1);  
  if (pos2!=-1) {
    return cookies.substring(pos1 + name.length + 1, pos2);
  } else {
    return cookies.substr(pos1 + name.length + 1);
  }
}

function GetUser (name) {
	codHtml = '';
	cookiedata = CookieGet(name);
	var cookieuser = 'invitado'
	cookiedata = unescape(cookiedata)
	var splitted = cookiedata.split("|");
	for (i=0; i<splitted.length; i++) {
		var splitted2 = splitted[i].split("=")
		if (splitted2[0]=="ALINOMBRE") {
			cookieuser = splitted2[1];
		}
	}
	if (cookieuser!='invitado') {
		codHtml +='<span class="negro">Bienvenido <b>'+cookieuser+'</b> [<a href="javascript:DesconectarVentana();" class="menu">Desconectar</a>]</span>';
		codHtml +='<form action="" name="FORMDESCONECTA" method="post" style="display: inline;">';
		codHtml +='<input type="Hidden" name="ESTATICO" value="yes"/>';
		codHtml +='<input type="hidden" name="SITE" value="espacio2"/>';	
		codHtml +='<input type="Hidden" name="URL_VOLVER" value="'+location.href+'"/>';
		codHtml +='</form>';
	} 
	document.write(codHtml );
}