function lwrte_image(field_name, url, type, win) {
	var self = this;
  var panel = $('<div></div>').addClass('rte-panel').css('position','relative');
	panel.dialog({ title:'Upload Image/File', width: 400, height: 200, resizable:true, zIndex:400000 }) ;
	panel.append('\
<p>Use this form to upload an file/image from your desktop. Just click the Upload button to select the file/image from your desktop, then click OK when you are done. (If you are using this form to embed an image, it should be no wider than 550 pixels.)</p><p><input type="text" id="url" size="30" value=""><button id="file">Upload</button></p>\
<div class="clear"></div>\
<p class="submit"><button id="ok">Ok</button><button id="cancel">Cancel</button></p>'
).show();

	var url = $('#url', panel);
	var upload = $('#file', panel).upload( {
		autoSubmit: false,
		action: '/default/upload/',
		onSelect: function() {
			var file = this.filename();
			var ext = (/[.]/.exec(file)) ? /[^.]+$/.exec(file.toLowerCase()) : '';
			if(!(ext && /^(jpg|png|jpeg|gif|pdf)$/.test(ext))){
				alert('Invalid file extension');
				return;
			}

			this.submit();
		},
		onComplete: function(response) {
			if(response.length <= 0)
				return;

			response	= eval("(" + response + ")");
			if(response.error && response.error.length > 0)
				alert(response.error);
			else
				url.val((response.file && response.file.length > 0) ? response.file : '');
		}
	});

	$('#cancel', panel).click( function() { panel.remove();$('.rte_dialog').dialog('destroy'); return false;} );
	$('#ok', panel).click(
		function() {
			win.document.forms[0].elements[field_name].value  = url.val();
      panel.remove();
			$('.rte_dialog').dialog('destroy');
			return false;
		}
	)
}