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

		    window.parent.loadImageFrame($(this), function(attachment) {
		    	jQuery("#image").val(attachment.id);
		    	$('#image-thumb').attr('src', attachment.url);
		    	
		    	if ( $('#preview-content').length > 0 ) {
                  $('#preview').click();
                }
		    });
		});
	});
</script>