var ie=(document.all) ? 1:0;
var n4=(document.layers) ? 1:0;
var n6=(document.getElementById) ? 1:0;  

var critica=0;
var numeroImagen = 0;
var hostTmp="http://www.estamosrodando.com";
var whitespace = " \t\n\r";
var reWhitespace = /^\s+$/
var valor_preg = "";
var seg_preg = "";
var respondido=false;
var ind = 0;

	var posicionListaFilling = 0;
	var lista = new Array();
	var tamaLista = 0;
	var datos = new Array();
	var ids = new Array();
	
	function ajaxobj() {
		try {
			_ajaxobj = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				_ajaxobj = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				_ajaxobj = false;
			}
		}
	   
		if (!_ajaxobj && typeof XMLHttpRequest!='undefined') {
			_ajaxobj = new XMLHttpRequest();
		}
		
		return _ajaxobj;
	}

/**
 * Verifica que no este vacio
 */
function isEmpty(s){   
	return ((s == null) || (s.length == 0)) 
}

/**
 * Verifica que no sean espacios en blanco
 */
function isWhitespace (s){
    return (isEmpty(s) || reWhitespace.test(s));
}
/**
 * Devolver cadena sin espacios por delante y por detras.
 */
function trimAll(sString) 
{
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
return sString;
}
/**
 * Valida un email mediante expresiones regulares
 */
function validarEmail(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){
		return true;
	} else {
		return false;
	}
}

function cambiarImagen(numero){
	document.getElementById('imagen_principal').src = img[numero].src;
//	document.getElementById('enlace_principal').href = big[numero];
	document.getElementById('div_img_'+String(numeroImagen)).style.backgroundColor = "#000000";
	document.getElementById('div_img_'+String(numero)).style.backgroundColor = "#C9C9C9";
	numeroImagen=Number(numero);
}

function imagenAnterior(){
	if (numeroImagen!=0)
	{
		ant = Number(numeroImagen) - Number(1);
		document.getElementById('imagen_principal').src = img[ant].src;
		document.getElementById('imagen_principal').alt = img[ant].alt;
		document.getElementById('imagen_principal').title = img[ant].alt;
//		document.getElementById('enlace_principal').href = big[ant];
		document.getElementById('div_img_'+String(numeroImagen)).style.backgroundColor = "#000000";
		document.getElementById('div_img_'+String(ant)).style.backgroundColor = "#C9C9C9";
		if (document.getElementById('descImg'))
		{
			document.getElementById('descImg').innerHTML=img[ant].alt;
		}
		numeroImagen = ant;
	}
}
function imagenSiguiente(total){
	if (Number(numeroImagen)!=(total-1))
	{
		sig = Number(numeroImagen) + Number(1);
		document.getElementById('imagen_principal').src = img[sig].src;
		document.getElementById('imagen_principal').alt = img[sig].alt;
		document.getElementById('imagen_principal').title = img[sig].alt;
//		document.getElementById('enlace_principal').href = big[sig];
		document.getElementById('div_img_'+String(numeroImagen)).style.backgroundColor = "#000000";
		document.getElementById('div_img_'+String(sig)).style.backgroundColor = "#C9C9C9";
		numeroImagen=(numeroImagen+1);
		if (document.getElementById('descImg'))
		{
			document.getElementById('descImg').innerHTML=img[sig].alt;
		}
	}
}

function enviarCritica(frm){
	if (isWhitespace(frm.valoracion.value))
	{
		alert("Valora la película.");
		frm.valoracion.focus();
		return;
	}
	if (isWhitespace(frm.titulo.value))
	{
		alert("Escriba el título de la crítica.");
		frm.titulo.select();
		frm.titulo.focus();
		return;
	}
	if (isWhitespace(frm.critica.value))
	{
		alert("Escriba la crítica que quiera hacer sobre la película.");
		frm.critica.select();
		frm.critica.focus();
		return;
	}
	var result = "<img src='/imagenes/comn/cargando.gif' />";
	
	if(ie){
		document.all["spanCritica"].innerHTML=result;
	}else{
		if(n4){
			document.layers["spanCritica"].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById("spanCritica").innerHTML=result;
			}
		}
	}
	getCritica(frm);
	return;
}


function enviarComentario(frm){
	if (isWhitespace(frm.valoracion.value))
	{
		alert("Valora la película.");
		frm.valoracion.focus();
		return;
	}
	if (isWhitespace(frm.titulo.value))
	{
		alert("Escriba el título del comentario.");
		frm.titulo.select();
		frm.titulo.focus();
		return;
	}
	if (isWhitespace(frm.critica.value))
	{
		alert("Escriba el comentario que quiere hacer sobre la encuesta.");
		frm.critica.select();
		frm.critica.focus();
		return;
	}
	var result = "<img src='/imagenes/comn/cargando.gif' />";
	
	if(ie){
		document.all["spanCritica"].innerHTML=result;
	}else{
		if(n4){
			document.layers["spanCritica"].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById("spanCritica").innerHTML=result;
			}
		}
	}
	getCritica(frm);
	return;
}

function enviarAmigo(frm){
	if (isWhitespace(frm.nombre.value))
	{
		alert("Escriba su nombre.");
		frm.nombre.select();
		frm.nombre.focus();
		return;
	}
	if (!validarEmail(frm.email.value))
	{
		alert("Escriba su e-mail.");
		frm.email.select();
		frm.email.focus();
		return;
	}
	if (isWhitespace(frm.nombre_amigo.value))
	{
		alert("Escriba el nombre de su amigo.");
		frm.nombre_amigo.select();
		frm.nombre_amigo.focus();
		return;
	}
	if (!validarEmail(frm.email_amigo.value))
	{
		alert("Escriba el e-mail de su amigo.");
		frm.email_amigo.select();
		frm.email_amigo.focus();
		return;
	}
	var result = "<img src='/imagenes/comn/cargando.gif' />";
	
	if(ie){    
		document.all["spanEnviar"].innerHTML=result;
	}else{
		if(n4){
			document.layers["spanEnviar"].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById("spanEnviar").innerHTML=result;
			}
		}
	}
	getEnviar(frm);
	return;
}
function enviarContacto(frm){
	if (isWhitespace(frm.nombre.value))
	{
		alert("Escriba su nombre.");
		frm.nombre.select();
		frm.nombre.focus();
		return;
	}
	if (!validarEmail(frm.email.value))
	{
		alert("Escriba su e-mail.");
		frm.email.select();
		frm.email.focus();
		return;
	}
	var result = "<img src='/imagenes/comn/cargando.gif' />";
	
	if(ie){    
		document.all["spanEnviar"].innerHTML=result;
	}else{
		if(n4){
			document.layers["spanEnviar"].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById("spanEnviar").innerHTML=result;
			}
		}
	}
	getContacto(frm);
	return;
}
//mouse over 
function mouseOverMenu2(obj){
	if (obj.className == "opt_menu2_off")
	{
		obj.style.backgroundColor="#BCC2C7";
		obj.style.cursor="pointer";
	}
}
function mouseOverTit2(obj){
	var imgsrc = obj.src;
	imgsrc = imgsrc.replace('.on.png', '.png');
	imgsrc = imgsrc.replace('.png', '.on.png');
	obj.src = imgsrc;
}
function mouseOver(obj){
	if (obj.className == "opt_menu_off")
	{
		obj.style.backgroundColor="#C0C5C7";
	}
}
function mouseOver2(obj){
	if (obj.className == "opt_menu_int_off")
	{
		obj.style.backgroundColor="#9EA8AE";
	}
}
function mouseOverLine(id, total){
	for (i=0; i<total; i++)
	{
		document.getElementById("line_"+id+"_"+i).style.backgroundColor="#FFFFD7";
	}
}
function mouseOverImg(obj, ext){
	var imgsrc = obj.src.replace(ext, 'on.'+ext);
//	alert (imgsrc);
	obj.src = imgsrc;
}

