// JavaScript Document


function buscar() {
	
	if (validar_buscador_superior(document.frm_buscador_superior)) {
	
		document.frm_buscador_superior.action = "/index.php";
     	document.frm_buscador_superior.submit();		
	}
}

function validar_buscador_superior(theForm){
	
	if (theForm.palabra_buscada.value == ""){
		alert("Debe completar el campo para realizar la b\xFAsqueda.");
		theForm.palabra_buscada.focus();
		return (false);
	}

	return (true);	
}




function buscar_carreras() {
	
	if (validar_buscador_carreras(document.frm_buscador_carreras)) {
		document.frm_buscador_carreras.action = "/subsitios/resultados_busqueda.php?buscar_por=carreras";
		document.frm_buscador_carreras.submit();
	}
}


function validar_buscador_carreras(theForm){

	dato_buscado = theForm.carrera_buscada.value;
	
	dato_buscado = eliminar_caracteres(dato_buscado, '"');
	dato_buscado = eliminar_caracteres(dato_buscado, "<");
	dato_buscado = eliminar_caracteres(dato_buscado, ">");

	theForm.carrera_buscada.value = dato_buscado;
		
	if (theForm.carrera_buscada.value == ""){
		alert("Debe completar el campo para realizar la b\xFAsqueda.");
		theForm.carrera_buscada.focus();
		return (false);
	}
		
	numero_caracteres = theForm.carrera_buscada.value.length;

	if (numero_caracteres < 3){
		alert("La frase de b\xFAsqueda debe tener como m\xEDnimo tres caracteres.");
		theForm.texto_busqueda.value = "";
		theForm.texto_busqueda.focus();
		return (false);
	}
	else {
		return(true);
	}
	
	return(true);
}




function buscar_ramas(){
	if (validar_buscador_ramas(document.frm_buscador_ramas)) {
		document.frm_buscador_ramas.action = "/subsitios/resultados_busqueda.php?buscar_por=ramas";
		document.frm_buscador_ramas.submit();
	}
}

function validar_buscador_ramas(theForm){

	if (theForm.id_rama_buscada.value == "seleccionar"){
		alert("Debe seleccionar una rama para realizar la b\xFAsqueda.");
		theForm.id_rama_buscada.focus();
		return (false);
	}

	return(true);
}



function enviar_newsletter() {
	
	if (validar_email_newsletter(document.frm_newsletter)) {
	
		document.frm_newsletter.action = "http://www.newsletter.poloeducativo.com/?p=subscribe";
		document.frm_newsletter.submit();
	}
}

function validar_email_newsletter(theForm){
	
	if (theForm.email.value == ""){
		alert("Su email es un dato requerido.");
		theForm.email.focus();
		return (false);
	}

	email = theForm.email.value;
	
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
		return (true);
	}
	else{
		alert("La direcci\xF3n de email es incorrecta.");
		return (false);
	}	

	return (true);	
	
}



function validar_contacto(theForm){
	
	if (theForm.apellido.value == ""){
		alert("El apellido es un dato requerido.");
		theForm.apellido.focus();
		return (false);
	}
	
	if (theForm.nombre.value == ""){
		alert("El nombre es un dato requerido.");
		theForm.nombre.focus();
		return (false);
	}
		
	 if (theForm.email.value == ""){
		alert("El email es un dato requerido.");
		theForm.email.focus();
		return (false);
	}

	email = theForm.email.value;
	email = email.toLowerCase();			
	
	if ( email.search("@") != -1 ){
	}
	else{
		alert("La dirección de e-mail ingresada no es válida");
		theForm.email.focus();
		return (false);				
	}
	
	if (theForm.mensaje.value == ""){
		alert("Su mensaje es un dato requerido.");
		theForm.mensaje.focus();
		return (false);
	}

	
	return (true);	
	
}
