function checkTab(){
// función para cambio en selección del tipo de autorizado (para uso o para retiro)
miForm	=	document.f;

 if(miForm.tipo.selectedIndex==0 ){
	document.getElementById("sexo_tr").style.display					=	"";
	document.getElementById("fechaNacimiento_tr").style.display			=	"";
	document.getElementById("nacionalidad_id_tr").style.display			=	"";
	document.getElementById("estadoCivil_tr").style.display				=	"";
	document.getElementById("parentesco_id_tr").style.display			=	"";
	document.getElementById("profesion_id_tr").style.display			=	"";
//	document.getElementById("div1_tr").style.display					=	"";		
//	document.getElementById("dir_titulo_tr").style.display				=	""; 
	document.getElementById("pais_id_tr").style.display					=	""; 
	document.getElementById("division_id_tr").style.display				=	""; 
	document.getElementById("subdivision_id_tr").style.display			=	""; 
	document.getElementById("descripcion_tr").style.display				=	""; 
//	document.getElementById("celular_tr").style.display					=	""; 
	document.getElementById("telefono1_tr").style.display				=	""; 
	document.getElementById("telefono2_tr").style.display				=	""; 
	document.getElementById("tel_label_tr").style.display				=	""; 
	
	document.getElementById("email1_tr").style.display					=	""; 
	document.getElementById("email2_tr").style.display					=	""; 
	document.getElementById("div2_tr").style.display					=	""; 
	document.getElementById("preferencias_tit_tr").style.display		=	""; 
	document.getElementById("preferencias_tr").style.display			=	""; 
	document.getElementById("autorizaciones_tit_tr").style.display		=	""; 
	document.getElementById("autorizaciones_tr").style.display			=	""; 
	document.getElementById("div3_tr").style.display					=	""; 

	document.getElementById("sexo").selectedIndex						=	-1;
	document.getElementById("nacionalidad_id").selectedIndex			=	-1;
	document.getElementById("estadoCivil").selectedIndex				=	-1;
	document.getElementById("profesion_id").selectedIndex				=	-1;
	document.getElementById("parentesco_id").selectedIndex				=	-1;
	document.getElementById("pais_id").selectedIndex					=	-1;
	document.getElementById("division_id").selectedIndex				=	-1; 
	document.getElementById("subdivision_id").options.length			=	0; 
	document.getElementById("descripcion").value						=	""; 
//	document.getElementById("celular_tr").style.display					=	"none"; 
	document.getElementById("telefono1").value							=	""; 
	document.getElementById("tipoTelefono1").selectedIndex				=	-1;
	document.getElementById("tipoTelefono2").selectedIndex				=	-1;


	document.getElementById("cod_pais1").value							=	"";
	document.getElementById("cod_pais2").value							=	"";
	document.getElementById("tel1").value								=	"";
	document.getElementById("tel2").value								=	"";
	document.getElementById("extension1").value							=	"";
	document.getElementById("extension2").value							=	"";
	document.getElementById("email1").value								=	""; 
//	document.getElementById("email2_tr").style.display					=	"none"; 
//	document.getElementById("preferencia_id").value						=	"0"; 
//	document.getElementById("autorizaciones_tr").style.display			=	"none"; 	
	miForm.preferencia_id[0].checked									=	false; 
	}
 if(miForm.tipo.selectedIndex==1 ){
	document.getElementById("sexo_tr").style.display					=	"none";
	document.getElementById("fechaNacimiento_tr").style.display			=	"none";
	document.getElementById("nacionalidad_id_tr").style.display			=	"none";
	document.getElementById("estadoCivil_tr").style.display				=	"none";
	document.getElementById("profesion_id_tr").style.display			=	"none";
	document.getElementById("parentesco_id_tr").style.display			=	"none";
//	document.getElementById("div1_tr").style.display					=	"none";		
//	document.getElementById("dir_titulo_tr").style.display				=	"none"; 
	document.getElementById("pais_id_tr").style.display					=	"none"; 
	document.getElementById("division_id_tr").style.display				=	"none"; 
	document.getElementById("subdivision_id_tr").style.display			=	"none"; 
	document.getElementById("descripcion_tr").style.display				=	"none"; 
//	document.getElementById("celular_tr").style.display					=	"none"; 
	document.getElementById("telefono1_tr").style.display				=	"none"; 
	document.getElementById("telefono2_tr").style.display				=	"none"; 
	document.getElementById("tel_label_tr").style.display				=	"none"; 

	document.getElementById("email1_tr").style.display					=	"none"; 
	document.getElementById("email2_tr").style.display					=	"none"; 
	document.getElementById("div2_tr").style.display					=	"none"; 
	document.getElementById("preferencias_tit_tr").style.display		=	"none"; 
	document.getElementById("preferencias_tr").style.display			=	"none"; 
	document.getElementById("autorizaciones_tit_tr").style.display		=	"none"; 
	document.getElementById("autorizaciones_tr").style.display			=	"none"; 
	document.getElementById("div3_tr").style.display					=	"none"; 
	
	document.getElementById("sexo").selectedIndex						=	0;
	document.getElementById("nacionalidad_id").selectedIndex			=	0;
	document.getElementById("estadoCivil").selectedIndex				=	0;
	document.getElementById("profesion_id").selectedIndex				=	0;
	document.getElementById("parentesco_id").selectedIndex				=	0;
	document.getElementById("pais_id").selectedIndex					=	0;
	document.getElementById("division_id").selectedIndex				=	0; 
	//si no hay provincias ni cantones agregar una opcion y seleccionarla para pasar la validacion
	obj = document.getElementById("division_id");
	if(obj.options.length==0) {
		with (obj) {
			newItem = options.length;
			options[newItem] = new Option("0");
			options[newItem].value = 0;
			obj.selectedIndex = 0;
			}
		}
	obj = document.getElementById("subdivision_id");
	if(obj.options.length==0) {
		with (obj) {
			newItem = options.length;
			options[newItem] = new Option("0");
			options[newItem].value = 0;
			obj.selectedIndex = 0;
			}
		}
//	document.getElementById("subdivision_id").selectedIndex=0; 

	document.getElementById("descripcion").value					=	"x"; 
//	document.getElementById("celular_tr").style.display				=	"none"; 
	document.getElementById("telefono1").value						=	"0"; 
	document.getElementById("telefono2").value						=	""; 
	document.getElementById("cod_pais1").value						=	"1"; 
	document.getElementById("tel1").value							=	"0000-0000"; 
	document.getElementById("extension1").value						=	"0"; 
	document.getElementById("tipoTelefono1").selectedIndex			=	0;
	document.getElementById("tipoTelefono2").selectedIndex			=	-1;
	document.getElementById("email1").value							=	"a@a.com"; 
//	document.getElementById("email2_tr").style.display				=	"none"; 
	miForm.preferencia_id[0].checked=true; 
//	document.getElementById("autorizaciones_tr").style.display		=	"none"; 	
	
	}		
}
// función para cambio en selección del tipo de autorizado (para uso o para retiro)
// --------------------------------------------------------------------------------