//mouse out 
function mouseOutMenu2(obj){
	if (obj.className == "opt_menu2_off")
	{
		obj.style.backgroundColor="#FFFFFF";
	}
}
function mouseOutTit2(obj, opt){
	if (opt=="")
	{
		var imgsrc = obj.src;
		imgsrc = imgsrc.replace('on.png', 'png');
		obj.src = imgsrc;
	}
}
function mouseOut(obj){
	if (obj.className == "opt_menu_off")
	{
		obj.style.backgroundColor="#EEEEEE";
	}
}
function mouseOut2(obj){
	if (obj.className == "opt_menu_int_off")
	{
		obj.style.backgroundColor="#CCCCCC";
	}
}
function mouseOutLine(id, onoof, total){
	if (onoof=="on")
	{
		for (i=0; i<total; i++)
		{
//			document.getElementsByName("line_"+id).style.backgroundColor="#EEEEEE";
			document.getElementById("line_"+id+"_"+i).style.backgroundColor="#EEEEEE";
		}
	}else{
		for (i=0; i<total; i++)
		{
//			document.getElementsByName("line_"+id).style.backgroundColor="#CCCCCC";
			document.getElementById("line_"+id+"_"+i).style.backgroundColor="#CCCCCC";
		}
	}
}
function mouseOutImg(obj, ext){
	var imgsrc = obj.src.replace('on.'+ext, ext);
//	alert (imgsrc);
	obj.src = imgsrc;
//	obj.src = obj.src.replace('on.'+ext, ext);
}

//mouse over en destacados
function mouseOverDestacados(obj){
	obj.style.backgroundColor="#D9DCDD";
}

//mouse out en destacados
function mouseOutDestacados(obj){
	obj.style.backgroundColor="#FFFFFF";
}
function imgOver(obj, onoff){
	if (onoff == "off")
	{
		obj.src=obj.src.replace(".png", ".on.png");
		obj.src=obj.src.replace(".gif", ".on.gif");
	}
}
function imgOut(obj, onoff){
	if (onoff == "off")
	{
		obj.src=obj.src.replace(".on.png", ".png");
		obj.src=obj.src.replace(".on.gif", ".gif");
	}
}

function buscarPer(frm){
/*	if (isWhitespace(frm.nmbr.value))
	{
		alert("Escriba el nombre de la persona.");
		frm.nmbr.select();
		frm.nmbr.focus();
		return false;
	}*/
/*	if (isWhitespace(frm.ps.value))
	{
		alert("Escriba el país de origen de la persona.");
		frm.ps.focus();
		return false;
	}*/
	frm.submit();
}
function abrirCritica(id){
	if (id!=critica)
	{
		if (critica!=0)
		{
			cerrarCritica(critica);
		}
		if(ie){
			document.all["critica-"+id].style.display='inline';
		}else{
			if(n4){
				document.layers["critica-"+id].display='inline';
			}else{
				if(n6){      
					document.getElementById("critica-"+id).style.display='inline';
				}
			}
		}
		critica = id;
	}else{
		cerrarCritica(critica);
	}
}
function cerrarCritica(id){
	if(ie){    
		document.all["critica-"+id].style.display='none';
	}else{
		if(n4){
			document.layers["critica-"+id].display='none';
		}else{
			if(n6){      
				document.getElementById("critica-"+id).style.display='none';
			}
		}
	}
	critica = 0;
}
function cambiarValoracion(obj, pel, per, id){
	if (obj.value!="")
	{
		valorar(obj.value, pel, per, id);
	}
}
function paginadoOver(obj){
	obj.style.backgroundColor="#EEEEEE";
}

function paginadoOut(obj){
	obj.style.backgroundColor="#FFFFFF";
}
function cambiarCiudad(frm){
	frm.cdd.value=frm.ciudad.value;
}
function enviara(opt, url_art){
	var url="";
	switch (opt)
	{
		case 'meneame':
			url = "http://meneame.net/login.php?return=/submit.php?url=" + url_art;
		break;
		case 'digg':
			url = "http://digg.com/submit?phase=2&url=" + url_art;
		break;
		case 'delicious':
			url = "https://secure.del.icio.us/login?url=" + url_art;
		break;
		case ' thecnorati':
			url = "http://www.technorati.com/search/" + url_art + "?sub=postcosm";
		break;
		case 'yahoo':
			url = "https://login.yahoo.com/config/login?.intl=us&.src=smw&.pd=smw_ver%3d1&.done=" + url_art;
		break;
		case 'fresqui':
			url = "http://tec.fresqui.com/post?url=" + url_art;
		break;
	}
	var pop = window.open(url);
	popup.focus();
}
zm_intro = 11;
zm_intro_lh = 15;
zm_linke = 9;
zm_linke_lh = 13;
zm_texto = 11;
zm_texto_lh = 15;
zm_titulo = 13;
zm_titulo_lh = 18;
function zoomIn() {
	//		PARA EL TAG zm_texto
	if (zm_texto < 18){
		zm_texto += 2;
		zm_texto_lh += 2;
		
//		titulares = document.getElementById("zm_texto0");
		ii=0;
		while (eval(titulares=document.getElementById("zm_texto"+ii))!=null)
		{
			titulares.style.fontSize = zm_texto+'px';
			titulares.style.lineHeight = zm_texto_lh+'px';
			ii++;
		};
	}
}
function zoomOut() {
	//		PARA EL TAG zm_texto
	if (zm_texto > 9){
		zm_texto -= 2;
		zm_texto_lh -= 2;
//		titulares=document.getElementById("zm_texto0");
		ii=0;
		while (eval(titulares=document.getElementById("zm_texto"+ii))!=null)
		{
			titulares.style.fontSize = zm_texto+'px';
			titulares.style.lineHeight = zm_texto_lh+'px';
			ii++;
		};
	}
}
//mouse over en arriba y abajo de noticias
function overArrAbj(obj, id){
	obj.style.backgroundColor="#909395";
	if (id=="imgArr")
	{
		document.getElementById(id).src = "http://www.estamosrodando.com/imagenes/noti/arriba-on.gif";
	}else{
		document.getElementById(id).src = "http://www.estamosrodando.com/imagenes/noti/abajo-on.gif";
	}
}

