var url="";

function sendUrl(url1){
	url=url1;
	return true;
}

$(document).ready(function(){
	$("#depto").change(function () {
		$("#depto option:selected").each(function () {
				id=$(this).val();
				$.post(url, { id: id }, function(data){
				$("#ciudad").html(data);
			});
		});
	})
});

$(document).ready(function(){
	$("#depto_nac_1").change(function () {
		$("#depto_nac_1 option:selected").each(function () {
				id=$(this).val();
				$.post(url, { id: id }, function(data){
				$("#ciudad_nac_1").html(data);
			});
		});
	})
});


function validarReq(){
	objValidacion=new jsValidacion();
	var resultado=true;

	if(resultado){
		objValidacion.setId('titulo');
		objValidacion.setReq();
		resultado=objValidacion.validar();
	} // if

	if(resultado){
		objValidacion.setId('requisito');
		objValidacion.setReq();
		resultado=objValidacion.validar();
	} // if   

	return resultado;
} // validarReq


function validarDepen(){
	objValidacion=new jsValidacion();
	var resultado=true;

	if(resultado){
		objValidacion.setId('nm_depen');
		objValidacion.setReq();
		resultado=objValidacion.validar();
	} // if

	return resultado;
} // validarDepen


function validarPaso(){
	objValidacion=new jsValidacion();
	var resultado=true;

	if(resultado){
		objValidacion.setId('texto');
		objValidacion.setReq();
		resultado = objValidacion.validar();
	} // if 

	return resultado;
} // 



function valSoautpasinsoat(){

	$.validator.addMethod("validarPlaca", function(value, element){
		var placa=/^[a-zA-Z]{3}\d{2,3}[a-zA-Z]{0,1}$/;
		var regex=new RegExp(placa);
		var placa=value.length;
		if(placa!=6) return false;
		return this.optional(element) || regex.test(value);
	}, '<span class="msgErrorJs">Por favor ingrese una placa v&aacute;lida.<span>');

	$(document).ready(function(){
		$("#soautpasinsoat").validate({
			rules: {
				placa: {
					required: true,
					validarPlaca: true
				},
				nombres: {
					required: true,
					maxlength:150
				},
				iden: {
					required: true,
					digits: true,
					rangelength: [6, 11]
				},
				dir_notif: {
					required: true,
					maxlength: 50
				},
				depto: {
					required: true
				},
				ciudad: {
					required: true
				},
				tels: {
					required: false,
					minlength: 7
				},
				annos: {
					required: true
				},
				causal: {
					required: true
				}
			}
		});
	});
	
} // valSoautpasinsoat



function valUpdSoautpasinsoat(){

	$(document).ready(function(){
		$("#registro").validate({
			rules: {
				nombres: {
					required: true,
					maxlength:150
				},
				dir_notif: {
					required: true,
					maxlength: 50
				},
				depto: {
					required: true
				},
				ciudad: {
					required: true
				},
				causal: {
					required: true
				}
			}
		});
	});
} // valUpdSoautpasinsoat



function validarTarjprofbacterio(){
	$(document).ready(function(){
		$("#registro").validate({
			rules: {
				nombres: {
					required: true,
					maxlength:100
				},
				apellidos: {
					required: true,
					maxlength:100
				},
				iden: {
					required: true,
					digits: true,
					maxlength: 50
				},
				iden_exp: {
					required: true,
					maxlength: 50
				},
				dia_nac: {
					required: true
				},
				mes_nac: {
					required: true
				},
				anno_nac: {
					required: true
				},
				direccion_resi: {
					required: true,
					maxlength: 100
				},
				telf_resi: {
					required: true,
					maxlength: 100
				},
				universidad: {
					required: true,
					maxlength: 100
				},
				ciudad_univ: {
					required: true,
					maxlength: 100
				},
				registro_entidad: {
					required: true,
					maxlength: 100
				},
				registro_numero: {
					required: true,
					digits: true,
					maxlength: 100
				},
				dia_registro: {
					required: true
				},
				mes_registro: {
					required: true
				},
				anno_registro: {
					required: true
				},
				otros_univer: {
					maxlength: 100
				},
				otros_univer_ciudad: {
					maxlength: 100
				},
				otros_pos_univer: {
					maxlength: 100
				}
			}
		});
	});
	
} // validarTarjprofbacterio




