// JavaScript Document

function valida(frm) {
  // the name of the form
  f = frm;

	if (f.dirigido) {
	if (f.dirigido.options[f.dirigido.selectedIndex].value == "0")
    {
    alert("Por favor, seleccione a quien va dirigido este Formulario");
    document.form.dirigido.focus(form.dirigido.options[form.dirigido.selectedIndex].value == "0");
    return false;
    }
	}
	
	if (f.nombres) {
    if (f.nombres.value == '') {
      alert('No ha ingresado sus Nombres');
	  document.form.nombres.focus();
	  return false;
    }
  }

	if (f.apellidos) {
    if (f.apellidos.value == '') {
      alert('No ha ingresado sus Apellidos');
	  document.form.apellidos.focus();
	  return false;
    }
  }	
  
  	if (f.telefono) {
	    if (f.telefono.value == '') {
      alert('No ha ingresado Telefono');
	  document.form.telefono.focus();
      return false;
    }
	

var checkOK = "0123456789."; 
var checkStr = f.telefono.value; 
var allValid = true; 
var decPoints = 0; 
var allNum = ""; 
for (i = 0; i < checkStr.length; i++) { 
ch = checkStr.charAt(i); 
for (j = 0; j < checkOK.length; j++) 
if (ch == checkOK.charAt(j))
break; 
if (j == checkOK.length) { 
allValid = false; 
break; 
} 
allNum += ch; 
} 
if (!allValid) { 
alert("Escriba sólo numeros en el campo de Telefono");
form.telefono.focus(document.form.telefono.value='');
return false;
}
}

if (f.rut.value == '') {
alert('No ha ingresado RUT');
document.form.rut.focus();
return false;
}


if (f.objetivo) {
if (f.objetivo.options[f.objetivo.selectedIndex].value == "0")
{
alert("Por favor, seleccione el Propósito u Objetivo de este Formulario");
document.form.objetivo.focus(form.objetivo.options[form.objetivo.selectedIndex].value == "0");
return false;
}
}

if (f.tema){
if (f.tema.value == '') {
      alert('No ha ingresado el Tema');
	  document.form.tema.focus();
	  return false;
  }
}
  
    if (f.mail) {
    if (f.mail.value != '' && (f.mail.value.lastIndexOf('.') < 0 || f.mail.value.lastIndexOf('@') < 1)) {
      alert('E-mail Invalido! \n Debe ingresar una Direccion de correo valida.');
	  document.form.mail.focus(document.form.mail.value='');
      return false;
    }
    else if(f.mail.value == ''){
	alert('Debe Ingresar una direccion de correo');
	document.form.mail.focus();
	return false;
}
  }
  
   if (f.msje) {
   if (f.msje.value == '') {
      alert('No ha ingresado el Mensaje');
	  document.form.msje.focus();
	  return false;
  }
	 }


if (f.pass){
if (f.pass.value == '') {
      alert('No ha ingresado su contraseña');
	  document.form.pass.focus();
	  return false;
  }
}
  
if(form.requiere) {  
forma = 0

for(m=0;m<2;m++){

if(form.requiere[m].checked == true){

forma++

}

}

if(forma==0){

alert('Debe seleccionar Si requiere respuesta')

return false;

}
}


}