//mouse out en arriba y abajo de noticias
function outArrAbj(obj, id){
	obj.style.backgroundColor="#979B9D";
	if (id=="imgArr")
	{
		document.getElementById(id).src = "http://www.estamosrodando.com/imagenes/noti/arriba-off.gif";
	}else{
		document.getElementById(id).src = "http://www.estamosrodando.com/imagenes/noti/abajo-off.gif";
	}
}
//mouse over en arriba y abajo de noticias
function overVerTodas(obj){
	obj.style.backgroundColor="#BFCECF";
}

//mouse out en arriba y abajo de noticias
function outVerTodas(obj){
	obj.style.backgroundColor="#CCCCCC";
}
function contieneProv(obj){
	if (obj.prvnc.value=="")
	{
		alert("Elija la provincia de la cual quiera realizar la busqueda.");
		obj.prvnc.focus();
		return false;
	}
	return true;
}
function abrirVentana(url){
	var pop = window.open(url);
	popup.focus();
}
function iniciarTiempo (num_preg, hw_tipo_juego, hw_id_partida, hw_categoria){
//	alert ("'"+num_preg+"', '"+hw_tipo_juego+"', '"+hw_id_partida+"', '"+hw_categoria+"'");
	valor_preg = 750;
	seg_preg = 15;
//	go('0');
	respondido = false;
	var t=setTimeout("cambiarCargPreg('"+num_preg+"', '"+hw_tipo_juego+"', '"+hw_id_partida+"', '"+hw_categoria+"')", 3000);
}
function ocultarId(id){
	if(ie){
		document.all[id].style.display='none';
	}else{
		if(n4){
			document.layers[id].display='none';
		}else{
			if(n6){
				document.getElementById(id).style.display='none';
			}
		}
	}
}
function mostrarId(id){
	if(ie){
		document.all[id].style.display='inline';
	}else{
		if(n4){
			document.layers[id].display='inline';
		}else{
			if(n6){
				document.getElementById(id).style.display='inline';
			}
		}
	}
}
function cambiarCargPreg(num_preg, hw_tipo_juego, hw_id_partida, hw_categoria){
	ocultarId("cargando");
	mostrarId("pregresp");
//	alert ("Cambiado");
	var t=setTimeout("setValores('"+num_preg+"', '"+hw_tipo_juego+"', '"+hw_id_partida+"', '"+hw_categoria+"')", 1000);
}
function setValores(num_preg, hw_tipo_juego, hw_id_partida, hw_categoria){
	valor_preg = valor_preg - 50;
	seg_preg = seg_preg - 1;
	var nomSpan="";
	if (valor_preg<0){	valor_preg = 0;	}
	if (seg_preg<0){	seg_preg = 0;	}
	nomSpan="valor_preg";
	
	if (seg_preg==14)
	{
		go(0);
		playmovie();
	}
	if(ie){
		document.all[nomSpan].innerHTML=valor_preg;
//		document.all["ObjBarraTiempo"].Play();
	}else{
		if(n4){
			document.layers[nomSpan].innerHTML=valor_preg;
//			document.layers["ObjBarraTiempo"].Play();
		}else{
			if(n6){      
				document.getElementById(nomSpan).innerHTML=valor_preg;
//				document.getElementById("ObjBarraTiempo").Play();
			}
		}
	}
	
	nomSpan="seg_preg";
	if(ie){
		document.all[nomSpan].innerHTML=seg_preg;
	}else{
		if(n4){
			document.layers[nomSpan].innerHTML=seg_preg;
		}else{
			if(n6){      
				document.getElementById(nomSpan).innerHTML=seg_preg;
			}
		}
	}
	if (seg_preg==15)
	{
		go(15-seg_preg)
	}
	if (seg_preg==0)
	{
//		var t=setTimeout("enviarResp(0, "+num_preg+", "+hw_tipo_juego+", "+hw_id_partida+", "+hw_categoria+")", 1000);
		stopmovie();
		enviarResp('0', num_preg, hw_tipo_juego, hw_id_partida, hw_categoria);
	}else{
		if (respondido)
		{
			stopmovie();
		}else{
			var t=setTimeout("setValores('"+num_preg+"', '"+hw_tipo_juego+"', '"+hw_id_partida+"', '"+hw_categoria+"')", 1000);
		}
	}
}
function login(frm){
	if (frm.ch_olvidar.checked)
	{
		if (isWhitespace(frm.email.value))
		{
			alert("Escriba el e-mail con el que se registró.");
			frm.email.select();
			frm.email.focus();
			return;
		}
		if (!validarEmail(frm.email.value))
		{
			alert("Escriba su e-mail correctamente.");
			frm.email.select();
			frm.email.focus();
			return;
		}
		recordarContrasena(frm);
	}else{
		if (isWhitespace(frm.usuario.value))
		{
			alert("Escriba el nombre de usuario.");
			frm.usuario.select();
			frm.usuario.focus();
			return;
		}
        if (isWhitespace(frm.password.value))
        {
            alert("Escriba el e-mail.");
            frm.password.select();
            frm.password.focus();
            return;
        }
        /*if (isWhitespace(frm.password.value))
        {
            alert("Escriba el password.");
            frm.password.select();
            frm.password.focus();
            return;
        }*/
		loginearse(frm);
	}
}
function loginMini(frm){
	if (frm.ch_olvidar.checked)
	{
		if (isWhitespace(frm.email.value))
		{
			alert("Escriba el e-mail con el que se registró.");
			frm.email.select();
			frm.email.focus();
			return;
		}
		if (!validarEmail(frm.email.value))
		{
			alert("Escriba su e-mail correctamente.");
			frm.email.select();
			frm.email.focus();
			return;
		}
		recordarContrasena(frm);
	}else{
		if (isWhitespace(frm.usuario.value))
		{
			alert("Escriba el nombre de usuario.");
			frm.usuario.select();
			frm.usuario.focus();
			return;
		}
		if (isWhitespace(frm.password.value))
		{
			alert("Escriba el password.");
			frm.password.select();
			frm.password.focus();
			return;
		}
		loginearseMini(frm);
	}
}
function cambiarUsuEmail(obj, frm){
	if (obj.checked)
	{
		document.getElementById("email").style.display = "inline";
		document.getElementById("usupass").style.display = "none";
		document.getElementById("spanLogin").value = "";
		document.getElementById("imgEntrar").scr = "http://www.estamosrodando.com/imagenes/jueg/trivial/regi/enviar.jpg";
		frm.email.value = "";
	}else{
		document.getElementById("email").style.display = "none";
		document.getElementById("usupass").style.display = "inline";
		document.getElementById("spanLogin").value = "";
		document.getElementById("imgEntrar").scr = "http://www.estamosrodando.com/imagenes/jueg/trivial/regi/entrar.jpg";
		frm.usuario.value = "";
		frm.password.value = "";
	}
	mostrarTexto("spanLogin", "&nbsp;");
}
function mostrarTexto(id, texto){
	if(ie){
		document.all[id].innerHTML=texto;
	}else{
		if(n4){
			document.layers[id].innerHTML=texto;
		}else{
			if(n6){      
				document.getElementById(id).innerHTML=texto;
			}
		}
	}
}
function jugar(hw_tipo_juego){
	var str_tipo = hw_tipo_juego;
	str_tipo = str_tipo.replace("estamos-rodando", "trivial-estamos-rodando");
	var url_loc = "http://juegos.estamosrodando.com/trivial/" + str_tipo + "/";
	parent.location.href = url_loc;
}
function jugarMini(hw_tipo_juego){
	var str_tipo = hw_tipo_juego;
	str_tipo = str_tipo.replace("estamos-rodando", "trivial-estamos-rodando");
	var url_loc = "http://juegos.estamosrodando.com/minitrivial/" + str_tipo + "/";
	parent.location.href = url_loc;
}
function mostrarFlash(ìd, banner, w, h){
	document.write('<object id="'+id+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" name="movie" id="movie" width="'+w+'" height="'+h+'">');
	document.write('<param name="movie" value="http://estamosrodando.com/media/video/'+banner+'?clickTag=http://estamosrodando.com/media/video/" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed name="movie" src="http://estamosrodando.com/media/video/'+banner+'?clickTag=http://estamosrodando.com/media/video/" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" quality="high" scale="exactfit" swliveconnect="true"  wmode="transparent" menu="false" />');
	document.write('</object>');
}
function cambiarContrasena(frm){
	if (isWhitespace(frm.usu.value))
	{
		alert("Escribe el nombre de usuario.");
		frm.usu.select();
		frm.usu.focus();
		return false;
	}
	if (isWhitespace(frm.pw.value))
	{
		alert("Escribe la contraseña.");
		frm.pw.select();
		frm.pw.focus();
		return false;
	}
	if (isWhitespace(frm.pw_nueva1.value))
	{
		alert("Escribe la nueva contraseña.");
		frm.pw_nueva1.select();
		frm.pw_nueva1.focus();
		return false;
	}
	if (isWhitespace(frm.pw_nueva2.value))
	{
		alert("Repite la nueva contraseña.");
		frm.pw_nueva2.select();
		frm.pw_nueva2.focus();
		return false;
	}
	if (frm.pw_nueva1.value!=frm.pw_nueva2.value)
	{
		frm.pw_nueva1.value="";
		frm.pw_nueva2.value="";
		alert("La nueva contraseña no se ha repetido correctamente.");
		frm.pw_nueva1.select();
		frm.pw_nueva1.focus();
		return false;
	}
	getCambiaContrasena(frm);
	return false;
}
function mostrarFinRonda(num_preg, tipo, part, cat){
	
	document.getElementById("spanRespuesta").style.display = 'none';
	document.getElementById("spanFinRonda").style.display = 'inline';
	
//	alert ("Fin de Ronda: " + "'"+num_preg+"', '"+tipo+"', '"+part+"', '"+cat+"'");
	var t=setTimeout("sigPreg('"+num_preg+"', '"+tipo+"', '"+part+"', '"+cat+"')", 3000);
}
function login2(frm){
	if (isWhitespace(frm.u_web.value))
	{
		alert("Escriba el nombre de usuario.");
		frm.u_web.select();
		frm.u_web.focus();
		return;
	}
	if (isWhitespace(frm.pw_web.value))
	{
		alert("Escriba el password.");
		frm.pw_web.select();
		frm.pw_web.focus();
		return;
	}
	frm.submit();
}

var movieName = "testcommand";

function thisMovie(movieName) {
	if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {
//    return theMovie.PercentLoaded() == 100;
		return true;
  } else {
    return false;
  }
}


function playmovie() {
//  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).Play();
//  }
}

function stopmovie() {

//  if (movieIsLoaded(thisMovie(movieName))) {
    thisMovie(movieName).StopPlay();
//  }
}
function go(theFrame) {
//	alert(theFrame);
  if (movieIsLoaded(thisMovie(movieName))) {
//	alert (movieName);
    thisMovie(movieName).GotoFrame(theFrame);
  }
}
function bajaBoletines(frm){
	if (isWhitespace(frm.usu.value))
	{
		alert("Escriba el nombre de usuario.");
		frm.usu.select();
		frm.usu.focus();
		return;
	}
	if (isWhitespace(frm.pw.value))
	{
		alert("Escriba el password.");
		frm.pw.select();
		frm.pw.focus();
		return;
	}
	if (frm.opt.value!="1")
	{
		alert("Tienes que marcar la casilla para poder darte de baja en el servicio boletines.");
		frm.pw.focus();
		return;
	}
	frm.submit();
}
function envMailBol(frm){
	if (isWhitespace(frm.mai.value))
	{
		alert("Escriba el e-mail.");
		frm.mai.select();
		frm.mai.focus();
		return;
	}
	frm.submit();
}
function bajaBoletines2(frm){
	if (isWhitespace(frm.cod_can.value))
	{
		alert("Escriba el código de cancelación.");
		frm.cod_can.select();
		frm.cod_can.focus();
		return;
	}
	if (frm.opt.value!="1")
	{
		alert("Tienes que marcar la casilla para poder darte de baja en el servicio boletines.");
		frm.pw.focus();
		return;
	}
	frm.submit();
}
function bajaUsuarios(frm){
	if (isWhitespace(frm.usu.value))
	{
		alert("Escriba el nombre de usuario.");
		frm.usu.select();
		frm.usu.focus();
		return;
	}
	if (isWhitespace(frm.pw.value))
	{
		alert("Escriba el password.");
		frm.pw.select();
		frm.pw.focus();
		return;
	}
	if (frm.opt.value!="1")
	{
		alert("Tienes que marcar la casilla para poder darte de baja como usuario de Estamos Rodando.");
		frm.pw.focus();
		return;
	}
	frm.submit();
}

function PNG_loader() {
   for(var i=0; i<document.images.length; i++) {
      var img = document.images[i];
      var imgName = img.src.toUpperCase();
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
         var imgID = (img.id) ? "id='" + img.id + "' " : "";
         var imgClass = (img.className) ? "class='" + img.className + "' " : "";
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
         var imgStyle = "display:inline-block;" + img.style.cssText;
         if (img.align == "left") imgStyle += "float:left;";
         if (img.align == "right") imgStyle += "float:right;";
         if (img.parentElement.href) imgStyle += "cursor:hand;";
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
         img.outerHTML = strNewHTML;
         i--;
      }
   }
}
function mostrarOcultar(id){
//	alert(document.getElementById('espe_usu_'+id).style.display);
	var st = document.getElementById('espe_usu_'+id).style.display;
//	alert (st);
	if (st=="none")
	{
		if(ie){
			document.all["espe_usu_"+id].style.display='inline';
		}else{
			if(n4){
				document.layers["espe_usu_"+id].display='inline';
			}else{
				if(n6){      
					document.getElementById("espe_usu_"+id).style.display='inline';
				}
			}
		}
//		document.getElementById("espe_usu_"+id).style.display = 'in-line';
		if ((document.getElementById('imgFlechaAbrir'+id))&&(document.getElementById('imgFlechaCerrar'+id)))
		{
			document.getElementById('imgFlechaAbrir'+id).style.display = "none";
			document.getElementById('imgFlechaCerrar'+id).style.display = "inline";
		}
	}else{
		if(ie){
			document.all["espe_usu_"+id].style.display='none';
		}else{
			if(n4){
				document.layers["espe_usu_"+id].display='none';
			}else{
				if(n6){      
					document.getElementById("espe_usu_"+id).style.display='none';
				}
			}
		}
//		document.getElementById("espe_usu_"+id).style.display = 'none';
		if ((document.getElementById('imgFlechaAbrir'+id))&&(document.getElementById('imgFlechaCerrar'+id)))
		{
			document.getElementById('imgFlechaAbrir'+id).style.display = "inline";
			document.getElementById('imgFlechaCerrar'+id).style.display = "none";
		}
	}
}
function mostrarBannerJuego(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" name="movie" id="movie" width="190" height="150" >');
	document.write('<param name="movie" value="http://www.estamosrodando.com/media/video/banner-trivial.swf?clickTag=http://juegos.estamosrodando.com/trivial/" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed name="movie" src="http://www.estamosrodando.com/media/video/banner-trivial.swf?clickTag=http://juegos.estamosrodando.com/trivial/" width="190" height="150" type="application/x-shockwave-flash" quality="high" scale="exactfit" swliveconnect="true"  wmode="transparent" menu="false" />');
	document.write('</object>');
}
function setOptQuiniela(premio, id){
	if (document.getElementById("conf").value=="false"){
		alert ("Tienes que registrarte y confirmar el registro para poder participar en la quiniela de los Oscar");
		if (document.getElementById('ck_'+premio+'_'+id).checked==true){
			document.getElementById('ck_'+premio+'_'+id).checked = false;
		}
	}else{
		if (document.getElementById(premio).value!=""){
		//alert (document.getElementById(premio).value);
		document.getElementById('ck_'+premio+'_'+document.getElementById(premio).value).checked = false;
		}
		//alert ('ck_opt_'+premio+'_'+id);
		//alert (document.getElementById('ck_opt_'+premio+'_'+id));
		if (document.getElementById('ck_'+premio+'_'+id).checked=="true"){
			document.getElementById(premio).value = id;
		}else{
			document.getElementById(premio).value = id;
		}
	}
}