// funciones para recargar provincias y cantones con el cambio de país

// esta funcion se activa al cambiar el pais y hace un submit al iframe cambio_pais_frame
function cambio_pais(id) {
	window.cambio_pais_frame.document.f.pais_id.value = id;
	window.cambio_pais_frame.document.f.submit();
	if(id==188) {
		document.getElementById("subdivision_id_tr").style.display	=	"";
		} else {
		document.getElementById("subdivision_id_tr").style.display	=	"none";
		}
	}

// esta funcion se llama desde info_general_Cambio_pais.cfm una vez que se han obtenido los valores para actualizar el cfinput division_id
// correspondientes al pais seleccionado
function actualizar_divisiones(divisiones, ids, pais_id) {
	obj = document.f.division_id;
	with (obj) {
		 obj.options.length 										=	0;
		 for (i = 0; i < divisiones.length; i++) {
			newItem													=	options.length;
			options[newItem]										=	new Option(divisiones[i]);
			options[newItem].value									=	ids[i];
			}
		obj.selectedIndex											=	-1;
		}
	document.f.subdivision_id.options.length						=	0;
	if(pais_id!=188) {
		actualizar_subdivisiones('', '1', pais_id);
		}
	}




// esta funcion se activa al cambiar la division (provincia) y hace un submit al iframe cambio_division_frame
function cambio_division(pais_id, id) {
	window.cambio_division_frame.document.f.pais_id.value			=	pais_id;
	window.cambio_division_frame.document.f.division_id.value		=	id;
	window.cambio_division_frame.document.f.submit();
	}


