// JavaScript Document
function vacio(q) { 
	for ( i = 0; i < q.length; i++ ) { 	
		if ( q.charAt(i) != " " ) {
		return true;
		}
	}
	return false;
}

function validar(F){

 if( vacio(F.nombre.value) == false){
  alert("Ingrese su NOMBRE y APELLIDO.");
  F.nombre.focus();
  return false;
 }
 if (F.email.value==""){
  alert("Ingrese su EMAIL.");
  F.email.focus();
  return false;
 }
 var er_email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
 if(!er_email.test(F.email.value)) {    
  alert("Contenido del campo E-MAIL no valido.")
  F.email.focus();
  return false;
 }
 if (F.telefono.value==""){
  alert("Ingrese su Nro. de TELEFONO.");
  F.telefono.focus();
  return false;
 }
 if (F.tema.value==0){
  alert("Seleccione su TEMA a referenciar.");
  F.tema.focus();
  return false;
 }
 if (F.contenido.value==""){
  alert("Ingrese el CONTENIDO de su Tema.");
  F.contenido.focus();
  return false;
 }
 if (F.uword.value==""){
  alert("Ingrese el CODIGO visualizado.");
  F.uword.focus();
  return false;
 }  
 else{
     var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ\" + \"abcdefghijklmnñopqrstuvwxyzáéíóú\"";
     var checkStr = form1.name.value;
     var allValid = true;
     var uword = hex_md5(document.getElementById('uword').value);
  
     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;}  
	 }
	   
     if (!allValid) {
          alert("inserte el nombre");
          form1.name.focus();
          return false;
	 }   
	   
	 if (uword==cword[anum-1]) {
          return true;}
     else {
         alert("Codigo de imagen INCORRECTO, si no logra ver la imagen presione la tecla F5");
         document.getElementById('uword').focus();
         return false;}   
  } 
 
 
 return true;
}
function numeros(evento){
// Algunos caracteres: backspace = 8, enter = 13, '0' = 48, '9' = 57, '-' = 45
  var nav4 = window.Event ? true : false;
  var key = nav4 ? evento.which : evento.keyCode;
  return (key <= 13 || (key >= 48 && key <= 57) || key == 45);	
}

function buscar() {  
    var p = "url"
	var texto = document.form1.contenido.value;		
	var patron = new RegExp('('+p+')','gi'); 
		
	textoNuevo = texto.replace(patron,' * XXXXX * ');  
	document.form1.contenido.value = textoNuevo; 	
	
	if ( texto!=textoNuevo ) {  
	alert("EL SIGNO ' URL ' NO ES ADMITIDO EN ESTA AREA");
	}   
}
function envio(variable){

if(variable == "bien"){
   alert("Su contenido fue enviado correctamente");  
   var pagina="contacto.php"
   location.href=pagina 
   setTimeout ("location.href=pagina", 1000);   
}
if(variable == "mal"){
   alert("Hubo un error en el envio, Intentelo nuevamente");
   history.back();
   return false;
}
return true;
}