var arr_cargos = new Array ();
var arr_cargosN = new Array ();
arr_cargos[0] = "7";
arr_cargos[1] = "41";
arr_cargos[2] = "13";
arr_cargos[3] = "12";
arr_cargos[4] = "14";
arr_cargos[5] = "10";
arr_cargos[6] = "3";
arr_cargos[7] = "156";
arr_cargos[8] = "158";
arr_cargos[9] = "4";
arr_cargos[10] = "162";
arr_cargos[11] = "159";
arr_cargos[12] = "293";
arr_cargos[13] = "240";
arr_cargos[14] = "37";
arr_cargos[15] = "8";
arr_cargos[16] = "299";
arr_cargos[17] = "44";
arr_cargos[18] = "464";
arr_cargos[19] = "483";
arr_cargos[20] = "54";
arr_cargos[21] = "256";
arr_cargos[22] = "305";
arr_cargos[23] = "48";
//arr_cargos[24] = "35";
arr_cargosN[0] = "Mejor Película";
arr_cargosN[1] = "Mejor Actor";
arr_cargosN[2] = "Mejor Actriz";
arr_cargosN[3] = "Mejor Actor de reparto";
arr_cargosN[4] = "Mejor Actriz de reparto";
arr_cargosN[5] = "Mejor Director";
arr_cargosN[6] = "Mejor Guión Original";
arr_cargosN[7] = "Mejor Guión Adaptado";
arr_cargosN[8] = "Mejor Fotografía";
arr_cargosN[9] = "Mejor Montaje";
arr_cargosN[10] = "Mejor Dirección Artística";
arr_cargosN[11] = "Mejor Vestuario";
arr_cargosN[12] = "Mejor Maquillaje";
arr_cargosN[13] = "Mejor Banda Sonora Original";
arr_cargosN[14] = "Mejor Canción Original";
arr_cargosN[15] = "Mejor Sonido";
arr_cargosN[16] = "Mejor Edición Sonora";
arr_cargosN[17] = "Mejores Efectos Especiales";
arr_cargosN[18] = "Mejor Película Animada";
arr_cargosN[19] = "Mejor Película Extranjera";
arr_cargosN[20] = "Mejor Documental";
arr_cargosN[21] = "Mejor Cortometraje en directo";
arr_cargosN[22] = "Mejor Cortometraje Animado";
arr_cargosN[23] = "Mejor Cortometraje Documental";
//arr_cargosN[24] = "Mejor Cortometraje Documental";
//arr_cargosN[24] = "Oscar Honorífico";
function enviarQuiniela(frm){
//  El ID es el ID de la tabla ESR_MOV_PREMIOS
  for (i=0;i<arr_cargos.length;i++)
  {
  	if (isWhitespace(document.getElementById(arr_cargos[i]).value))
  	{
  		alert("Falta apostar por " + arr_cargosN[i]);
  		document.getElementById(arr_cargos[i]).select();
  		document.getElementById(arr_cargos[i]).focus();
  		return;
  	}
  }
  getQuiniela (frm);
  return;
}


