var hostTmp="http://www.dietas.net";
var whitespace = " \t\n\r";
var reWhitespace = /^\s+$/

/**
 * 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 fckFilter(stripped){
	stripped = stripped.replace(/&nbsp;/g, "");
	stripped = stripped.replace(/&amp;/g, "and");
	stripped = stripped.replace(/&/g, "and");
	return stripped;
}

function overMenu(obj, act, canal){
	obj.style.cursor="pointer";
	if (act=="")
	{
		var color="";
		if (canal==1){color = "#626A4E";
		}else if (canal==2){color = "#97673C";
		}else if (canal==3){color = "#938342";
		}else if (canal==4){color = "#636363";
		}else if (canal==5){color = "#626A4E";}

		obj.style.backgroundColor = color;
	}
}

function outMenu(obj, act, canal){
	if (act!="on")
	{
		var color="";
		if (canal==1){color = "#8E9A73";
		}else if (canal==2){color = "#CA9768";
		}else if (canal==3){color = "#BEAC66";
		}else if (canal==4){color = "#939393";
		}else if (canal==5){color = "#8E9A73";}
		obj.style.backgroundColor = color;
	}
}

function comentarArt(){
	idArt=document.articulo.id.value;
	canal=document.articulo.canal.value;
	ids=document.articulo.ids.value;
	var url=hostTmp+"/pop/comentarios/" + canal + "/comentar-" + idArt + "-" + ids + ".html";
	var popup=window.open(url,"high","width=450,height=420,top=247,left=152,resizable=yes,scrollbars=no");
	popup.focus();
}
function addFavoritos(url, desc){
	if (window.sidebar&&window.sidebar.addPanel) 
		window.sidebar.addPanel(desc,url,""); 
	else 
		window.external.AddFavorite(url,desc) ;
/*	if (document.all){
		window.external.AddFavorite(url, desc);
	}*/
}
function enviarArt(ids){
	idArt=document.articulo.id.value;
	canal=document.articulo.canal.value;
//	if (ids=="")
//	{
		var url=hostTmp+"/pop/recomendar/" + canal + "/recomendar-" + idArt + "-" +	document.articulo.ids.value + ".html";
//	}else{
//		var url=hostTmp+"/pop/recomendar/" + canal + "/recomendar-" + idArt + "-" + ids + ".html";
//	}
	var popup=window.open(url,"high","width=450,height=500,top=247,left=152,resizable=yes,scrollbars=no");
	popup.focus();
}
function imprimirArt(){
	idArt=document.articulo.id.value;
	canal=document.articulo.canal.value;
	var url=hostTmp+"/pop/imprimir/" + canal + "/imprimir-" + idArt + ".html";
	var popup=window.open(url,"high","width=680,top=247,left=152,resizable=yes,scrollbars=yes");
	popup.focus();
}
function mostrarComentarios(can, art, idArt){
	var url=hostTmp+"/pop/comentarios/" + can + "/" + art + "-" + idArt + ".html";
	var popup=window.open(url,"high","width=650,top=247,left=152,resizable=yes,scrollbars=yes");
	popup.focus();
}
function mostrarComentariosDe(urlPer){
	var url=hostTmp+"/pop/comentarios/comentado-por-" + urlPer + ".html";
	var popup=window.open(url,"high","width=650,top=247,left=152,resizable=yes,scrollbars=yes");
	popup.focus();
}
function abrirPopUp(url_popup, w, h){
	var url=hostTmp + "" + url_popup;
	var popup=window.open(url,"high","width=" + w + ",height=" + h + ",top=247,left=152,resizable=yes,scrollbars=no");
	popup.focus();
}

function comprobarFecha(dia, mes, ano){
	if (mes==2)
	{
		if (dia>29)
		{
			return false;
		}
	}
	if ((mes==4)||(mes==6)||(mes==9)||(mes==11))
	{
		if (dia>30)
		{
			return false;
		}
	}
	return true;
}

function enviarAmigo(frm, popup){
	if ((isWhitespace(frm.nombreOrg.value))||(frm.nombreOrg.value=="Tu Nombre"))
	{
		alert("Informa tu nombre.");
		frm.nombreOrg.select();
		frm.nombreOrg.focus();
		return;
	}
	if ((isWhitespace(frm.emailOrg.value))||(frm.emailOrg.value=="Tu E-mail"))
	{
		alert("Informa tu e-mail.");
		frm.emailOrg.select();
		frm.emailOrg.focus();
		return;
	}
	if (validarEmail(frm.emailOrg.value)==false)
	{
		alert("El e-mail es incorrecto.");
		frm.emailOrg.select();
		frm.emailOrg.focus();
		return;
	}
	if ((isWhitespace(frm.nombreDes.value))||(frm.nombreDes.value=="Su Nombre"))
	{
		alert("Informa el nombre de tu amigo/a.");
		frm.nombreDes.select();
		frm.nombreDes.focus();
		return;
	}
	if ((isWhitespace(frm.emailDes.value))||(frm.emailDes.value=="Su E-mail"))
	{
		alert("Informa el e-mail de tu amigo/a.");
		frm.emailDes.select();
		frm.emailDes.focus();
		return;
	}
	if (validarEmail(frm.emailDes.value)==false)
	{
		alert("El e-mail de su amigo/a es incorrecto.");
		frm.emailDes.select();
		frm.emailDes.focus();
		return;
	}
	nombreSpan = "spanEnviarAmigo";
//	result = '<img src="http://www.dietas.net/images/cargando.gif" />';
	result = 'Enviando...';
	if(ie){    
		document.all[nombreSpan].innerHTML=result;
	}else{
		if(n4){
			document.layers[nombreSpan].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById(nombreSpan).innerHTML=result;
			}
		}
	}
	if (popup==true)
	{
		frm.enviar_amigo.disabled=true;
	}
