// JavaScript Document
function SoloNumero(e){
				var charCode 
				charCode = e.keyCode 
				//status = charCode 
		if (charCode > 31 && (charCode < 48 || charCode > 57)){
					return false
						}
					return true
					}
function decimales(e){
					var charCode 
					charCode = e.keyCode 
					//status = charCode 
		if (charCode > 31 && (charCode < 48 || charCode > 57)&& charCode != 46){
					return false
					}
					return true
					}

function VMail(campo){
					var exp_reg = /(^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*)@([0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\.[0-9a-zA-Z]{2,3})$/;
					var cadena = document.getElementById(campo).value;
		if(!exp_reg.test(cadena)){
					document.getElementById(campo).focus();
					alert("Direccion de correo electronico invalida");
					//showDialog('Atenci&oacute;n','Direccion de correo electronico invalida','warning');
					}
					return true;
}

function VPass(pass){
					var contra = document.getElementById(pass).value;    
					var error = 0;
					var tam = 0;
					var blanck_space = /\b +/ ; //validamos que no contenga espacios en blanco
					var special_char = /[a-zA-Z]*  [0-9]*/;
					tam = contra.length;
		if(tam < 6){
					showDialog('Atenci&oacute;n','La contrae&ntilde;a no cumple con la cantidad de caracteres requeridos','warning');
					//alert('El password no cumple con la cantidad de caracteres requeridos');
					//error = 1
					document.getElementById(pass).focus();
					}else{
		if(tam > 12){
					showDialog('Atenci&oacute;n','La contrae&ntilde;a exede el limite de caracteres requeridos','warning');
					//alert('El password exede el limite de caracteres requeridos');
					//error = 1
					document.getElementById(pass).focus();
					}else{
		if(blanck_space.test(contra)){
					showDialog('Atenci&oacute;n','La contrae&ntilde;a no debe tener espacios en blanco','warning');
					//alert('El password no debe tener espacios en blanco');
					//error = 1
					document.getElementById(pass).focus();
					}}}
					return true;
					}
function VFecha(inicio,fin,foco){
					var vinicio = document.getElementById(inicio).value;
					var vfin = document.getElementById(fin).value;
					//validar las fechas
					var anio1=parseInt(vinicio.substr(0,4));
					var mes1=parseInt(vinicio.substr(5,2));
					var dia1=parseInt(vinicio.substr(8));
					var anio2=parseInt(vfin.substr(0,4));
					var mes2=parseInt(vfin.substr(5,2));
					var dia2=parseInt(vfin.substr(8));
		if(anio1 > anio2){
					showDialog('Atenci&oacute;n','La fecha de incio no puede ser mayor a la fecha de conclucion','warning');
					document.getElementById(foco).focus();
					}
		if(anio1 == anio2){// anos iguales
		if(mes1 > mes2){
					showDialog('Atenci&oacute;n','El mes de inicio no puede ser mayor ral mes de conclucion ','warning');
					document.getElementById(foco).focus();
					}
				}
		if((mes1 == mes2 ) && (anio1 == anio2)){//meses iwales
		if(dia1 > dia2){
					showDialog('Atenci&oacute;n','El dia de inicio no puede ser mayor al dia de conclucion ','warning');
					document.getElementById(foco).focus();
					}
					}
					//alert(dia1+'-'+mes1+'-'+anio1+'****'+dia2+'-'+mes2+'-'+anio2);
					return true
									}
function VMaxValue(campo1,campo2){
					var valor = document.getElementById(campo1);
					var maxim = document.getElementById(campo2);
		if(valor.value != ""){
		if(valor.value > maxim.value){
					showDialog('Atenci&oacute;n','No puede exceder el vamor maximo','warning');
					valor.focus();
					}
					}else{
					showDialog('Atenci&oacute;n','Por favor indique un valor','warning');
					valor.focus();
					}
					return true;
								}
function RevisarForm(frm){
		var formu = document.getElementById(frm);
		var campo = 0;
		for(i = 0; i<formu.elements.length;i++){
					switch(formu.elements[i].type){
					case 'text': if(formu.elements[i].value == ""){ campo++; }  break;
					//case 'checkbox': if(formu.elements[i].checked){ campo++; } break;
					case 'select': if(formu.elements[i].value == 0){ campo++; } break;
					case 'textarea': if(formu.elements[i].value == ""){ campo++; } break;
					}                              
						}              
		if(campo != 0){
			return false;
		}else{
			return true;
		}
}

function validacion(frm){
	var x;
	x = RevisarForm(frm);

	if(x){
		document.getElementById(frm).submit();
	}else{
		alert('Debe rellenar todos los campos');
	}
}