$('#intVal1Label').text('Tag Type');
$('#intVal1').html('<option value="1">Open</option><option value="0">Single</option>');
$('#intVal2').html('<option value="1">Prologus</option><option value="2">Capitula</option><option value="3">Imago</option><option value="4">Annotatio</option><option value="5">Subscriptio</option><option value="6">Eusebius</option><option value="7">Tabulae liturgicae</option><option value="8">Epigrammata</option><option value="10">Scholia exegetica</option><option value="9">Others</option>');
$('#stringVal1').hide();$('#stringVal1Span').append('<input type="radio" name="pf" value="p."/>p. <input type="radio" name="pf" value="f."/>f. <input type="text" name="pftext"/> <input type="radio" name="rv" value="r"/>r <input type="radio" name="rv" value="v"/>v');
$('#stringVal1').on('change', function() {
  var vals = $('#stringVal1').val().split('|');
  if (vals.length < 3) return;
  $('input[name=pf]').val([vals[0]]);
  $('input[name=pftext]').val(vals[1]);
  $('input[name=rv]').val([vals[2]]);
});
$('input[name=pf],input[name=rv],input[name=pftext]').on('change', function() {
  $('input[name=rv]').prop('disabled', $('input[name=pf]:checked').val() == 'p.');
  if ($('input[name=pf]:checked').val() == 'p.') $('input[name=rv]').val(['']);
  $('#stringVal1').val($('input[name=pf]:checked').val()+'|'+$('input[name=pftext]').val()+'|'+$('input[name=rv]:checked').val());
});
$('#stringVal2').hide();$('#stringVal2Span').append('Zone <select name="zone"><option></option><option>a</option><option>b</option><option>c</option><option>d</option><option>marg. sup.</option><option>marg. inf.</option><option>marg. dextr.</option><option>marg. sin.</option><option>marg. med.</option><option>marg. med. 1</option><option>marg. med. 2</option><option>marg. med. 3</option></select> Position <select name="position"><option></option><option>quart. 1 inc.</option><option>quart. 1 med.</option><option>quart. 2</option><option>quart. 3</option><option>quart. 4 med.</option><option>quart. 4 des.</option><option>quart. 1 inc. - quart. 2</option><option>quart. 1 inc. - quart. 3</option><option>quart. 1 inc. - quart. 4 med.</option><option>quart. 1 inc. - quart. 4 des.</option><option>quart. 1 med. - quart. 2</option><option>quart. 1 med. - quart. 3</option><option>quart. 1 med. - quart. 4 med.</option><option>quart. 1 med. - quart. 4 des.</option><option>quart. 2 - quart. 3</option><option>quart. 2 - quart. 4 med.</option><option>quart. 2 - quart. 4 des.</option><option>quart. 3 - quart. 4 med.</option><option>quart. 3 - quart. 4 des.</option></select>');
$('#stringVal2').on('change', function() {
  var vals = $('#stringVal2').val().split('|');
  if (vals.length < 2) return;
  $('select[name=zone]').val([vals[0]]);
  $('select[name=position]').val([vals[1]]);
});
$('select[name=zone],select[name=position]').on('change', function() {
  $('#stringVal2').val($('select[name=zone]').val()+'|'+$('select[name=position]').val());
});

$('#prose').val('');