<script>
	jQuery(function($) {
		// Uploading files
  		$('.upload_image_button').live('click', function( event ){
		    event.preventDefault();

		    window.parent.loadImageFrame($(this), function(attachment) {
		    	jQuery("#custom_icon").val(attachment.id);
		    	$('#custom_icon-thumb').attr('src', attachment.url);

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