// esta funcion se llama desde info_general_Cambio_pais.cfm una vez que se han obtenido los valores para actualizar el cfinput subdivision_id
// correspondientes al pais seleccionado
function actualizar_subdivisiones(subdivisiones, ids, pais_id) {
	obj = document.f.subdivision_id;
	if(pais_id==188) {
		with (obj) {
			 obj.options.length										=	0;
			 for (i = 0; i < subdivisiones.length; i++) {
				newItem												=	options.length;
				options[newItem]									=	new Option(subdivisiones[i]);
				options[newItem].value								=	ids[i];
				}
			  obj.selectedIndex										=	-1;
			}
	} else {
		with (obj) {
			obj.options.length										=	0;
			newItem													=	options.length;
			options[newItem]										=	new Option('USA');
			options[newItem].value									=	1;
			obj.selectedIndex										=	0;
			}
		}
	}



// funciones para recargar provincias y cantones con el cambio de país
// -------------------------------------------------------------------

function openwin(p,h,w) {
//	p	=	"interna_tarifas.cfm";
	t	=	(screen.availHeight / 2) - (h / 2);
	l	=	(screen.availWidth / 2) - (w / 2);
	c	=	window.open( p, 'JetBox', 'top=' + t + ',left=' + l + ',width=' + w + ',height=' + h + ',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1' );
	c.focus();
	return false;
	}

function tarifas() {
	p	=	"interna_tarifas.cfm";
	t	=	(screen.availHeight / 2) - 295;
	l	=	(screen.availWidth / 2) - 225;
	c	=	window.open( p, 'Tarifas', 'top=' + t + ',left=' + l + ',width=450,height=590,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0' );
	c.focus();
	}
	
