
// JavaScript Document
function oculta_div(sitio,valor,destino)
	{
		
		document.getElementById(sitio).style.visibility="hidden";
		 setTimeout(function(){document.getElementById(sitio).style.visibility="visible"}, 5000)
	   
	}

function muestra_div(sitio,valor,destino,valor2)
	{
		
		
		document.getElementById(sitio).style.visibility="visible";
		 document.getElementById(sitio).style.display="block";
		 MostrarConsulta(valor2,destino);
		 setTimeout(function(){							 
					
					document.getElementById(sitio).style.visibility="hidden";
			        document.getElementById(sitio).style.display="none";
			 
			 MostrarConsulta(valor,destino);   }, 4000)
		
		 ;
	
	   
	}








	function abrirVentana(ventana,sitio)
	{
		if (ventana=="1")
		{
			document.getElementById("capaFondo1").style.visibility="visible";
			document.getElementById("capaFondo2").style.visibility="hidden";
			document.getElementById("capaFondo3").style.visibility="hidden";
		
		}
		else if (ventana=="2")
		{
			document.getElementById("capaFondo1").style.visibility="hidden";
			document.getElementById("capaFondo2").style.visibility="visible";
			document.getElementById("capaFondo3").style.visibility="hidden";
		}
		else
		{
			document.getElementById("capaFondo1").style.visibility="hidden";
			document.getElementById("capaFondo2").style.visibility="hidden";
			document.getElementById("capaFondo3").style.visibility="visible";
		}
		
		document.getElementById(sitio).style.visibility="visible";
		//document.formulario.bAceptar.focus();
	   
	}
	
	function cerrarVentana3(sitio)
	{
		document.getElementById("capaFondo1").style.visibility="hidden";
		document.getElementById("capaFondo2").style.visibility="hidden";
		document.getElementById("capaFondo3").style.visibility="hidden";
		document.getElementById(sitio).style.visibility="hidden";
		//document.formulario.bAceptar.blur();
	}




//alertas formularios
/*
function validar_campos()
{
var s="" 
for (e=0; e<=document.form1.length; e++){ 
if (document.form1.elements[e].value=="" || document.form1.elements[e].value==" "){ 
s=s + document.form1.elements[e].name 
} 
} 
if (s!=""){ 
alert("No llenaste todo el formulario"); 
return false
} else { 
document.form1.submit(); 
}

}

/*
function Enter(Evento, Campo)
{
var keyCode = Evento.keyCode ? Evento.keyCode : Evento.which ? Evento.which : Evento.charCode; 
if (keyCode == 13) 
{ 
var i;
for (i = 0; i < Campo.form.elements.length; i++) 
if (Campo == Campo.form.elements[i]) 
break; 
i = Campo.form.elements[i].tabIndex + 1; 
for( j = 0 ; j < Campo.form.elements.length; j++)
{ 
if( Campo.form.elements[j].tabIndex == i)
break; 
} 
Campo.form.elements[j].focus(); 
return false; 
} 
else 
return true; 
}

*/
//validadion para expedientres



//validaion de emil

function validarEmail(valor1,valor2,valor3) {
      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor1)){
      
      } else {
      alert('El campo ' + valor2+   ' tiene un email incorrecto ');
      valor3.focus();
	  return false;
      }
      }

function contar(valor1) {



//alert(valor1);
if ((valor1.value.length < 8)||(valor1.value.length > 8)) {
	  alert('El campo ' + valor1.name +   ' su clave debe ser de 8 digitos ');
     valor1.focus();
	  return false;
}

}

//dos campos diferentes 
function diferente(valor1,valor2) {

if(valor1!=valor2) {
      alert('El campo ' + valor1.name +   ' no puede ser diferente al campo ' + valor2.name +  ' ');
      valor2.focus();
       return false
	  } 


}
//fin de sos campos diferentes

function validar_letras(e) { // 1
    tecla = (document.all) ? e.keyCode : e.which; // 2
    if (tecla==8) return true; // 3
    patron =/[A-Za-z\s]/; // 4
    te = String.fromCharCode(tecla); // 5
    return patron.test(te); // 6
} 