//	frm.enviar1.style.visibility=hidden;
//	frm.cerrar.style.visibility=normal;
	getEnviarAmigo(frm, popup);
}
function enviarComentario(frm, popup){
	if ((trimAll(frm.nombre.value)==""))
	{
		alert("Informa tu nombre.");
		frm.nombre.focus();
		return;
	}
	if (trimAll(frm.comentario.value)=="")
	{
		alert("Informa el comentario que quieras poner.");
		return;
	}
	nombreSpan = "spanEnviando";
	result = 'Enviando...';
	if(ie){    
		document.all[nombreSpan].innerHTML=result;
	}else{
		if(n4){
			document.layers[nombreSpan].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById(nombreSpan).innerHTML=result;
			}
		}
	}
	getEnviarComentario(frm);
}

function cambiarValidacion (color, valor, frm){
	switch (valor)
	{
		case '1':
			frm.puntuacion.value="1";
			document.getElementById('est1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est2').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('est3').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('est4').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('est5').src="/images/iconos/estrella_" + color + "_off.gif";
			break;
		case '2':
			frm.puntuacion.value="2";
			document.getElementById('est1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est3').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('est4').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('est5').src="/images/iconos/estrella_" + color + "_off.gif";
			break;
		case '3':
			frm.puntuacion.value="3";
			document.getElementById('est1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est3').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est4').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('est5').src="/images/iconos/estrella_" + color + "_off.gif";
			break;
		case '4':
			frm.puntuacion.value="4";
			document.getElementById('est1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est3').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est4').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est5').src="/images/iconos/estrella_" + color + "_off.gif";
			break;
		case '5':
			frm.puntuacion.value="5";
			document.getElementById('est1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est3').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est4').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est5').src="/images/iconos/estrella_" + color + "_on.gif";
			break;
		default:	
			frm.puntuacion.value="1";
			document.getElementById('est1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est3').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est4').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('est5').src="/images/iconos/estrella_" + color + "_on.gif";
	}
}

function cambiarValidacionArt (color, valor){
	switch (valor)
	{
		case '0':
			document.getElementById('estrella1').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella2').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella3').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella4').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella5').src="/images/iconos/estrella_" + color + "_off.gif";
			break;
		case '1':
			document.getElementById('estrella1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella2').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella3').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella4').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella5').src="/images/iconos/estrella_" + color + "_off.gif";
			break;
		case '2':
			document.getElementById('estrella1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella3').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella4').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella5').src="/images/iconos/estrella_" + color + "_off.gif";
			break;
		case '3':
			document.getElementById('estrella1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella3').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella4').src="/images/iconos/estrella_" + color + "_off.gif";
			document.getElementById('estrella5').src="/images/iconos/estrella_" + color + "_off.gif";
			break;
		case '4':
			document.getElementById('estrella1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella3').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella4').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella5').src="/images/iconos/estrella_" + color + "_off.gif";
			break;
		case '5':
			document.getElementById('estrella1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella3').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella4').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella5').src="/images/iconos/estrella_" + color + "_on.gif";
			break;
		default:	
			document.getElementById('estrella1').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella2').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella3').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella4').src="/images/iconos/estrella_" + color + "_on.gif";
			document.getElementById('estrella5').src="/images/iconos/estrella_" + color + "_on.gif";
	}
}

function comprobarBusqueda(frm){
	if (frm.palabra.value=="")
	{
		alert ("Informe la palabra a buscar.");
		frm.palabra.focus();
		return false;
	}
	frm.submit();
}
function comprobarBuscador(frm){
	if (isWhitespace(frm.buscar.value))
	{
		alert ("Informe la palabra a buscar.");
		frm.buscar.focus();
		return false;
	}
	frm.submit();
}
function comprobarRegistro(frm){
	if (frm.email.value=="")
	{
		alert ("Informe el e-mail.");
		frm.email.focus();
		return false;
	}
	if (validarEmail(frm.email.value)==false)
	{
		alert ("El e-mail es incorrecto.");
		frm.email.select();
		frm.email.focus();
		return false;
	}
	if (frm.pw.value=="")
	{
		alert ("Informe el pw.");
		frm.pw.focus();
		return false;
	}
	result = "Abriendo sesión...";
	if(ie){    
		document.all["enviar"].innerHTML=result;
		document.all["enviar"].style.visibility='visible';
	}else{
		if(n4){
			document.layers["enviar"].innerHTML=result;
			document.layers["enviar"].visibility='visible';
		}else{
			if(n6){      
				document.getElementById("enviar").innerHTML=result;
				document.getElementById("enviar").style.visibility='visible';
			}
		}
	}
	getRegistro(frm);
	return false;
}
function comprobarRegistro2(frm){
	if (frm.nick.value=="")
	{
		alert ("Informe el nick.");
		frm.nick.focus();
		return false;
	}
	if (frm.pw.value=="")
	{
		alert ("Informe el pw.");
		frm.pw.focus();
		return false;
	}
	result = "Abriendo sesión...";
	if(ie){    
		document.all["enviar"].innerHTML=result;
		document.all["enviar"].style.visibility='visible';
	}else{
		if(n4){
			document.layers["enviar"].innerHTML=result;
			document.layers["enviar"].visibility='visible';
		}else{
			if(n6){      
				document.getElementById("enviar").innerHTML=result;
				document.getElementById("enviar").style.visibility='visible';
			}
		}
	}
//	getRegistro2(frm);
//	return false;
	return true;
}
function comprobarRegistroPortada(frm){
	if (frm.nick.value=="")
	{
		alert ("Informe el nick.");
		frm.nick.focus();
		return false;
	}
	if (frm.pw.value=="")
	{
		alert ("Informe el pw.");
		frm.pw.focus();
		return false;
	}
	result = "Abriendo sesión...";
	if(ie){    
		document.all["enviar"].innerHTML=result;
		document.all["enviar"].style.visibility='visible';
	}else{
		if(n4){
			document.layers["enviar"].innerHTML=result;
			document.layers["enviar"].visibility='visible';
		}else{
			if(n6){      
				document.getElementById("enviar").innerHTML=result;
				document.getElementById("enviar").style.visibility='visible';
			}
		}
	}
//	getRegistroPortada(frm);
	return true;
}