function validarParametros(){
	
	$(document).ready(function(){
		$("#registro").validate({
			rules: {
				parametro: {
					required: true
				}
			}
		});
	});
	
} // validarParametros



function valConsultar(){

	$.validator.addMethod("validarPlaca", function(value, element){
		var placa=/^[a-zA-Z]{3}\d{2,3}[a-zA-Z]{0,1}$/;
		var regex=new RegExp(placa);
		var placa=value.length;
		if(placa!=6) return false;
		return this.optional(element) || regex.test(value);
	}, '<span class="msgErrorJs">Por favor ingrese una placa v&aacute;lida.<span>');

	$(document).ready(function(){
		$("#consultar").validate({
			rules: {
				placa: {
					required: true,
					validarPlaca: true
				},
				iden: {
					required: true,
					digits: true,
					rangelength: [6, 11]
				}
			}
		});
	});
	
} // valConsultarSoat



function valConsultarBact(){

	$(document).ready(function(){
		$("#soautpasinsoat").validate({
			rules: {
				iden: {
					required: true,
					digits: true,
					rangelength: [6, 11]
				},
				dia_nac: {
					required: true
				},
				mes_nac: {
					required: true
				},
				anno_nac: {
					required: true
				}
			}
		});
	});
	
} // valConsultarBact


function otraCausal(elemento){
	if(elemento.value=="otra"){
		document.getElementById("otraCausal").style.display = "block";
	} // if
	else{
		document.getElementById("otracausal").value = "";
		document.getElementById("otraCausal").style.display = "none";
	} // else
} // otraCausal


function cambiarPais(elemento){
	//alert(elemento.value);
	if(elemento.value!=170){
		document.getElementById("depto_nac_2").value = "";
		document.getElementById("ciudad_nac_2").value = "";
		document.getElementById('colombia').style.display="none";
		document.getElementById("otroPais").style.display = "block";
	} // if
	else{
		document.getElementById('colombia').style.display="block";
		document.getElementById("otroPais").style.display = "none";
	}
} // cambiarPais

function disabledInput(elemento){
	if(elemento.value=='si'){
		document.registro.enti_vinc1.disabled=false;
		document.registro.tipo_enti1_oficial.disabled=false;
		document.registro.tipo_enti1_privada.disabled=false;
		document.registro.enti_vinc2.disabled=false;
		document.registro.tipo_enti2_oficial.disabled=false;
		document.registro.tipo_enti2_privada.disabled=false;
	} // if
	else{
		document.registro.enti_vinc1.disabled=true;
		document.registro.tipo_enti1_oficial.disabled=true;
		document.registro.tipo_enti1_privada.disabled=true;
		document.registro.enti_vinc2.disabled=true;
		document.registro.tipo_enti2_oficial.disabled=true;
		document.registro.tipo_enti2_privada.disabled=true;
	}
} // disabledInput


function valSolcertimpvehi(){
	$.validator.addMethod("validarPlaca", function(value, element){
		var placa=/^[a-zA-Z]{3}\d{2,3}[a-zA-Z]{0,1}$/;
		var regex=new RegExp(placa);
		var placa=value.length;
		if(placa!=6) return false;
		return this.optional(element) || regex.test(value);
	}, '<span class="msgErrorJs">Por favor ingrese una placa v&aacute;lida.<span>');

	$(document).ready(function(){
		$("#solcertimpvehi").validate({
			rules: {
				placa: {
					required: true,
					validarPlaca: true
				},
				nombres: {
					required: true,
					maxlength:150
				},
				iden: {
					required: true,
					digits: true,
					rangelength: [6, 11]
				},
				dir_notif: {
					required: true,
					maxlength:100
				},
				depto: {
					required: true
				},
				ciudad: {
					required: true
				},
				tels: {
					required: false,
					minlength: 7,
					maxlength:30
				},
				email: {
					email: true,
					maxlength:50
				},
				annos: {
					required: true,
					maxlength:255
				}
			}
		});
	});
} // valSolcertimpvehi



function valUpdSolcertimpvehi(){

	$(document).ready(function(){
		$("#registro").validate({
			rules: {
				nombres: {
					required: true,
					maxlength:150
				},
				dir_notif: {
					required: true,
					maxlength: 50
				},
				depto: {
					required: true
				},
				ciudad: {
					required: true
				},
				annos: {
					required: true
				}
			}
		});
	});
	
} // valUpdSolcertimpvehi