//
function validar_for233 (F) {


valor=F.email.value;
      if(valor=='') {
      alert('El campo ' + F.email.name +   ' no puede estar vacio ');
      F.email.focus();
      return false
	  }


valor=F.Input.value;
      if(valor=='') {
      alert('El campo ' + F.Input.name +   ' no puede estar vacio ');
      F.Input.focus();
      return false
	  }
	//
		 
	 valor=F.Input.value;
	   valor1=F.Input2.value;
	/*
	if(valor1!='' && valor!='') {
	/*/
	if(valor1!=valor) {
      alert('El campo ' + F.Input.name +   ' no puede ser diferente al campo ' + F.Input2.name +  ' ');
      F.Input2.focus();
       return false
	  } 



valor1=F.email.value;
      if(valor1!='') {
      return validarEmail(F.email.value,F.email.name,F.email);
	 }	


}
//

function validar_for23 (F) {

//16 elementos del formulario 
     //mail
	 valor=F.elements[2].value;
      if(valor=='') {
      alert('El campo ' + F.elements[2].name +   ' no puede estar vacio ');
      F.elements[2].focus();
      return false
	  }
	
	
	 valor=F.elements[3].value;
      if(valor=='') {
      alert('El campo ' + F.elements[3].name +   ' no puede estar vacio ');
      F.elements[3].focus();
      return false
	  }
      //
     //formato 
	 	 //clave
	 valor=F.elements[7].value;
      if(valor=='') {
      alert('El campo ' + F.elements[7].name +   ' no puede estar vacio ');
      F.elements[7].focus();
      return false
	  }
     
	  
	 
	 //email
	 
	 valor=F.elements[8].value;
      if(valor=='') {
      alert('El campo ' + F.elements[8].name +   ' no puede estar vacio ');
      F.elements[8].focus();
      return false
	  }
	 
	 
	
	  	  
	 
	 //direccion
	
	valor=F.elements[9].value;
      if(valor=='') {
      alert('El campo ' + F.elements[9].name +   ' no puede estar vacio ');
      F.elements[9].focus();
      return false
	  }
	//
	//Codigo Postal
	
	valor=F.elements[10].value;
      if(valor=='') {
      alert('El campo ' + F.elements[10].name +   ' no puede estar vacio ');
      F.elements[10].focus();
      return false
	  }
	
	//
	//Poblacion
	
	valor=F.elements[11].value;
      if(valor=='') {
      alert('El campo ' + F.elements[11].name +   ' no puede estar vacio ');
      F.elements[11].focus();
      return false
	  }
	//Estado
	valor=F.telephone.value;
      if(valor=='') {
      alert('El campo ' + F.telephone.name +   ' no puede estar vacio ');
      F.telephone.focus();
      return false
	  }
	//
	//telefono
	valor=F.password.value;
      if(valor=='') {
      alert('El campo ' + F.password.name +   ' no puede estar vacio ');
      F.password.focus();
      return false
	  }
	//
	//contraseña
	valor=F.password2.value;
      if(valor=='') {
      alert('El campo ' + F.password2 +   ' no puede estar vacio ');
      F.password2.focus();
      return false
	  }
	//
	
	
	//
	
	
	 
	 valor=F.password.value;
	   valor1=F.password2.value;
	/*
	if(valor1!='' && valor!='') {
	/*/
	if(valor1!=valor) {
      alert('El campo ' + F.password.name +   ' no puede ser diferente al campo ' + F.password2.name +  ' ');
      F.password2.focus();
       return false
	  } 
     
	/*}*/
	
	
valor1=F.elements[7].value;
      if(valor1!='') {
      return validarEmail(F.elements[7].value,F.elements[7].name,F.elements[7]);
	 }	
	

}
//fin de registro
//
function validar_for1 (F) {

//16 elementos del formulario 
     //mail
	
	 valor=F.elements[0].value;
      if(valor=='') {
      alert('El campo ' + F.elements[0].name +   ' no puede estar vacio ');
      F.elements[0].focus();
      return false
	  }
      //
    
	 //formato 
	 
	
	 //clave
	 valor=F.elements[1].value;
      if(valor=='') {
      alert('El campo ' + F.elements[1].name +   ' no puede estar vacio ');
      F.elements[1].focus();
      return false
	  }
     //temañao
	 
	 if (F.elements[1].value!=''){

	  if ((F.elements[1].value.length < 8)|| (F.elements[1].value.length > 8)) {
	  alert('El campo ' + F.elements[1].name +   ' su contraseña dbe ser de 8 digitos ');
      F.elements[1].focus();
	  return false
	  }
	  
	  }
	 
	
	
	
	valor1=F.elements[0].value;
      if(valor1!='') {
      return validarEmail(F.elements[0].value,F.elements[0].name,F.elements[0]);
	  	  }
	
	

}
//fin de validacion de expedientes 




