<script>
	jQuery(function($) {
		$('.allfields').hide();
		$('.imagesize').hide();
		$('.excerptlength').hide();
		var options = $("#field").html();

		$('#type').change(function() {
			$('.allfields').hide();
			$('.imagesize').hide();
			$('.excerptlength').hide();

			var text = $("#type :selected").text().toLowerCase();

			$("#field").html(options);
			$('#field :not( [value^="' + text.substr(0, 3) + '"], [value="title"], [value^="content"], [value^="featured_images"], [value^="featured_color"], [value^="permalink"] )' ).remove();
			$('.allfields').show();
		});

		$('#field').change(function() {
			var selected = $("#field :selected").text().toLowerCase();
			$('.imagesize').hide();
			$('.excerptlength').hide();

			if ( selected === 'featured images' || selected === 'cover image' || selected === 'author image' || selected === 'logo' || selected === 'company logo' || selected === 'member photo' ) {
				$('.imagesize').show();
			} else {
				var featimg = document.getElementById('size');
				featimg.selectedIndex = 0;
			}

			if ( selected === 'content' ) {
				$('.excerptlength').show();
			} else {
				var exclen = document.getElementById('excerpt_length');
				exclen.value = '';
			}
		});
	});
</script>