
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);

//	remote = window.open('', 'BIWE','width=400,height=115,resizable=1', 'toolbar=yes');
	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)
{
	//alert('hola');
	abrir ("http://www.chatear.com/chat_web.php?nc=Admin&n=" + "d" + "&p=" + "" + "&c=" + canal, "chat", 1024, 768);
}

function abrirParaChat(nombre, clave, canal)
{
	abrir ("http://www.chatear.com/chat_web.php?nc=Admin&n=" + "d" + "&p=" + "" + "&c=" + canal, "chat", 1024, 768);
}

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_web.php";
	f.submit;
}

//de la home

var tipochat="java";
function tipo_chat(eleccion) {
	tipochat = eleccion;
}
function busqueda(buscar) {
	if (document.buscar.donde.options[document.buscar.donde.selectedIndex].value == "canales") {
		document.buscar.action="indice/busca_canal_ok.php";
	}
	if (document.buscar.donde.options[document.buscar.donde.selectedIndex].value == "webs") {
		document.buscar.nombre.value = document.buscar.canal.value;
		document.buscar.action="indice/busca_pagina_ok.php";
	}
	if (document.buscar.donde.options[document.buscar.donde.selectedIndex].value == "usuarios") {
		document.buscar.nick.value = document.buscar.canal.value;
		document.buscar.action="indice/busca_usuario_ok.php";
	}
	if (document.buscar.donde.options[document.buscar.donde.selectedIndex].value == "contactos") {
		document.buscar.keyword.value = document.buscar.canal.value;
		document.buscar.action="contactos/contactos.php";
	}
	if (document.buscar.donde.options[document.buscar.donde.selectedIndex].value == "ranking") {
		document.buscar.nick.value = document.buscar.canal.value;
		document.buscar.action="indice/busca_ranking_ok.php";
	}
	if (document.buscar.donde.options[document.buscar.donde.selectedIndex].value == "internet") {
		document.buscar.Keywords.value = document.buscar.canal.value;
		document.buscar.action="http://www.buscador.com/buscador.php";
	}
	if (!buscar.canal.value) {
		alert ("Por favor, introduzca una palabra para efectuar la busqueda.")
		return false;
	}
	return true;
}
function enlace() {
	nombre = "d";
	clave = "";
	canal = document.log.canal.options[document.log.canal.selectedIndex].value;
	if (nombre == "") {
		alert("Debes introducir un nick");
		document.log.canal.selectedIndex = 0;
		return false;
	}
	if (tipochat=="java") {
		abrirParaChat(nombre, clave, canal);
	}
	else abrir('cliente3/chat.php?n='+nombre+'&p='+clave+'&c='+canal, 'chat', 790, 550);
	//setTimeout("location.href='index.php'",10000);

	return true;
}
function IrA (pagina){
	ventana = window.open(pagina,"canales","toolbar=0,location=0,directories=0,menubar=0,width=636,height=395");
	return false;
}
function leyenda(){
	window.open('leyenda.htm','Leyenda','toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,width=140,height=337');
}
//indexreg
function confirmSubmit(){
var agree=confirm("Si borras este canal quedará inutilizado. Pulsa OK para borrarlo");
if (agree)
	return true ;
else
	return false ;
}
function abrir_popup_flash (pag, nombre, w, h){
   posleft = (screen.availWidth / 2) - (w / 2);
   postop = (screen.availHeight / 2) - (h / 2);
   window.open(pag,nombre,'width=' + w +',height=' + h + ',alwaysRaised=1,resizable=0,personalbar=0,left=' + posleft + ',top=' + postop);
}
//col_izq
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