function valSolregiimpvehi(){

	$.validator.addMethod("validarPlaca", function(value, element){
		var placa=/^[a-zA-Z]{3}\d{2,3}[a-zA-Z]{0,1}$/;
		var regex=new RegExp(placa);
		var placa=value.length;
		if(placa!=6) return false;
		return this.optional(element) || regex.test(value);
	}, '<span class="msgErrorJs">Por favor ingrese una placa v&aacute;lida.<span>');

	$(document).ready(function(){
		$("#solregiimpvehi").validate({
			rules: {
				placa: {
					required: true,
					validarPlaca: true
				},
				nombres: {
					required: true,
					maxlength:150
				},
				iden: {
					required: true,
					digits: true,
					rangelength: [6, 11]
				},
				dir_notif: {
					required: true,
					maxlength: 50
				},
				depto: {
					required: true
				},
				ciudad: {
					required: true
				},
				tels: {
					required: true,
					minlength: 7
				}
			}
		});
	});
	
} // valSolregiimpvehi


function validarTarjprofmedico(){

	$(document).ready(function(){
		$("#registro").validate({
			rules: {
				solicitud: {
					required: true
				},
				nombres: {
					required: true,
					maxlength:150
				},
				apellidos: {
					required: true,
					maxlength:150
				},
				tipo_iden: {
					required: true
				},
				iden: {
					required: true,
					digits: true,
					rangelength: [6, 11]
				},
				iden_exp: {
					required: true,
					maxlength:25
				},
				dia_nac: {
					required: true
				},
				mes_nac: {
					required: true
				},
				anno_nac: {
					required: true
				},
				lugar_nac: {
					required: true,
					maxlength:25
				},
				dir_envio: {
					required: true,
					maxlength:100
				},
				dir_ciudad: {
					required: true,
					maxlength:100
				},
				tel: {
					required: true,
					maxlength:15
				},
				email: {
					email: true,
					maxlength:50
				},
				ciudad_mil: {
					required: true,
					maxlength:255
				},
				dpto_mil: {
					required: true,
					maxlength:255
				},
				pregrado: {
					required: true,
					maxlength:150
				},
				uni: {
					required: true,
					maxlength:150
				},
				ciudad: {
					required: true,
					maxlength:150
				},
				num_diplo: {
					required: true,
					maxlength:30
				},
				num_acta: {
					required: true,
					maxlength:20
				},
				num_acta: {
					required: true,
					maxlength:20
				},
				d_grado: {
					required: true
				},
				m_grado: {
					required: true
				},
				a_grado: {
					required: true
				},
				num_reg: {
					required: true,
					maxlength:15
				},
				libro: {
					required: true,
					maxlength:15
				},
				folio: {
					required: true,
					maxlength:15
				},
				d_reg: {
					required: true
				},
				m_reg: {
					required: true
				},
				a_reg: {
					required: true
				},
				cod_dptal: {
					required: true,
					digits: true,
					maxlength:2
				},
				num_res: {
					required: true,
					digits: true,
					maxlength:15
				},
				d_regmedico: {
					required: true
				},
				m_regmedico: {
					required: true
				},
				a_regmedico: {
					required: true
				},
				vinculacion: {
					required: true
				}
			}
		});
	});
} // validarTarjprofmedico


function validarRegis(){
	objValidacion=new jsValidacion();
	var resultado=true;

	if(resultado){
		objValidacion.setId('conv_icfes');
		objValidacion.setReq();
		resultado = objValidacion.validar();
	} // if 

	return resultado;
} // 


function disabledInputIden(elemento){
	if(elemento=='cc'){
		document.registro.conv_icfes.disabled=true;
		document.registro.d_conv.disabled=true;
		document.registro.m_conv.disabled=true;
		document.registro.a_conv.disabled=true;
		document.registro.conv_icfes.value='';
		document.registro.d_conv.value='';
		document.registro.m_conv.value='';
		document.registro.a_conv.value='';
		document.getElementById('resultado').innerHTML="";
		document.getElementById('resultado2').innerHTML="";
	} // if
	else{
		document.registro.conv_icfes.disabled=false;
		document.registro.d_conv.disabled=false;
		document.registro.m_conv.disabled=false;
		document.registro.a_conv.disabled=false;
		document.getElementById('resultado').innerHTML="&nbsp;*";
		document.getElementById('resultado2').innerHTML="&nbsp;*";
	}
} // disabledInput
