function valida(form)
{	
	status="";
	control="";
		
	if (trim(form.men.value) == "")
		control=form.men;
	if (trim(form.ema.value) == "")
		control=form.ema;
	if (trim(form.nic.value) == "")
		control=form.nic;
	
	email1=form.ema.value;
	if (trim(email1) != "")
	{
		if ((email1.indexOf("@") == -1) || (email1.indexOf(".") == -1) || (email1.indexOf(" ") != -1))
		{
			alert('Debes escribir una dirección de e-mail válida');
			staus = 'La dirección e-mail no es válida'
			form.ema.focus();
			form.ema.select();
			return false;			
		}
	}				
				
				
	
	if (trim(form.archivo.value) != "")
	{
		var n,aux,aux2;			
		n=form.archivo.value.length;
		aux=form.archivo.value.substring(n-3,n);
		if ((aux.toLowerCase()!='jpg')&&(aux.toLowerCase()!='gif')&&(aux.toLowerCase()!='png'))
		{								
			control="007";
		}				
	}	
	
	
	
	if ((control != "")||(control == "007"))
	{
		if (control == "007")
		{
			alert('El formato del archivo no es permitido...  Debe ser una imagen: .gif, .jpg o .png  ');
			form.archivo.focus();			
		} else {
			alert("ERROR: Existen campos que son obligatorios...");
			status = "Este campo no puede estar en blanco";
			control.focus();
		}
		return false;
	} else { cargar.style.visibility='visible'; return true; }
	
}
	
function trim(s)
{
	while (s.substring(0,1) == ' ')
		s = s.substring(1,s.length);

	while (s.substring(s.length-1,s.length) == ' ')
		s = s.substring(0,s.length-1);
	return s;
}

function confirmar( mensaje, destino)
{
	if (confirm(mensaje))
		location = destino;
}	


function alfa(evt)
{									
	evt = (evt) ? evt : event;	
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));    	
  
    if ( (charCode > 47) && (charCode < 58) || (charCode > 96) && (charCode < 123) || (charCode > 64) && (charCode < 91) || (charCode > 179) && (charCode < 257) || (charCode > 36) && (charCode < 41) ||  (charCode==8) || (charCode==32) || (charCode==46) || (charCode==13) || (charCode==44) || (charCode==58) || (charCode==59) ) 
        return true;
    else
    	return false;
}	

function validactrl(e) {
  tecla = (document.all) ? e.keyCode : e.which;
  return  !(tecla==86 && e.ctrlKey);
}
	