//
function validar(e) { // 1
     tecla = (document.all) ? e.keyCode : e.which; // 2
    if (tecla==8) return true; // 3
   // patron = /\D/;
	patron =/[A-Za-zñÑ\s]/;
		//patron =/[A-ZÁÉÍÓÚÜÑ]/;
	//patron =/[A-Za-zñÑ\s];
	// 4
    te = String.fromCharCode(tecla); // 5
    return patron.test(te); // 6
} 

function validar_num(e) { // 1
     tecla = (document.all) ? e.keyCode : e.which; // 2
    if (tecla==8) return true; // 3
   // patron = /\D/;
	patron = /\d/; // Solo acepta números
		//patron =/[A-ZÁÉÍÓÚÜÑ]/;
	//patron =/[A-Za-zñÑ\s];
	// 4
    te = String.fromCharCode(tecla); // 5
    return patron.test(te); // 6
} 

function foco_1(e,F){
var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode; 
//alert(F);
//13 corresponde al intro 
if (keyCode == 13) { 

F.focus();

return false
}


}







function foco_letras(e,F){
var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode; 
//alert(F);
//13 corresponde al intro 
if (keyCode == 13) { 

F.focus();

return false
}

else {

 //alert('aca entro');
 return validar(e);
   

}
}


//
function foco_numeros(e,F){
var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode; 
//alert(F);
//13 corresponde al intro 
if (keyCode == 13) { 

F.focus();

return false
}

else {

 //alert('aca entro');
 return validar_num(e);
   

}
}




//FUNCION CAMPOS VACIOS SIMPLES 
function validar_campos(e,number,F)
{
   for (e; e<=number; e++){ 
   var valor = F.elements[e].value;
      if(valor=='') {
       
	  alert('El campo ' + F.elements[e].name +   ' no puede estar vacio ');
      F.elements[e].focus();
      return false
       
          }
   
	
	
	}

}
//fin de campos simples

//validar mail y contraseña




////validar mail y contraseña







//funcion con campos numericos 
function validar_campos155(e,cantidad,F)
{
   for (e; e<=cantidad; e++){ 
   var valor = F.elements[e].value;
   if(valor!='') {
   alert(F.elements[e].name);
   F.elements[e].focus();
	return false
   }
    
	}
}
// fin  funcion  mixta de numeros 
//fucnion validar numeros 
function validar_camposN(e,number,F)
{
   for (e; e<=number; e++){ 
   var valor = F.elements[e].value;
     
	 if(valor=='') {
       
	  alert('El campo ' + F.elements[e].name +   ' no puede estar vacio ');
      F.elements[e].focus();
      return false
       
          }
    
	 	 
	 if(isNaN(valor)==true ) {
          alert('El campo '+ F.elements[e].name + ' tiene que ser numerico');
         F.elements[e].focus();
          return false
       
          }
    
	}

}
//fin funcion validar numeros 

// ingreso solo numeros BLOQUEANDO EL ENTER 
var nav = window.Event ? true : false;
function acceptNum(evt) {
// NOTA: Backspace = 8->si, Enter = 13->no, '0' = 48, '9' = 57, '.'=46->si
var key = nav ? evt.which : evt.keyCode;
return (key < 13 || key ==46 || (key >= 48 && key <= 57 || key == 13  ));
}

