// JavaScript Document

function quienesSomos()
{
	document.getElementById("formulario").action="quienessomos.asp";
	document.getElementById("formulario").submit();
}

function contacto()
{
	document.getElementById("formulario").action="contacto.asp";
	document.getElementById("formulario").submit();
}

function login()
{
	var url=new String(document.location);
	if (url.lastIndexOf("standalone")>0)
	{
		window.open("http://www.cesefor.com/login.asp")
	}
	else
	{
		document.getElementById("formulario").action="login.asp";
		document.getElementById("formulario").submit();
	}
}

function servicios()
{
	document.getElementById("formulario").action="servicioscesefor.asp";
	document.getElementById("formulario").submit();
}

function enlaces()
{
	document.getElementById("formulario").action="enlaces.asp";
	document.getElementById("formulario").submit();
}

function controlBuscador(e)
{
	if (e.keyCode==13)
	{
		return lanzarBuscar();
	}
}

function lanzarBuscar()
{
	if (trim(document.getElementById("txtBuscar").value)=="")
	{
		alert("No ha introducido un texto para la búsqueda");
		return;
	}
	if (controlTxtBuscador(document.getElementById("txtBuscar").value))
	{
		document.getElementById("txtCadenaBusqueda").value=" " + trim(document.getElementById("txtBuscar").value) + " ";
		document.getElementById("formulario").action="buscador.asp";
		document.getElementById("formulario").submit();
	}	
}

function controlTxtBuscador(txt)
{
	var i;
	var j=0;
	var tx=0;
	var letra=new String(trim(txt));
	var longitud = letra.length;
	
	//Controlo ke por lo menos una palabra tenga 3 letra
	for (i=0; i<longitud; i++)
	{
		if (letra.substring(i,i+1)!=" " && letra.substring(i,i+1)!='"')
		{
			j++;
			if(j==3)
			{
				tx=1;
			}
		}
		else
		{
			j=0;
		}
	}
	if(tx==0)
	{
		alert("El número mínimo de caracteres a buscar es 3");
		return (false);
	}
	else
	{
		return (true);
	}	
}

function calidad()
{
	document.getElementById("formulario").action="calidad.asp";
	document.getElementById("formulario").submit();
}