function inputFilling(evt, obj, div, hid) {
	var fill = document.getElementById(div);
	var obj=document.getElementById(obj);
	var elems = datos;
	var tecla = "";
	var res = obj.value;
	var borrar = false;
	// Como se modifica el imput, inicializamos el input hidden ID
	hid.value='';
	
	// Almaceno la tecla pulsada
	if (!ie) {
	  tecla = evt.which;
	} else {
	  tecla = evt.keyCode;
	}
	
	var texto;
	// Si la tecla que pulso es una
	// letra o un espacio, o el intro
	// o la tecla borrar, almaceno lo 
	// que debo buscar
	if (!String.fromCharCode(tecla).match(/(\w|\s)/) && 
			tecla != 8) {
		texto = res;
	}else if(tecla == 13){
		//Si pulsamos intro seleccionamos els texto /////////////////////////
		var n = posicionListaFilling;
		document.getElementById('tr'+obj.id+n).onmousedown();
	}else{
		texto = obj.value;
	}
	
	res = texto;
	
	// Si el texto es distinto de vacio
	// o se pulsa ARRIBA o ABAJO
	// hago llamada AJAX para que 
	// me devuelva la lista de palabras
	// que coinciden con lo que hay
	// escrito en la caja
	if ((texto != null && texto != "") 
		|| (tecla == 40 || tecla == 38)) {
		if ((tecla != 40 && tecla != 38)){
			cargaLista(evt, obj.id, div, texto, hid, res);
		}
	}
	
	// Según la letra que se pulse
	if (tecla == 37) { // Izquierda
		// No hago nada
	} else if (tecla == 38) { // Arriba
		// Subo la posicion en la
		// lista desplegable una posición
		if (posicionListaFilling > 0) {
			posicionListaFilling--;
		}
		// Corrijo la posición del scroll
		fill.scrollTop = posicionListaFilling*14;
	} else if (tecla == 39) { // Derecha
		// No hago nada
	} else if (tecla == 40) { // Abajo
		if (obj.value != "") {
			// Si no es la última palabra
			// de la lista
			if (posicionListaFilling < tamaLista-1) { 
				fill.scrollTop = posicionListaFilling*14;
				// Bajo la posición de la lista
				posicionListaFilling++;
			}
				fill.scrollTop = posicionListaFilling*14;
		}
	} else if (tecla == 8) { // Borrar <-
		// Se sube la lista del todo
		posicionListaFilling = 0;
		// Se permite borrar
		borrar = true;
	} else if (tecla == 13) { // Intro
		// Deseleccionamos el texto
		if (obj.createTextRange) {
			var r = obj.createTextRange();
			r.moveStart("character", 
				obj.value.length+1);
			r.moveEnd("character", 
				obj.value.length+1);
			r.select();
		} else if (obj.setSelectionRange) {
			obj.setSelectionRange(
				obj.value.length+1, 
				obj.value.length+1);
		}
		// Ocultamos la lista
		fill.style.display = "none";
		// Ponemos el puntero de 
		// la lista arriba del todo
		posicionListaFilling = 0;
		// Controlamos el scroll
		fill.scrollTop = 0;
		return true;
	} else {
		// En otro caso que siga
		// escribiendo
		posicionListaFilling = 0;
		fill.scrollTop = 0;
	}	
	
	// Si no se ha borrado
	if (!borrar) {
		if (lista.length != 0) {
			// Seleccionamos la parte del texto
			// que corresponde a lo que aparece
			// en la primera posición de la lista
			// menos el texto que realmente hemos
			// escrito
			obj.value = lista[posicionListaFilling];
			if (obj.createTextRange) {
				var r = obj.createTextRange();
				r.moveStart("character", 
					texto.length);
				r.moveEnd("character", 
					lista[posicionListaFilling].length);
				r.select();
			} else if (obj.setSelectionRange) {
				obj.setSelectionRange(
					texto.length, 
					lista[posicionListaFilling].length);
			}
		}
	}
	return true;
}