function tutor() {
	p	=	"tutor.htm";
	t	=	(screen.availHeight / 2) - 250;
	l	=	(screen.availWidth / 2) - 420;
	c	=	window.open( p, 'Tutor', 'top=' + t + ',left=' + l + ',width=840,height=500,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
	c.focus();
	}

function cambio_tipo_id(){
	miForm																												=	document.f;
	if(miForm.tipoIdentificacion.selectedIndex==0 ){
		//tipo cédula ocultar formato libre (identificacion)
		document.getElementById("tr_identificacion_ced").style.display													=	"";
		document.getElementById("identificacion_ced").value																=	"";
		document.getElementById("tr_identificacion").style.display														=	"none";
		// esta línea es para que no se muestre doble en el alert de la validación el mensaje de indique su número de identificación
		if(document.getElementById("identificacion").value.length==0) document.getElementById("identificacion").value="0";
		} else {
		//tipo pasaporte o residencia ocultar formato cedula (identificacion_ced)
		document.getElementById("tr_identificacion_ced").style.display													=	"none";
		// esta línea es para que no se muestre doble en el alert de la validación el mensaje de indique su número de identificación
		if(document.getElementById("identificacion_ced").value==0) document.getElementById("identificacion_ced").value	=	"0-0000-0000";
		document.getElementById("tr_identificacion").style.display														=	"";
		document.getElementById("identificacion").value																	=	"";
		}
	}

function cambio_tipo_id_apod(){
	miForm																												=	document.f;
	if(miForm.apoderado_tipoIdentificacion.selectedIndex==0 ){
		//tipo cédula ocultar formato libre (identificacion)
		document.getElementById("tr_identificacion_ced_apod").style.display												=	"";
		document.getElementById("apoderado_identificacion_ced").value													=	"";
		document.getElementById("tr_identificacion_apod").style.display													=	"none";
		// esta línea es para que no se muestre doble en el alert de la validación el mensaje de indique su número de identificación
		if(document.getElementById("apoderado_identificacion").value.length==0) document.getElementById("apoderado_identificacion").value	=	"0";
		} else {
		//tipo pasaporte o residencia ocultar formato cedula (identificacion_ced)
		document.getElementById("tr_identificacion_ced_apod").style.display												=	"none";
		// esta línea es para que no se muestre doble en el alert de la validación el mensaje de indique su número de identificación
		if(document.getElementById("apoderado_identificacion_ced").value==0) document.getElementById("apoderado_identificacion_ced").value	=	"0-0000-0000";
		document.getElementById("tr_identificacion_apod").style.display													=	"";
		document.getElementById("apoderado_identificacion").value														=	"";
		}
	}
// fuciones para manejo de tipo de identificación e identificación
// ---------------------------------------------------------------


// funciones para manejo de tipos de teléfono y teléfonos
function validar_tipos_tels(n) {
	if(document.f.tipo_id.value==1) {
		if(document.f.cedulaJuridica.value.length<12) {
			alert(document.f.aviso_long_ced_jur.value);
			document.f.cedulaJuridica.focus();
			return false;
			}
		if(document.f.apoderado_tipoIdentificacion.selectedIndex==0&&document.f.apoderado_identificacion_ced.value.length<11) {
			alert(document.f.aviso_long_ced_apod.value);
			document.f.apoderado_identificacion_ced.focus();
			return false;
			}
		}

	if(document.f.tipo_id.value==2&&document.f.tipoIdentificacion.selectedIndex==0&&document.f.identificacion_ced.value.length<11) {
		alert(document.f.aviso_long_ced.value);
		document.f.identificacion_ced.focus();
		return false;
		}

	if(document.f.check_celular.value==1) {
		celular		=	eval("document.f.celular");
		cod_pais	=	eval("document.f.cod_pais0");
		tel			=	eval("document.f.tel0");

		if(tel.value.length!=0&&cod_pais.value.length==0||tel.value.length!=0&&cod_pais.value=="000") {
			alert(document.f.msjCodTelefono1.value);
			cod_pais.focus();
			return false; 
			}
		if(tel.value.length!=0&&tel.value.length<9) {
			alert(document.f.msjLongTel.value);
			tel.focus();
			return false;
			}
		if(tel.value.length==0) {
			cod_pais.value	=	"";
			celular.value	=	"";
			}
	}


//	revisar telefonos según n (n val de campo + 1)
	n = document.f.nTipos_Tel.value;
	if(n==0) {
		k = 1;
		} else {
		k = n-1;
		}
	for (i=1; i<=k; i++) {
		tel			=	eval("document.f.telefono"+i);
		numero		=	eval("document.f.tel"+i);
		cod_pais	=	eval("document.f.cod_pais"+i);
		tipo_tel	=	eval("document.f.tipoTelefono"+i);
		if(tel.value.length!=0&&tipo_tel.selectedIndex==-1&&n>0) {
			alert(document.f.msjTipoTel.value); 
			tipo_tel.focus();
			return false; 
			}
		if(numero.value.length!=0&&cod_pais.value.length==0||numero.value.length!=0&&cod_pais.value=="000") {
			alert(document.f.msjCodTelefono1.value);
			cod_pais.focus();
			return false; 
			}
		if(numero.value.length!=0&&numero.value.length<9) {
			alert(document.f.msjLongTel.value);
			numero.focus();
			return false;
			}
		if(numero.value.length==0) {
			cod_pais.value			=	"";
			tipo_tel.selectedIndex	=	-1;
			tel.value				=	"";
			}
		if(tel.value.length==0&&tipo_tel.selectedIndex!=-1) {
			tipo_tel.selectedIndex	=	-1;
			}
		}
	return true;
}

function camb_tipo_tel(linea) {
	if(document.getElementById("tipoTelefono" + linea).options[document.getElementById("tipoTelefono" + linea).selectedIndex].value==1) {
		document.getElementById("span_ext" + linea).style.display			=	"";
		} else {
		document.getElementById("span_ext" + linea).style.display			=	"none";
		document.getElementById("extension" + linea).value					=	"";
		update_full_telefono(linea);
		}
	}
	
function update_full_telefono(linea) {
	if(linea==0) {
		celular		=	eval("document.f.celular");
		cod_pais	=	eval("document.f.cod_pais" + linea);
		tel			=	eval("document.f.tel" + linea);

		if(cod_pais.value.length==0) { cod_pais.value = "" }
		else if(cod_pais.value.length<2) { cod_pais.value = "00" + cod_pais.value; }
		else if(cod_pais.value.length<3) { cod_pais.value = "0" + cod_pais.value; };

		if(celular.value=="() " || celular.value.length==0 && cod_pais.value.length==0 && tel.value.length==0 || celular.value.length==0 && cod_pais.value=="000" && tel.value.length==0) {
			celular.value = "";
			} else {
			celular.value = "(" + eval("document.f.cod_pais" + linea).value + ") " + eval("document.f.tel" + linea).value;
			}
		} else {
		if(eval("document.f.extension" + linea).value.length!=0) {
			ext		=	" x" + eval("document.f.extension" + linea).value;
			} else {
			ext = "";	
			}
		telefono	=	eval("document.f.telefono" + linea);
		cod_pais	=	eval("document.f.cod_pais" + linea);
		tel			=	eval("document.f.tel" + linea);
		
		if(cod_pais.value.length==0) { cod_pais.value = "" }
		else if(cod_pais.value.length<2) { cod_pais.value = "00" + cod_pais.value; }
		else if(cod_pais.value.length<3) { cod_pais.value = "0" + cod_pais.value; };
		
		if(telefono.value=="() " || telefono.value.length==0 && cod_pais.value.length==0 && tel.value.length==0 || telefono.value.length==0 && cod_pais.value=="000" && tel.value.length==0) {
			telefono.value = "";
			} else {
			telefono.value = "(" + eval("document.f.cod_pais" + linea).value + ") " + eval("document.f.tel" + linea).value + ext;
			}
		}
	}
	

// Funcion para Mostrar una Fila de una Tabla
function mostrarRow(){
 miForm	=	document.formDeCalculos;

 if(miForm.pv_Tipo_deSolicitud[0].checked){
	document.getElementById("msjAdvertencia").style.display="";
	}
 if(miForm.pv_Tipo_deSolicitud[1].checked ){
	document.getElementById("msjAdvertencia").style.display="none";
	}		
}	
	
// funciones para manejo de tipos de teléfono y teléfonos
// ------------------------------------------------------

function chk_datos_calculadora_preliminar() {
	
	}

function desactivar_datos_calculadora() {
	document.getElementById("nId_Contrato").disabled		=	true;
	document.getElementById("nId_Arancel").disabled			=	true;
	document.getElementById("nValorMercaderia").disabled	=	true;
	document.getElementById("nPeso").disabled				=	true;
	document.getElementById("sTipoDePeso").disabled			=	true;
	document.getElementById("sTipoDeDimensiones").disabled	=	true;
	document.getElementById("nLargo").disabled				=	true;
	document.getElementById("nAncho").disabled				=	true;
	document.getElementById("nAlto").disabled				=	true;
	document.getElementById("submit").disabled				=	true;
	}

function activar_datos_calculadora() {
	document.getElementById("nId_Contrato").disabled		=	false;
	document.getElementById("nId_Arancel").disabled			=	false;
	document.getElementById("nValorMercaderia").disabled	=	false;
	document.getElementById("nPeso").disabled				=	false;
	document.getElementById("sTipoDePeso").disabled			=	false;
	document.getElementById("sTipoDeDimensiones").disabled	=	false;
	document.getElementById("nLargo").disabled				=	false;
	document.getElementById("nAncho").disabled				=	false;
	document.getElementById("nAlto").disabled				=	false;
	document.getElementById("submit").disabled				=	false;
	}

function habilitar_formulario() {
	if(document.formDeCalculos.nombre_completo.value!=""&&document.formDeCalculos.correo_electronico.value!="") {
		activar_datos_calculadora();
		} else {
		desactivar_datos_calculadora();
		}
	if(document.formDeCalculos.correo_electronico_ori.value!="null"&&document.formDeCalculos.correo_electronico.value!=document.formDeCalculos.correo_electronico_ori.value) {
		document.getElementById("correo_electronico_ori_aviso").style.display="";
		}
	if(document.formDeCalculos.correo_electronico_ori.value=="null"||document.formDeCalculos.correo_electronico_ori.value!="null"&&document.formDeCalculos.correo_electronico.value==document.formDeCalculos.correo_electronico_ori.value) {
		document.getElementById("correo_electronico_ori_aviso").style.display="none";
		}
	}

function no_indicar_f_nac() {
	if(document.f.no_indicar_fecha_nac.checked==true) {
		document.f.fechaNacimiento_dy.selectedIndex =	-1;
		document.f.fechaNacimiento_mn.selectedIndex =	-1;
		document.f.fechaNacimiento_yr.selectedIndex =	-1;
		document.f.fechaNacimiento_dy.disabled		=	true;
		document.f.fechaNacimiento_mn.disabled 		=	true;
		document.f.fechaNacimiento_yr.disabled 		=	true;
		document.f.fechaNacimiento.value			=	"";
		} else {
		document.f.fechaNacimiento_dy.selectedIndex =	0;
		document.f.fechaNacimiento_mn.selectedIndex =	0;
		document.f.fechaNacimiento_yr.selectedIndex =	0;
		document.f.fechaNacimiento_dy.disabled		=	false;
		document.f.fechaNacimiento_mn.disabled 		=	false;
		document.f.fechaNacimiento_yr.disabled 		=	false;
		f_val										=	document.f.fechaNacimiento_dy.selectedIndex + "/";
		f_val										=	f_val + document.f.fechaNacimiento_mn.selectedIndex + "/";
		f_val										=	f_val + document.f.fechaNacimiento_yr.selectedIndex;
		document.f.fechaNacimiento.value			=	f_val;
		}
	}