<script>
    jQuery(function($) {
        var $ = jQuery;
        
  		$('.upload_gallery_button').live('click', function( event ){
            event.preventDefault();

            var target = $(this).data('target-id');
    
            window.parent.loadGalleryFrame($(this), function(attachments) {

                $.each(attachments, function (i, attachment) {
                    if (i == 0) { 
                        jQuery("#" + target).val('');
                    }

                    var ids = jQuery("#" + target).val() + ',' + attachment.id;

                    if (jQuery("#" + target).val().length == 0) {
                        ids = attachment.id;
                    }

                    jQuery("#" + target).val(ids);
                });

                
            });
        });  

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

			switch(type) {
				case "blog_post":
					$(".usecontent").show();
					break;
				default:
					$(".usecontent").hide();
					break;
			}
		});
    });
</script>