function cargaLista(evt, obj, div, txt, hid, res) {
	ajax = ajaxobj();
	switch (div)
	{
		case 'peliculas':
			ajax.open("GET", "/inc/lib/core/cine/peli.lib.php?texto="+txt, true);
			break;
		case 'pers-rank':
			ajax.open("GET", "/inc/lib/core/rank/pers.lib.php?texto="+txt, true);
			break;
		default:
			ajax.open("GET", "/inc/lib/core/cine/"+div+".lib.php?texto="+txt, true);
			break;
	
	}
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			var datos = ajax.responseXML;
			var elementos = datos.getElementsByTagName("elemento");
			var idelementos = datos.getElementsByTagName("idelemento");
			var lista = new Array();
			if (elementos) {
				for (var i=0; i<elementos.length; i++) {
					lista[lista.length] = elementos[i].firstChild.data;
				}
			}
			var listaId = new Array();
			if (idelementos) {
				for (var i=0; i<idelementos.length; i++) {
					listaId[listaId.length] = idelementos[i].firstChild.data;
				}
				tamaLista = lista.length;
			}
			escribeLista(obj, div, lista, listaId, hid, res);
		}
	}
	ajax.send(null);
}

function escribeLista(obj, div, lista, listaids, hid, res) {
	var html = "";
	var fill = document.getElementById(div);
	obj = document.getElementById(obj);
	if (lista.length == 0) {
		// Si la lista es vacia no la mostramos
		fill.style.display = "none";
	} else {
		// Creamos una tabla con 
		// todos los elementos encontrados
		fill.style.display = "block";
		var html='<table cellspacing="0" '+
			'cellpadding="0" border="0" width="100%">';
		for (var i=0; i<lista.length; i++) {
			if(i%2!=0){var bgc='class="tr_2"';}
			else{var bgc='';}
			html += '<tr id="tr'+obj.id+i+
				'" '+(posicionListaFilling == i? 
					' class="fill" ': bgc)+
				' onmouseover="seleccionaFilling(\'tr'+obj.id+'\', '+i+')" onmousedown="seleccionaTextoFilling(\'tr'+
				obj.id+'\', \''+i+'\', \''+listaids[i]+'\', \''+div+'\', \''+hid.id+'\', \''+obj.id+'\', \''+res+'\')">';
			html += '<td class="td_auto" onmouseover="this.style.color=\'#ffffff\';" onmouseout="this.style.color=\'#333333\';">'+lista[i]+	'</td></tr>';
		}
		html += '</table>';
	}

	// Escribimos la lista
	fill.innerHTML = html;
}
	// Introduce el texto seleccionado
	function setInput(obj, hid, fill, res, val) {
		obj.value = res;
		hid=document.getElementById(hid);
		hid.value = val;
		document.getElementById(fill).style.display = "none";
		posicionListaFilling = 0;
		if (fill=="pers-rank"){
			mostrarCargo(val);
		}
	}
	
	function mostrarCargo(id){
		document.getElementById("spanVac").style.display = "none";
		document.getElementById("spanDir").style.display = "none";
		document.getElementById("spanAct").style.display = "none";
		document.getElementById("spanDirAct").style.display = "none";
		
		document.getElementById("sltDir").disabled = true;
		document.getElementById("sltAct").disabled = true;
		document.getElementById("sltDirAct").disabled = true;
		
		ajax = ajaxobj();
		ajax.open("GET", "/inc/lib/core/rank/carg.lib.php?pers="+id, true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				var datos = ajax.responseText;
				switch (datos)
				{
					case "2":
						document.getElementById("spanDir").style.display = "inline";
						document.getElementById("sltDir").disabled = false;
						document.getElementById("slt").value = "2";
						break;
					case "4":
						document.getElementById("spanAct").style.display = "inline";
						document.getElementById("sltAct").disabled = false;
						document.getElementById("slt").value = "4";
						break;
					case "6":
						document.getElementById("spanDirAct").style.display = "inline";
						document.getElementById("sltDirAct").disabled = false;
						document.getElementById("slt").value = "6";
						break;
					default:
						document.getElementById("spanVac").style.display = "inline";
						document.getElementById("slt").value = "0";
						break;
				}
			}
		}
		ajax.send(null);
	}
	
	// Cambia el estilo de
	// la palabra seleccionada
	// de la lista
	function seleccionaFilling(id, n){
		document.getElementById(id + 
			n).className = "fill";
		if(posicionListaFilling%2!=0){
			document.getElementById(id + posicionListaFilling).className = "tr_2";
			posicionListaFilling = n;
		}else{
			document.getElementById(id + posicionListaFilling).className = "";
			posicionListaFilling = n;
		}
	}
  
	// Pasa el texto del filling a la caja
	function seleccionaTextoFilling (id, n, val, div, hid, obj, res) {
		obj=document.getElementById(obj);
		res = document.getElementById(id + 
			n).firstChild.innerHTML;1
		posicionListaFilling = 0;
		setInput(obj, hid, div, res, val);
	}
	
	function printBannerTV(){
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" name="movie" id="movie" width="120" height="240" >');
		document.write('<param name="movie" value="http://www.estamosrodando.com/swf/banner_tv.swf?clickTag=http://www.estamosrodando.tv/" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="menu" value="false" />');
		document.write('<param name="wmode" value="transparent">');
		document.write('<embed name="movie" src="http://www.estamosrodando.com/swf/banner_tv.swf?clickTag=http://www.estamosrodando.tv/" width="120" height="240" type="application/x-shockwave-flash" quality="high" scale="exactfit" swliveconnect="true"  wmode="transparent" menu="false" />');
		document.write('</object>');
	}
	function enviarMail(frm){
		if (isWhitespace(frm.nom.value))
		{
			alert("Escribe tu nombre.");
			frm.nom.select();
			frm.nom.focus();
			return false;
		}
		if (isWhitespace(frm.mai.value))
		{
			alert("Escribe tu e-mail.");
			frm.mai.select();
			frm.mai.focus();
			return false;
		}
		enviarRegistro2 (frm);
		return false;
	}
	
