// JavaScript Document
/*function validar_vacios(form){
	camposTexto = form.elements;
	for (x=0; x < camposTexto.length; x++) {
		//if(camposTexto[x].name!="cel" && camposTexto[x].name!="anexo")
		if(camposTexto[x].value=="" && camposTexto[x].type=="text" && camposTexto[x].disabled==false) {
			camposTexto[x].focus();
			alert("El campo " + camposTexto[x].name + " está vacio y es OBLIGATORIO");
			return (false);
		}
	}
	return (true);
}*/

function validar_vacios(form){
	
	if(document.form1.num_carnet.value=="") {
		document.form1.num_carnet.focus();
		alert("El campo Número de Carnet está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.nombre_trabajador.value=="") {
		document.form1.nombre_trabajador.focus();
		alert("El campo Apellidos y Nombres está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.dni_trabajador.value=="") {
		document.form1.dni_trabajador.focus();
		alert("El campo DNI está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.email_trabajador.value=="") {
		document.form1.email_trabajador.focus();
		alert("El campo E-Mail está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.paterno.value=="") {
		document.form1.paterno.focus();
		alert("El campo Paterno está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.materno.value=="") {
		document.form1.materno.focus();
		alert("El campo Materno está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.nombre.value=="") {
		document.form1.nombre.focus();
		alert("El campo Nombre está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.nro_documento.value=="") {
		document.form1.nro_documento.focus();
		alert("El campo Nro Documento está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.direccion.value=="") {
		document.form1.direccion.focus();
		alert("El campo Direccion está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.distrito.value=="") {
		document.form1.distrito.focus();
		alert("El campo Distrito está vacio y es OBLIGATORIO");
		return (false);
	}
	if(document.form1.telefono.value=="") {
		document.form1.telefono.focus();
		alert("El campo Telefono está vacio y es OBLIGATORIO");
		return (false);
	}
	return (true);
}

function centrar_formulario(w,h){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	window.moveTo(LeftPosition,TopPosition);
	window.resizeTo (w,h);
}	
/*
function validar_numero(numero,tamano){
	if(numero.length!=tamano)
		return (false );	
	var number = parseInt(numero);
	if (isNaN(number)==true)
		return (false);
	if(tamano>0){
		limite=1;
		for(i=0;i<tamano;i++)		
			limite=10*limite;
		if((number<(limite/10))|| (number>=limite))
			return (false);
	}
	return (true);	
}
*/
function validar_numero(numero,tamano){
	var number = parseInt(numero);
	if (isNaN(number)==true)
		return (false);
	if(tamano>0){
		if(numero.length!=tamano)
			return (false);	
		for(i=0;i<numero.length;i++){ 
			if(isNaN(parseInt(numero.substring(i,i+1)))==true)
				return (false);
		}
	}
	return (true);	
}
function validar_email(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
    //alert("La dirección de email " + valor + " es correcta.") 
    return (true)
  } else {
    //alert("La dirección de email es incorrecta.");
    return (false);
  }
}
