<script>
    jQuery(function($) {
        var $ = jQuery;
        
        // Uploading files
        $('.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();
            }
          });
        });

        $(".backgroundimagesettings").hide();

        $("#type").change(function() {
            var type = $(this).val();

            $(".backgroundimagesettings").hide();

            switch(type) {
                case "style3":
                case "style4":
                case "style5":
                case "style6":
                case "style7":
                    $(".backgroundimagesettings").show();
                    break;
                case "":
                    $(".backgroundimagesettings").hide();
                default:
                    $(".backgroundimagesettings").hide();
                    break;
            }
        });

        $(".backgroundcentersettings").hide();

        $("#type").change(function() {
            var type = $(this).val();

            $(".backgroundcentersettings").hide();

            switch(type) {
                case "style4":
                case "style5":
                case "style6":
                    $(".backgroundcentersettings").show();
                    break;
                case "":
                    $(".backgroundcentersettings").hide();
                default:
                    $(".backgroundcentersettings").hide();
                    break;
            }
        });
    });
</script>