//Creamos el Objeto AJAX
//para la ejecución de procesos AJAX
function ajaxobj() {
	try {
		_ajaxobj = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			_ajaxobj = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			_ajaxobj = false;
		}
	}
	if (!_ajaxobj && typeof XMLHttpRequest!='undefined') {
		_ajaxobj = new XMLHttpRequest();
	}
	return _ajaxobj;
}

var elementoSeleccionado = -1;
var sugerencias = null;
var cacheSugerencias = {};
var cacheSugerencias_id = {};

Array.prototype.formateaLista = function(sug_id) {
	document.frm_buscador.gnr.style.visibility = "hidden";
	document.frm_buscador.sltDir.style.visibility = "hidden";
	document.frm_buscador.sltAct.style.visibility = "hidden";
	document.frm_buscador.sltDirAct.style.visibility = "hidden";
	codigoHtml = "<table width=\"175\" cellpadding=\"3\" cellspacing=\"0\" style=\"border:1px solid #666;cursor:pointer;\">";
	for(var i=0; i<this.length; i++) {
		if(i == elementoSeleccionado) {
			codigoHtml += "<tr><td style=\"font-family:arial,helvetica;font-size:11px;background-color:#333333;color:#FFFFFF;font-size:12px;padding-left:5px;\"> "+this[i]+"</td></tr>";
		}
		else {
			codigoHtml += "<tr><td style=\"background-color:#FFF;font-size:12px;padding-left:5px;\" onMouseOver=\"limpia_over();this.style.backgroundColor='#333333';this.style.color='#FFFFFF';this.style.font='normal normal 12px arial,helvetica';\" onMouseOut=\"this.style.backgroundColor='#ffffff';this.style.color='#333333';this.style.font='normal normal 12px arial,helvetica';\" onclick=\"selecciona_r('"+i+"', "+sug_id+");\"> "+this[i]+"</td></tr>";
		}
	}
	codigoHtml += "</table>";
	return codigoHtml;
}
	
function selecciona_r(ciudad, s_id){
	elementoSeleccionado = ciudad;
	seleccionaElemento(s_id);
	borraLista();
}

function noenter(obj,e) {
	opc = true;
	tecla = (document.all) ? e.keyCode : e.which;
	
	if (tecla == 13){
		opc = false;
	}

	return opc;
}

function seleccionaElemento(s_id){
	if(sugerencias[elementoSeleccionado]) {
		document.frm_buscador.gnr.style.visibility = "visible";
		document.frm_buscador.sltDir.style.visibility = "visible";
		document.frm_buscador.sltAct.style.visibility = "visible";
		document.frm_buscador.sltDirAct.style.visibility = "visible";
		document.getElementById("id_img_busc").style.visibility = "visible";
		//reemplazamos "&ntilde;" por "Ñ"
		tmp = sugerencias[elementoSeleccionado];
		tmp2 = sugerencias_id[elementoSeleccionado];
		document.frm_buscador.search.value = tmp;
		document.frm_buscador.hpers.value = tmp2;
		mostrarCargo(tmp2);
		//document.oForm4.action = "http://" + document.oForm.nombre_ciudad.value + ".callejero.net/tiempo/";
		//document.oForm.submit();
//		setInput(obj, hid, div, res, val);
		/*obj.value = res;
		hid=document.getElementById(hid);
		hid.value = val;
		document.getElementById(fill).style.display = "none";
		mostrarCargo(val);*/
	}
}

function autocompleta() {
	var elEvento = arguments[0] || window.event;
	var tecla = elEvento.keyCode;
		if(tecla == 40) { // Flecha Abajo
			
			if(elementoSeleccionado+1 < sugerencias.length) {
				elementoSeleccionado++;
			}
			muestraSugerencias();

		}else if(tecla == 38) { // Flecha Arriba
		
			if(elementoSeleccionado > 0) {
				elementoSeleccionado--;
			}
			muestraSugerencias();

		}
		else if(tecla == 13) { // ENTER o Intro
			seleccionaElemento();
			borraLista();
			
		}else{
			var search = document.frm_buscador.search.value;

			// Si es la tecla de borrado y el texto es vacío, ocultar la lista
			if(tecla == 8 && search == "") {
				borraLista();
				return;
			}
			
			//if(cacheSugerencias[search] == null) {

				var date = new Date();
				var arr = new Array();
				var timestamp = date.getTime();
				var parameters = "texto=" + search+ "&time=" + timestamp;
				ajax = ajaxobj();
//				ajax.open("POST", "/inc/ajax/alim/buscar.php");
				ajax.open("POST", "/inc/lib/core/rank/pers.lib.php");
				ajax.onreadystatechange=function(){
					if (ajax.readyState==4){
						var datos = ajax.responseXML;
						var elementos = datos.getElementsByTagName("elemento");
						var idelementos = datos.getElementsByTagName("idelemento");
						var lista = new Array();
						if (elementos) {
							for (var i=0; i<elementos.length; i++) {
								lista[lista.length] = elementos[i].firstChild.data;
							}
						}
						var listaId = new Array();
						if (idelementos) {
							for (var i=0; i<idelementos.length; i++) {
								listaId[listaId.length] = idelementos[i].firstChild.data;
							}
							tamaLista = lista.length;
						}
//						sugerencias = Array(lista, listaId);
						sugerencias = lista;
						sugerencias_id = listaId;
						//sugerencias = ajax.responseText;
						//sugerencias = eval('('+ajax.responseText+')');
						//if(sugerencias.length == 0) {
						if (tamaLista == 0){
							sinResultados();
						}else {
							cacheSugerencias[search] = sugerencias;
							cacheSugerencias_id[search] = sugerencias_id;
							actualizaSugerencias();
						} 
					}
				}
				ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
				ajax.send(parameters);
			/*}else{
				sugerencias = cacheSugerencias[search];
				//alert("2");
				actualizaSugerencias(sugerencias);
			}*/
				
		}
}
function muestraSugerencias() {
	var zonaSugerencias = document.getElementById("sugerencias");
	//alert("AQUI - "+document.getElementById("sugerencias")+" "+zonaSugerencias);
	zonaSugerencias.innerHTML = sugerencias.formateaLista(sugerencias_id);
	zonaSugerencias.style.display = 'block';
}