function comprobarRegistroComent(frm){
	if (frm.email.value=="")
	{
		alert ("Informe el e-mail.");
		frm.email.focus();
		return;
	}
	if (validarEmail(frm.email.value)==false)
	{
		alert ("El e-mail es incorrecto.");
		frm.email.select();
		frm.email.focus();
		return;
	}
	if (frm.pw.value=="")
	{
		alert ("Informe el pw.");
		frm.pw.focus();
		return;
	}
	if(ie){    
		document.all["enviar"].style.visibility='visible';
	}else{
		if(n4){
			document.layers["enviar"].visibility='visible';
		}else{
			if(n6){      
				document.getElementById("enviar").style.visibility='visible';
			}
		}
	}
	getRegistroComent(frm);
	return;
}
function comprobarDatosRegistro(frm, opt){
	if (frm.nom.value=="")
	{
		alert ("Informa el nombre.");
		frm.nom.focus();
		return false;
	}
	if (frm.ape.value=="")
	{
		alert ("Informa los apellidos.");
		frm.ape.focus();
		return false;
	}
	if (frm.prov.value=="")
	{
		alert ("Informa la provincia.");
		frm.prov.focus();
		return false;
	}
	if (frm.pais.value=="")
	{
		alert ("Informa el pais.");
		frm.pais.focus();
		return false;
	}
	if (!comprobarFecha(frm.dia.value, frm.mes.value, frm.ano.value))
	{
		alert ("La fecha de nacimiento es incorrecta.");
		frm.dia.focus();
		return false;
	}
	if (frm.email.value=="")
	{
		alert ("Informa el e-mail.");
		frm.email.focus();
		return false;
	}
	if (validarEmail(frm.email.value)==false)
	{
		alert ("El e-mail es incorrecto.");
		frm.email.select();
		frm.email.focus();
		return false;
	}
	if (frm.pw.value=="")
	{
		alert ("Informa la contraseña.");
		frm.pw.focus();
		return false;
	}
	if (frm.pw2.value=="")
	{
		alert ("Confirma la contraseña.");
		frm.pw2.focus();
		return false;
	}
	if (frm.pw2.value!=frm.pw.value)
	{
		alert ("La confirmación de la contraseña no es correcta.");
		frm.pw2.select();
		frm.pw2.focus();
		return false;
	}
/*	if (frm.sexo.checked!="")
	{
		alert(frm.sexo.checked);
		alert(frm.sexo.value);
	}*/
//	result="<img src=\"http://localhost/images/cargando.gif\" />";
	result="Enviando...";
	if(ie){    
		document.all["spanDatosRegistro"].innerHTML=result;
	}else{
		if(n4){
			document.layers["spanDatosRegistro"].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById("spanDatosRegistro").innerHTML=result;
			}
		}
	}
	frm.enviar.disabled=true;
	getDatosRegistro(frm, opt);
	return false;
}
function comprobarDatosRegistro2(frm, opt){
	if (frm.nom.value=="")
	{
		alert ("Informa el nombre.");
		frm.nom.focus();
		return false;
	}
	if (frm.email.value=="")
	{
		alert ("Informa el e-mail.");
		frm.email.focus();
		return false;
	}
	if (validarEmail(frm.email.value)==false)
	{
		alert ("El e-mail es incorrecto.");
		frm.email.select();
		frm.email.focus();
		return false;
	}
	if (frm.nick.value=="")
	{
		alert ("Informa el nick.");
		frm.nick.focus();
		return false;
	}
	if (frm.pw.value=="")
	{
		alert ("Informa la contraseña.");
		frm.pw.focus();
		return false;
	}
	if (frm.pw2.value=="")
	{
		alert ("Confirma la contraseña.");
		frm.pw2.focus();
		return false;
	}
	if (frm.pw2.value!=frm.pw.value)
	{
		alert ("La confirmación de la contraseña no es correcta.");
		frm.pw2.select();
		frm.pw2.focus();
		return false;
	}
	result="Enviando...";
	if (frm.ch_terminos.checked==false)
	{
		alert ("Acepta los términos y condiciones.");
		return false;
	}
	if(ie){    
		document.all["spanRegistro"].innerHTML=result;
	}else{
		if(n4){
			document.layers["spanRegistro"].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById("spanRegistro").innerHTML=result;
			}
		}
	}
/*	frm.enviar_datos.disabled=true;*/
	getDatosRegistro2(frm, opt);
	return false;
}

