<script>
    jQuery(function($) {
      var $ = jQuery;
      
      $('.upload_image_button').live('click', function( event ){
        event.preventDefault();
        var target = $(this).data('target-id');

        window.parent.loadImageFrame($(this), function(attachment) {
          jQuery("#" + target).val(attachment.id);
          
          if ( attachment.sizes.thumbnail ) {
            jQuery("#" + target + "-thumb").attr("src", attachment.sizes.thumbnail.url);
          } else {
            jQuery("#" + target + "-thumb").attr("src", attachment.url);
          }

          if ( $('#preview-content').length > 0 ) {
            $('#preview').click();
          }
        });
      });

      $('.heightsetting').hide();

      $('#direction').change(function() {
		$('.heightsetting').hide();

		if ($(this).val() == 'vertical') {
			$('.heightsetting').show();
		}
	});

	$('.imagesettings').hide();

	$('#type').change(function() {				
		if ($(this).val() == 'image') {
			$('.imagesettings').show();
		} else {
			$('.imagesettings').hide();
		}
	});

    });
</script>