function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) 
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      } 
   }
   return "";
}

function abrir (pag, nombre, w, h)
{
	posleft = (screen.availWidth / 2) - (w / 2);
	postop = (screen.availHeight / 2) - (h / 2);
	remote = window.open(pag,nombre,'width=' + w +',height=' + h + ',alwaysRaised=1,resizable=0,personalbar=0,left=' + posleft + ',top=' + postop);

//	remote = window.open('', 'BIWE','width=400,height=115,resizable=1');
	if (remote != null) {
	    if (remote.opener == null) 
		  remote.opener = self;
	    else		
	          remote.opener = window.parent;
//        remote.location.href = pag;
	}

}

function abrirPreEx(f)
{
	abrir ("http://www.chatear.com/inc/vacio.php", "chatearcom", 636, 395);
	f.target = "chatearcom";
	f.method = "GET";
	f.action = "http://www.chatear.com/prechat.php";
	f.submit();
}

function abrirPre(canal)
{
	if ((getCookie('validado') == '1') && (getCookie('nick') != ""))
		abrirChat (getCookie('nick'), getCookie('clave'), canal);
	else
		abrir ("http://www.chatear.com/prechat.php?nc=Admin&c=" + canal, "_blank", 636, 395);
}

function abrirChat(nombre, clave, canal)
{
	abrir ("http://www.chatear.com/chat.php?nc=Admin&n=" + nombre + "&p=" + clave + "&c=" + canal, "_blank", 636, 395);
}

function abrirChatEx(f)
{
	abrir ("http://www.chatear.com/inc/vacio.php", "chatearcom", 636, 395);
	f.target = "chatearcom";
	f.method = "GET";
	f.action = "http://www.chatear.com/chat.php";
	f.submit;
}