//	ZOOM DEL TEXTO	

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;
		
		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++;
		};
		/*for(ii=0; ii <= 10;ii++){
			eval(titulares=document.getElementById("zm_texto"+ii));
			if (titulares != null){
				titulares.style.fontSize = zm_texto+'px';
				titulares.style.lineHeight = zm_texto_lh+'px';

			}else{
				break;
			}
		}*/
	}
	//		PARA EL TAG zm_titulo
	if (zm_titulo < 20){
		zm_titulo += 2;
		zm_titulo_lh += 2;
		ii=0;
		while (eval(titulares=document.getElementById("zm_titulo"+ii))!=null)
		{
			titulares.style.fontSize = zm_titulo+'px';
			titulares.style.lineHeight = zm_titulo_lh+'px';
			ii++;
		};
		/*for(ii=0; ii <= 10;ii++){
			eval(titulares=document.getElementById("zm_titulo"+ii));
			if (titulares != null){
				titulares.style.fontSize = zm_titulo+'px';
				titulares.style.lineHeight = zm_titulo_lh+'px';

			}else{
				break;
			}
		}*/
	}
	//		PARA EL TAG zm_linke
	if (zm_linke < 18){
		zm_linke += 2;
		zm_linke_lh += 2;
		
		eval(titulares=document.getElementById("zm_linke"));
		if (titulares != null){
			titulares.style.fontSize = zm_linke+'px';
			titulares.style.lineHeight = zm_linke_lh+'px';

		}
	}
}

function zoomOut() {
	//		PARA EL TAG zm_texto
	if (zm_texto > 8){
		zm_texto -= 2;
		zm_texto_lh -= 2;
		
		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++;
		};
		/*for(ii=0; ii <= 10;ii++){
			eval(titulares=document.getElementById("zm_texto"+ii));
			if (titulares != null){
				titulares.style.fontSize = zm_texto+'px';
				titulares.style.lineHeight = zm_texto_lh+'px';

			}else{
				break;
			}
		}*/
	}
	//		PARA EL TAG zm_titulo
	if (zm_titulo > 10){
		zm_titulo -= 2;
		zm_titulo_lh -= 2;
		ii=0;
		while (eval(titulares=document.getElementById("zm_titulo"+ii))!=null)
		{
			titulares.style.fontSize = zm_titulo+'px';
			titulares.style.lineHeight = zm_titulo_lh+'px';
			ii++;
		};
		/*for(ii=0; ii <= 10;ii++){
			eval(titulares=document.getElementById("zm_titulo"+ii));
			if (titulares != null){
				titulares.style.fontSize = zm_titulo+'px';
				titulares.style.lineHeight = zm_titulo_lh+'px';

			}else{
				break;
			}
		}*/
	}
	if (zm_linke > 8){
		zm_linke -= 2;
		zm_linke_lh -= 2;
		
		eval(titulares=document.getElementById("zm_linke"));
		if (titulares != null){
			titulares.style.fontSize = zm_linke+'px';
			titulares.style.lineHeight = zm_linke_lh+'px';

		}
	}
}
function focusObject(obj){
	if ((obj.value=="Tu Nombre")||(obj.value=="Su Nombre")||(obj.value=="Tu E-mail")||(obj.value=="Su E-mail"))
	{
		obj.value="";
	}
}
function enviarContactar(frm){
	if (isWhitespace(frm.nombre.value))
	{
		alert("Por favor introduzca su nombre.");
		frm.nombre.select();
		frm.nombre.focus();
		return;
	}
	if (isWhitespace(frm.apellidos.value))
	{
		alert("Por favor introduzca sus apellidos.");
		frm.apellidos.select();
		frm.apellidos.focus();
		return;
	}
	if (isWhitespace(frm.email.value))
	{
		alert("Por favor introduzca su e-mail.");
		frm.email.select();
		frm.email.focus();
		return;
	}
	if (isWhitespace(frm.comentario.value))
	{
		alert("Por favor introduzca el comentario que quiera enviarnos.");
		frm.comentario.select();
		frm.comentario.focus();
		return;
	}
	nombreSpan="spanContacto";
	result = 'Enviando...';
	if(ie){    
		document.all[nombreSpan].innerHTML=result;
	}else{
		if(n4){
			document.layers[nombreSpan].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById(nombreSpan).innerHTML=result;
			}
		}
	}