//var nav = window.Event ? true : false;  
//validar solo letras


/* patrones esto se cambia por el patron de arriba
patron =/[A-Za-z\s]/;
patron = /\d/; // Solo acepta números
patron = /\w/; // Acepta números y letras
patron = /\D/; // No acepta números
patron =/[A-Za-zñÑ\s]/; // igual que el ejemplo, pero acepta también las letras ñ y Ñ

*/
//fin de validar letras
//cuenta los elmeonto de un formulario
function validar_id(e,number,F)
{
   for (e; e<=number; e++){ 
   var valor = document.forms[F].value;
    
       
	  alert('El campo ' + document.forms[F].elements[e].name +   ' no puede estar vacio ' + e +   ' formulario ' +  F );
      //F.elements[e].focus();
      //return false
       
        
   
	
	
	}

}

//


// fin solo numeros BLOQUEANDO EL ENTER CON EL KEYPRESSS onKeyPress="return acceptNum(event);" 
//RECORRE EL FORMULARIO CON ENTER
/*
Con esta función lo primero q se hace es validar el evento xa saber si se presionó la tecla enter, luego se recorren los elementos del formulario xa saber sobre cual estoy posicionado, como puede suceder que el orden de creación de los elementos no sea el mismo que el del tabindex, se recorre nuevamente los elementos xa saber cual tiene el siguiente tabindex y se ubica el foco sobre este.

No se si exista alguna función más simple pero esta solucionó mis problemas del momento y es la q uso actualimente.

Lo q debes hacer es hacer el llamado de la función en el evento onKeypress del campo deseado y tener organizado el tabindex de todos los campos.

Lo otro q puedes haces es modificar el código de la función Enter para que cuando detecte q se presiono enter ejecute el submit o la funcion q desees ejecutar.
/*

*/
/*
function Enter(Evento, Campo)
{
var keyCode = Evento.keyCode ? Evento.keyCode : Evento.which ? Evento.which : Evento.charCode; 
if (keyCode == 13) 
{ 
var i;
for (i = 0; i < Campo.form.elements.length; i++) 
if (Campo == Campo.form.elements[i]) 
break; 
i = Campo.form.elements[i].tabIndex + 1; 
for( j = 0 ; j < Campo.form.elements.length; j++)
{ 
if( Campo.form.elements[j].tabIndex == i)
break; 
} 
Campo.form.elements[j].focus(); 
return false; 
} 
else 
return true; 
}




//

//VALIDAR NUMERO SI BLOQUEAR EL ENTER FUCNIONA CON onkeydown="return Verificar(this);"

function es_numerico (strString)
{
var strValidChars = "0123456789.";
var strChar;
var blnResult = true;

for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
{
blnResult = false;
}
}
return blnResult;
}

function Verificar (obj)
{
if (es_numerico(obj.value))
{
return true;
}
else
{
return false;
}
}


//FIN VALIDAR NUMEROS SIN BLOQUEAR EL ENTER

/*
function validar_campos(e,number,F)
{
//alert(number);
   for (e; e<=number; e++){ 
  
       alert('El campo  ' + e + ' '+F.elements[e].name);
          
		  // return false
		  }
}

*/
/*
function validar_letras(F)
{

var nombre1 = f.value;
if(isNaN(nombre1)==false) {
alert('campo incorrecto');
F.Nombre_129.focus();
return false
}
//Nombre 2
var checkOK = 'ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ' + 'abcdefghijklmnñopqrstuvwxyzáéíóú ';
var checkStr = F.value;
var allValid = true; 
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('digitos incorrectos'); 
    F.focus(); 
    return (false); 
  } 


/*
function validar_campos1()
{
var s="" 
for (e=0; e<=document.form1.length; e++){ 
if (document.form1.elements[e].value=="" || document.form1.elements[e].value==" "){ 
s=s + document.form1.elements[e].name 
} 
} 
if (s!=""){ 
alert("No llenaste todo el formulario"); 
} else { 
document.form1.submit(); 
} 

}
*/