function borraLista() {
	document.getElementById("sugerencias").innerHTML = "";
	document.getElementById("sugerencias").style.display = "none";
}
function sinResultados() {
	document.frm_buscador.gnr.style.visibility = "hidden";
	document.frm_buscador.sltDir.style.visibility = "hidden";
	document.frm_buscador.sltAct.style.visibility = "hidden";
	document.frm_buscador.sltDirAct.style.visibility = "hidden";
	document.getElementById("id_img_busc").style.visibility = "hidden";
	
	codigoHtml = "<table width=\"310\" cellpadding=\"3\" cellspacing=\"0\" style=\"border:1px solid #666;cursor:pointer;\">";
	codigoHtml += "<tr><td style=\"font-size:12px;background-color:#333333;color:#FFFFFF;padding-left:5px; \">No existen personas para la búsqueda seleccionada</td></tr>";
	codigoHtml += "</table>";
	document.getElementById("sugerencias").innerHTML = codigoHtml;
	document.getElementById("sugerencias").style.display = "block";
}
function actualizaSugerencias() {
	elementoSeleccionado = -1;
	muestraSugerencias();
}

function limpia_over(){
	if(elementoSeleccionado != -1){
		elementoSeleccionado = -1;
		muestraSugerencias();

		//alert(elementoSeleccionado)
	}
	
}

function valSearch(obj){
	var date = new Date();
	var timestamp = date.getTime();
	var search=obj.search.value;
	var parameters = "search=" + search+ "&time=" + timestamp;
	ajax = ajaxobj();
	ajax.open("POST", "/inc/ajax/alim/redirect.php");
	ajax.onreadystatechange=function(){
		if (ajax.readyState==4){
			//sugerencias = ajax.responseText;
			sugerencias = eval('('+ajax.responseText+')');
			if(sugerencias.length == 0) {
				sinResultados();
			}else {
				document.location.href=sugerencias[0];
				return true;
				//cacheSugerencias[search] = sugerencias;
				//actualizaSugerencias();
			} 
		}
	}
	ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
	ajax.send(parameters);

	return false;
}
function displaySumario(id, opt){
	if (opt=="ocultar"){
		document.getElementById(id).style.display = "none";
	}else if (opt=="mostrar"){
		document.getElementById(id).style.display = "inline";
	}
}
function compMary(frm){
	if (isWhitespace(frm.ta_resp.value)){
		alert("Escribe tu respuesta.");
		frm.ta_resp.select();
		frm.ta_resp.focus();
		return false;
	}
	if (isWhitespace(frm.inp_usu.value)){
		alert("Escribe tu nombre de usuario.");
		frm.inp_usu.select();
		frm.inp_usu.focus();
		return false;
	}
	if (isWhitespace(frm.inp_mai.value)){
		alert("Escribe tu e-mail.");
		frm.inp_mai.select();
		frm.inp_mai.focus();
		return false;
	}
	if (!validarEmail(frm.inp_mai.value))
	{
		alert("Escriba su e-mail correctamente.");
		frm.inp_mai.select();
		frm.inp_mai.focus();
		return false;
	}
	return true;
}
function compBruno(frm){
	if (isWhitespace(frm.inp_usu.value)){
		alert("Escribe tu nombre de usuario.");
		frm.inp_usu.select();
		frm.inp_usu.focus();
		return false;
	}
	if (isWhitespace(frm.inp_mai.value)){
		alert("Escribe tu e-mail.");
		frm.inp_mai.select();
		frm.inp_mai.focus();
		return false;
	}
	if (!validarEmail(frm.inp_mai.value))
	{
		alert("Escriba su e-mail correctamente.");
		frm.inp_mai.select();
		frm.inp_mai.focus();
		return false;
	}
	return true;
}
function compNinjas(frm){
	if (isWhitespace(frm.plataforma.value)){
		alert("Elige la plataforma.");
//		frm.plataforma.select();
		frm.plataforma.focus();
		return false;
	}
	if (isWhitespace(frm.inp_usu.value)){
		alert("Escribe tu nombre de usuario.");
		frm.inp_usu.select();
		frm.inp_usu.focus();
		return false;
	}
	if (isWhitespace(frm.inp_mai.value)){
		alert("Escribe tu e-mail.");
		frm.inp_mai.select();
		frm.inp_mai.focus();
		return false;
	}
	if (!validarEmail(frm.inp_mai.value))
	{
		alert("Escriba su e-mail correctamente.");
		frm.inp_mai.select();
		frm.inp_mai.focus();
		return false;
	}
	return true;
}

function compRec(frm){
	if (isWhitespace(frm.inp_usu.value)){
		alert("Escribe tu nombre de usuario.");
		frm.inp_usu.select();
		frm.inp_usu.focus();
		return false;
	}
	if (isWhitespace(frm.inp_mai.value)){
		alert("Escribe tu e-mail.");
		frm.inp_mai.select();
		frm.inp_mai.focus();
		return false;
	}
	if (!validarEmail(frm.inp_mai.value))
	{
		alert("Escriba su e-mail correctamente.");
		frm.inp_mai.select();
		frm.inp_mai.focus();
		return false;
	}
	return true;
}

function recordarContrasenaConc(frm1, frm2){
	if (isWhitespace(frm2.inp_mai.value)){
		alert("Escribe tu e-mail.");
		frm2.inp_mai.select();
		frm2.inp_mai.focus();
		return ;
	}
	if (!validarEmail(frm2.inp_mai.value))
	{
		alert("Escriba su e-mail correctamente.");
		frm2.inp_mai.select();
		frm2.inp_mai.focus();
		return ;
	}
	recordarContrasena(frm1);
/*	var poststr = "email="+frm.email.value;
	nombreSpan = "spanLogin";
	makePOSTRequest("/inc/ajax/comn/comn-0011.ajax.php", poststr);*/
}
function recordarContrasenaComp (frm){
	if (isWhitespace(frm.email.value))
	{
		alert("Escriba el e-mail con el que se registró.");
		frm.email.select();
		frm.email.focus();
		return;
	}
	if (!validarEmail(frm.email.value))
	{
		alert("Escriba su e-mail correctamente.");
		frm.email.select();
		frm.email.focus();
		return;
	}
		if(ie){    
			document.all['spanLogin'].innerHTML='Enviando...';
		}else{
			if(n4){
				document.layers['spanLogin'].innerHTML='Enviando...';
			}else{
				if(n6){      
					document.getElementById('spanLogin').innerHTML='Enviando...';
				}
			}
		}
	
	recordarContrasena(frm, "12");
}

function abrirPopEnviar (url){
    document.getElementById('idframePop').style.height = "600px";
    document.getElementById('idframePop').src = url;
    document.getElementById('intersst1').style.display='';
    document.getElementById('intersst2').style.display='';
}