//	frm.getElementById("botonEnviar").visibility = "hidden";
//	frm.enviar.disabled=true;
	getEnviarContacto(frm);
}
function enviarContactar2(frm){
	if (isWhitespace(frm.empresa.value))
	{
		alert("Por favor introduzca el nombre de la empresa.");
		frm.empresa.select();
		frm.empresa.focus();
		return;
	}
	if (isWhitespace(frm.contacto.value))
	{
		alert("Por favor introduzca el nombre de la persona de contacto.");
		frm.contacto.select();
		frm.contacto.focus();
		return;
	}
	if (isWhitespace(frm.email.value))
	{
		alert("Por favor introduzca su e-mail.");
		frm.email.select();
		frm.email.focus();
		return;
	}
	if (isWhitespace(frm.comentario.value))
	{
		alert("Por favor introduzca el comentario que quiera enviarnos.");
		frm.comentario.select();
		frm.comentario.focus();
		return;
	}
	nombreSpan="spanContacto";
	result = 'Enviando...';
	if(ie){    
		document.all[nombreSpan].innerHTML=result;
	}else{
		if(n4){
			document.layers[nombreSpan].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById(nombreSpan).innerHTML=result;
			}
		}
	}
	getEnviarContacto2(frm);
}
function recordarContrasena(frm){
	if (isWhitespace(frm.email.value))
	{
		alert("Informa el e-mail.");
		frm.email.select();
		frm.email.focus();
		return;
	}
	if (validarEmail(frm.email.value)==false)
	{
		alert("El e-mail es incorrecto.");
		frm.email.select();
		frm.email.focus();
		return;
	}
	nombreSpan = "spanRecordContra";
//	result = '<img src="http://www.dietas.net/images/cargando.gif" />';
	result = 'Enviando...';
	if(ie){    
		document.all[nombreSpan].innerHTML=result;
	}else{
		if(n4){
			document.layers[nombreSpan].innerHTML=result;
		}else{
			if(n6){      
				document.getElementById(nombreSpan).innerHTML=result;
			}
		}
	}
	getEnviarContrasena(frm);
}
function getUrl(frm, str){
	var nom=str.toLowerCase();
	nom=nom.replace(/ /gi,"-");
	nom=nom.replace(/\'/gi,"");
	nom=nom.replace(/\"/gi,"");
	nom=nom.replace(/:/gi,"-");
	nom=nom.replace(/\./gi,"-");
	nom=nom.replace(/,/gi,"-");
	nom=nom.replace(/\\/gi,"");
	nom=nom.replace(/\//gi,"");
	nom=nom.replace(/_/gi,"-");
	nom=nom.replace(/\?/gi,"");
	nom=nom.replace(/¿/gi,"");
	nom=nom.replace(/!/gi,"");
	nom=nom.replace(/¡/gi,"");
	nom=nom.replace(/\+/gi,"");

	nom=nom.replace(/\(/gi,"");
	nom=nom.replace(/\)/gi,"");
	
	nom=nom.replace(/á/gi,"a");
	nom=nom.replace(/é/gi,"e");
	nom=nom.replace(/í/gi,"i");
	nom=nom.replace(/ó/gi,"o");
	nom=nom.replace(/ú/gi,"u");
	
	nom=nom.replace(/à/gi,"a");
	nom=nom.replace(/è/gi,"e");
	nom=nom.replace(/ì/gi,"i");
	nom=nom.replace(/ò/gi,"o");
	nom=nom.replace(/ù/gi,"u");
	
	nom=nom.replace(/ä/gi,"a");
	nom=nom.replace(/ë/gi,"e");
	nom=nom.replace(/ï/gi,"i");
	nom=nom.replace(/ö/gi,"o");
	nom=nom.replace(/ü/gi,"u");
	
	nom=nom.replace(/ñ/gi,"n");
	nom=nom.replace(/&/gi,"and");
	frm.url.value=nom;
}

function comprobarDatoReg(frm){
	if (isWhitespace(frm.nom.value))
	{
		alert("Por favor informa tu nombre.");
		frm.nom.select();
		frm.nom.focus();
		return false;
	}
	if (isWhitespace(frm.ape.value))
	{
		alert("Por favor informa tus apellidos.");
		frm.ape.select();
		frm.ape.focus();
		return false;
	}
	if (isWhitespace(frm.prov.value))
	{
		alert("Por favor informa tu provincia.");
		frm.prov.select();
		frm.prov.focus();
		return false;
	}
	if (isWhitespace(frm.pais.value))
	{
		alert("Por favor informa tu país.");
		frm.pais.focus();
		return false;
	}
	updateDatos(frm);
	return false;
}
function cambiarContrasena(frm){
	if (isWhitespace(frm.contrasena.value))
	{
		alert("Por favor introduzca su actual contraseña.");
		frm.contrasena.focus();
		return false;
	}
	if (isWhitespace(frm.nueva_contrasena.value))
	{
		alert("Por favor introduzca su nueva contraseña.");
		frm.nueva_contrasena.focus();
		return false;
	}
	if (isWhitespace(frm.nueva_contrasena2.value))
	{
		alert("Por favor introduzca su nueva contraseña otra vez.");
		frm.nueva_contrasena2.focus();
		return false;
	}
	if ((frm.nueva_contrasena.value)!=(frm.nueva_contrasena2.value))
	{
		alert("No ha repetido la contraseña correctamente.");
		frm.nueva_contrasena2.focus();
		return false;
	}
	actualizarContrasena(frm);
	return false;
}

function cambioCanal(frm){
	setSelectCategorias(frm.categoria2.value, frm.canal.value);
}
function cambioCanal2(frm){
	setSelectCategorias2(frm.categoria2.value, frm.canal.value);
}

function enviarArticulo(frm){
	if (frm.opt_submenu.value=='0')
	{
		if (isWhitespace(frm.canal.value))
		{
			alert("Informe el Canal al que pertenece el artículo.");
			frm.canal.focus();
			return false;
		}
		if (isWhitespace(frm.categoria.value))
		{
			alert("Informe la Categoría a la que pertenece el artículo.");
			frm.categoria.focus();
			return false;
		}
		if (isWhitespace(frm.nombre.value))
		{
			alert("Informe el Título del artículo.");
			frm.nombre.focus();
			frm.nombre.select();
			return false;
		}
		if (isWhitespace(frm.intro_ext.value))
		{
			alert("Informe la Introducción externa.");
			frm.intro_ext.focus();
			frm.intro_ext.select();
			return false;
		}
		if (isWhitespace(frm.intro_int.value))
		{
			alert("Informe la Introducción interna.");
			frm.intro_int.focus();
			frm.intro_int.select();
			return false;
		}
		anadirArticulo(frm);
		return false;
	}else if (frm.opt_submenu.value=='1')
	{
/*		if (isWhitespace(frm.titulo.value))
		{
			alert("Informe el Título del apartado del artículo.");
			frm.titulo.focus();
			frm.titulo.select();
			return false;
		}*/
		
		parent.frames[2].FCK.UpdateLinkedField();
		
		var richEdit=fckFilter(frm.richEdit.value);
		if (isWhitespace(richEdit))
		{
			alert("Informe el Texto que quiera poner.");
			frm.richEdit.select();
			return false;
		}
		anadirArticulo(frm);
		return false;
	}
}
function enviarArticuloUsuario(frm){
	if (isWhitespace(frm.canal.value))
	{
		alert("Informe el Canal al que pertenece el artículo.");
		frm.canal.focus();
		return false;
	}
	if (isWhitespace(frm.categoria.value))
	{
		alert("Informe la Categoría a la que pertenece el artículo.");
		frm.categoria.focus();
		return false;
	}
	if (isWhitespace(frm.nombre.value))
	{
		alert("Informe el Título del artículo.");
		frm.nombre.focus();
		frm.nombre.select();
		return false;
	}
	if (isWhitespace(frm.intro_ext.value))
	{
		alert("Informe la Introducción.");
		frm.intro_ext.focus();
		frm.intro_ext.select();
		return false;
	}
	parent.frames[2].FCK.UpdateLinkedField();

	var richEdit=fckFilter(frm.richEdit.value);
	
	if (isWhitespace(richEdit)){
		alert("Informe el Texto que quiera poner.");
		frm.richEdit.select();
		return false;
	}
	anadirArticuloUsuario(frm);
	return false;
}

function ponerUrl(frm){
	var nom=frm.nombre.value.toLowerCase();
	nom=nom.replace(/ /gi,"-");
	nom=nom.replace(/\'/gi,"");
	nom=nom.replace(/\//gi,"");
	
	nom=nom.replace(/á/gi,"a");
	nom=nom.replace(/é/gi,"e");
	nom=nom.replace(/í/gi,"i");
	nom=nom.replace(/ó/gi,"o");
	nom=nom.replace(/ú/gi,"u");
	
	nom=nom.replace(/à/gi,"a");
	nom=nom.replace(/è/gi,"e");
	nom=nom.replace(/ì/gi,"i");
	nom=nom.replace(/ò/gi,"o");
	nom=nom.replace(/ù/gi,"u");
	
	nom=nom.replace(/ä/gi,"a");
	nom=nom.replace(/ë/gi,"e");
	nom=nom.replace(/ï/gi,"i");
	nom=nom.replace(/ö/gi,"o");
	nom=nom.replace(/ü/gi,"u");
	
	nom=nom.replace(/ñ/gi,"n");
	nom=nom.replace(/ç/gi,"c");
	frm.url.value=nom;
}

function enviarRespuesta(frm){
	if ((frm.iu.value==0)&&(isWhitespace(frm.nom_orig.value)))
	{
		alert("Informe su nombre.");
		frm.nom_orig.focus();
		frm.nom_orig.select();
		return false;
	}
	if (isWhitespace(frm.tit.value))
	{
		alert("Informe el Título de tu respuesta.");
		frm.tit.focus();
		frm.tit.select();
		return false;
	}
	if (isWhitespace(frm.txt.value))
	{
		alert("Informe el Texto de tu respuesta.");
		frm.txt.focus();
		frm.txt.select();
		return false;
	}
	anadirRespuesta(frm);
	return false;
}
function enviarPregunta(frm){
	if ((frm.iu.value==0)&&(isWhitespace(frm.nom_orig.value)))
	{
		alert("Informe su nombre.");
		frm.nom_orig.focus();
		frm.nom_orig.select();
		return false;
	}
	if (isWhitespace(frm.canales.value))
	{
		alert("Informe el Canal al que hace referencia la pregunta.");
		frm.canales.focus();
		return false;
	}
	if (isWhitespace(frm.categorias.value))
	{
		alert("Informe la Categoría a la que hace referencia la pregunta.");
		frm.categorias.focus();
		return false;
	}
	if (isWhitespace(frm.tit.value))
	{
		alert("Informe el Título de tu respuesta.");
		frm.tit.focus();
		frm.tit.select();
		return false;
	}
	if (isWhitespace(frm.txt.value))
	{
		alert("Informe el Texto de tu respuesta.");
		frm.txt.focus();
		frm.txt.select();
		return false;
	}
	anadirPregunta(frm);
	return false;
}
function enviarMensaje(frm){
	if (isWhitespace(frm.nick.value))
	{
		alert("Informe el Nick del destinatario.");
		frm.nick.focus();
		return false;
	}
	if (isWhitespace(frm.asunto.value))
	{
		alert("Informe el Título del mensaje.");
		frm.asunto.focus();
		frm.asunto.select();
		return false;
	}
	if (isWhitespace(frm.texto.value))
	{
		alert("Informe el Texto del mensaje.");
		frm.texto.focus();
		frm.texto.select();
		return false;
	}
	enviarMensajePrivado(frm);
	return false;
}
function cambiarMensajes(valor, frm, opcion){
	var marcados = "";
	var total = document.frm_listamens.total_opt.value;
	for (i=0; i<total; i++)
	{
		if (document.getElementById(i).checked==true)
		{
			marcados = marcados + document.getElementById(i).name + ";";
		}
	}
	if ((marcados!="")&&(valor>0))
	{
		cambiarEstadoMensaje(frm, valor, marcados, opcion);
	}
}
function calcular(frm){
	
}
function calcularCCN(frm){
	if (isWhitespace(frm.peso.value))
	{
		alert("Informe el Peso.");
		frm.texto.focus();
		frm.texto.select();
		return false;
	}
	
}
function comprobarSugerencia(frm){
	if (isWhitespace(frm.nom.value))
	{
		alert("Informe su nombre.");
		frm.nom.focus();
		frm.nom.select();
		return false;
	}
	if (isWhitespace(frm.sugerencia.value))
	{
		alert("Informe la sugerencia.");
		frm.sugerencia.focus();
		frm.sugerencia.select();
		return false;
	}
	enviarSugerencia(frm);
}
function getUrlEnvMsg (canal, dest, obj){
	id=document.getElementById("caja_login_idusu").value;
//	this.class.value = "thickbox";
	var urlenv = "http://www.dietas.net/pop/mensajes/enviar-mensaje.php?dest=" + dest + "&id=" + id + "&KeepThis=true&TB_iframe=true&width=550&height=600";
	document.location.href = urlenv;
}
function verificarDatReg (frm){
	if (isWhitespace(frm.nick.value)){
		alert("Informa el ID de usuario.");
		frm.nick.focus();
		frm.nick.select();
		return false;
	}
	if (isWhitespace(frm.id_conf.value)){
		alert("Informa el ID2 que tienes en tu correo.");
		frm.id_conf.focus();
		frm.id_conf.select();
		return false;
	}
}
function closePop(){
	obj = parent.TB_remove();
}
function iralPanel(){
	document.location.href = "/panel-de-usuario/";
}
function onboton(obj){
	var str = obj.src;
	obj.src = str.replace('.off', '.on');
}
function offboton(obj){
	var str = obj.src;
	obj.src = str.replace('.on', '.off');
}
function clickAun(obj){
	if (obj.checked==true){
		document.getElementById('id_frm').style.display = 'inline';
		document.getElementById('id_pw').style.display = 'inline';
	}else{
		document.getElementById('id_frm').style.display = 'none';
		document.getElementById('id_pw').style.display = 'none';
	}
}
function compEnvConsejo(frm){
	if (isWhitespace(frm.cat.value)){
		alert("Informa la categoría del consejo.");
		frm.cat.focus();
//		frm.cat.select();
		return;
	}
	if (isWhitespace(frm.tit.value)){
		alert("Informa el título del consejo.");
		frm.tit.focus();
		frm.tit.select();
		return;
	}
	if (isWhitespace(frm.con.value)){
		alert("Informa el consejo.");
		frm.con.focus();
		frm.con.select();
		return;
	}
	if (frm.aun)
	{
		if (frm.aun.checked==true)
		{
			if (isWhitespace(frm.nombre.value)){
				alert("Informa el nombre.");
				frm.nombre.focus();
				frm.nombre.select();
				return;
			}
			if (isWhitespace(frm.ape.value)){
				alert("Informa los apellidos.");
				frm.ape.focus();
				frm.ape.select();
				return;
			}
			if (isWhitespace(frm.mai.value)){
				alert("Informa el e-mail.");
				frm.mai.focus();
				frm.mai.select();
				return;
			}
			if (isWhitespace(frm.nic.value)){
				alert("Informa el nick.");
				frm.nic.focus();
				frm.nic.select();
				return;
			}
			if (isWhitespace(frm.pw1.value)){
				alert("Informa la contraseña.");
				frm.pw1.focus();
				frm.pw1.select();
				return;
			}
			if (isWhitespace(frm.pw2.value)){
				alert("Repite la contraseña.");
				frm.pw2.focus();
				frm.pw2.select();
				return;
			}
			if (frm.pw1.value!=frm.pw2.value){
				alert("Repite bien la contraseña.");
				frm.pw2.focus();
				frm.pw2.select();
				return;
			}
			envRegiUsu(frm);
		}else{
			if (isWhitespace(frm.usu.value)){
				alert("Informa el usuario.");
				frm.usu.focus();
				frm.usu.select();
				return;
			}
			if (isWhitespace(frm.pw.value)){
				alert("Informa la contraseña.");
				frm.pw.focus();
				frm.pw.select();
				return;
			}
			envCompUsu(frm);
		}
	}else{
		envConsejo(frm);
	}
}

//codifica parametro para valores
function URLEncodeValue(obj)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = obj;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				alert( "Unicode Character '" 
						+ ch 
						+ "' cannot be encoded using standard URL encoding.\n" +
						  "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return encoded;
}

function recargaForm(val){
	document.aportes.submit();
}
//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 = {};

Array.prototype.formateaLista = function() {
	codigoHtml = "<table width=\"375\" cellpadding=\"3\" cellspacing=\"0\" style=\"border:1px solid #666;cursor:pointer;margin-left:15px;\">";
	for(var i=0; i<this.length; i++) {
		if(i == elementoSeleccionado) {
			codigoHtml += "<tr><td style=\"font-family:verdana;font-size:11px; background-color: #D5E283;font-size:12px\"> "+this[i]+"</td></tr>";
		}
		else {
			codigoHtml += "<tr><td style=\"background-color:#FFF;font-size:12px\" onMouseOver=\"limpia_over();this.style.backgroundColor='#D5E283';;\" onMouseOut=\"this.style.backgroundColor='#ffffff';\" onclick=\"selecciona_r('"+i+"');\"> "+this[i]+"</td></tr>";
		}
	}
	codigoHtml += "</table>";
	return codigoHtml;
}

function selecciona_r(ciudad){
	elementoSeleccionado = ciudad;
	seleccionaElemento();
	borraLista();
}

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

	return opc;
}

function seleccionaElemento(){
	if(sugerencias[elementoSeleccionado]) {
		//reemplazamos "&ntilde;" por "Ñ"
		tmp = sugerencias[elementoSeleccionado];
		document.search.search.value = tmp;
		//document.oForm4.action = "http://" + document.oForm.nombre_ciudad.value + ".callejero.net/tiempo/";
		//document.oForm.submit();
		
	}
}

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.search.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 timestamp = date.getTime();
				var parameters = "search=" + search+ "&time=" + timestamp;
				ajax = ajaxobj();
				ajax.open("POST", "/inc/ajax/alim/buscar.php");
				ajax.onreadystatechange=function(){
					if (ajax.readyState==4){
						//sugerencias = ajax.responseText;
						sugerencias = eval('('+ajax.responseText+')');
						if(sugerencias.length == 0) {
							sinResultados();
						}else {
							cacheSugerencias[search] = sugerencias;
							//alert("1" + sugerencias);
							actualizaSugerencias();
						} 
					}
				}
				ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
				ajax.send(parameters);
			/*}else{
				sugerencias = cacheSugerencias[search];
				//alert("2");
				actualizaSugerencias(sugerencias);
			}*/
				
		}
}

function autocompletaPlatos() {
	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.search.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 timestamp = date.getTime();
				var parameters = "search=" + search+ "&time=" + timestamp;
				ajax = ajaxobj();
				ajax.open("POST", "/inc/ajax/alim/buscarPlatos.php");
				ajax.onreadystatechange=function(){
					if (ajax.readyState==4){
						//sugerencias = ajax.responseText;
						sugerencias = eval('('+ajax.responseText+')');
						if(sugerencias.length == 0) {
							sinResultadosPlatos();
						}else {
							cacheSugerencias[search] = sugerencias;
							//alert("1" + sugerencias);
							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();
	zonaSugerencias.style.display = 'block';
}

function borraLista() {
	document.getElementById("sugerencias").innerHTML = "";
	document.getElementById("sugerencias").style.display = "none";
}
function sinResultados() {
	codigoHtml = "<table width=\"375\" cellpadding=\"3\" cellspacing=\"0\" style=\"border:1px solid #666;cursor:pointer;margin-left:15px;\">";
	codigoHtml += "<tr><td style=\"font-size:12px; background-color: #D5E283; \">No existen alimentos para la búsqueda seleccionada</td></tr>";
	codigoHtml += "</table>";
	document.getElementById("sugerencias").innerHTML = codigoHtml;
	document.getElementById("sugerencias").style.display = "block";
}
function sinResultadosPlatos() {
	codigoHtml = "<table width=\"375\" cellpadding=\"3\" cellspacing=\"0\" style=\"border:1px solid #666;cursor:pointer;margin-left:15px;\">";
	codigoHtml += "<tr><td style=\"font-size:12px; background-color: #D5E283; \">No existen platos 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 valSearchPlatos(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/redirectPlatos.php");
	ajax.onreadystatechange=function(){
		if (ajax.readyState==4){
			//sugerencias = ajax.responseText;
			sugerencias = eval('('+ajax.responseText+')');
			if(sugerencias.length == 0) {
				sinResultadosPlatos();
			}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;
}

var edad = /^[0-9]{1,3}$/;
var altura = /^[0-9]{2,3}$/;
var peso = /^[0-9]{2,3}$/;

function setGenero(frm, obj){
	if (obj.value == 1){
		for (i=0; i < frm.embarazada.length; i++){
			frm.embarazada[i].checked=false;
		}
	}
}

function validaFormIngestas(frm){
	if(!edad.test(frm.edad.value)) {
		alert("Por favor, informe correctamente su edad. Debe ser un número y no contener puntos ni comas ni espacios en blanco");
		frm.edad.focus();
		return false;
	}
	if(frm.genero.value == "") {
		alert("Por favor, informe su género, hombre o mujer");
		frm.genero.focus();
		return false;
	}
	if(!peso.test(frm.peso.value)) {
		alert("Por favor, informe correctamente su peso. Debe ser un número y no contener puntos ni comas ni espacios en blanco");
		frm.peso.focus();
		return false;
	}
	if(!altura.test(frm.altura.value)) {
		alert("Por favor, informe correctamente su altura. Debe ser un número y no contener puntos ni comas ni espacios en blanco");
		frm.altura.focus();
		return false;
	}

	var wkEmbarazada=-1;
	for (i=0; i < frm.embarazada.length; i++){
		if (frm.embarazada[i].checked == true){
			wkEmbarazada=frm.embarazada[i].value;
			break;
		}
	}
	if (wkEmbarazada != -1 && frm.genero.value != 2){
		alert("Para informar su estado de embarazo, debe seleccionar 'mujer' como género");
		for (i=0; i < frm.embarazada.length; i++){
			frm.embarazada[i].checked=false;
		}
		frm.genero.focus();
		return false;
	}

	var wkActividad=-1;
	for (i=0; i < frm.actividad.length; i++){
		if (frm.actividad[i].checked == true){
			wkActividad=frm.actividad[i].value;
			break;
		}
	}

	var imc=computeIngestas(frm);

	var poststr = "edad="+frm.edad.value+"&genero="+frm.genero.value+"&peso="+frm.peso.value+"&altura="+frm.altura.value+"&actividad="+wkActividad+"&embarazada="+wkEmbarazada+"&imc="+imc;
	nombreSpan = "spanIngestas";
	makePOSTRequest("/inc/ajax/comn/comn-0007.ajax.php", poststr);
}