Index: css/editimage-rtl.css
===================================================================
--- css/editimage-rtl.css	(revision 12559)
+++ css/editimage-rtl.css	(working copy)
@@ -55,7 +55,7 @@
 
 #img_dim label,
 #img_prop label {
-	margin: 5px 0pt;
+	margin: 5px 0;
 }
 
 #img_dim input,
Index: css/editimage.css
===================================================================
--- css/editimage.css	(revision 12559)
+++ css/editimage.css	(working copy)
@@ -40,13 +40,27 @@
 	padding: 3px;
 }
 
+input[type="text"] {
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
+}
+
 body, td {
 	font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
 }
 
+p.help {
+	margin: 4px 0;
+	font-size: 12px;
+	font-style: italic;
+}
+
 abbr.required {
-	color: #FF0000;
+	color: #F00;
 	text-align: left;
+	border: none;
 }
 
 img.alignright,
@@ -79,8 +93,10 @@
 
 .show-align {
 	height: 200px;
-	width: 480px;
+	width: 510px;
+	padding: 10px;
 	float: right;
+	border: 1px solid #ddd;
 	background-color: #f1f1f1;
 	cursor: default;
 	-moz-user-select: none;
@@ -88,6 +104,10 @@
 	overflow: hidden;
 }
 
+.code {
+	font-family: Consolas,Monaco,Courier,monospace;
+}
+
 #img-edit {
 	border: 1px solid #dfdfdf;
 	width: 623px;
@@ -137,21 +157,20 @@
 	text-align: center;
 	white-space: nowrap;
 	margin: 0;
-	padding: 0pt 7px;
+	padding: 0 7px;
 }
 
 #sidemenu a.current {
-	-moz-border-radius-topleft: 4px;
+	-moz-border-radius: 4px 4px 0 0;
 	-khtml-border-top-left-radius: 4px;
+	-khtml-border-top-right-radius: 4px;
 	-webkit-border-top-left-radius: 4px;
+	-webkit-border-top-right-radius: 4px;
 	border-top-left-radius: 4px;
-	-moz-border-radius-topright: 4px;
-	-khtml-border-top-right-radius: 4px;
-	-webkit-border-top-right-radius: 4px;
 	border-top-right-radius: 4px;
-	border-style:solid;
-	border-width:1px;
-	font-weight:normal;
+	border-style: solid;
+	border-width: 1px;
+	font-weight: normal;
 }
 
 #adv_settings .field label {
@@ -160,7 +179,7 @@
 
 #media-upload h3 {
 	clear: both;
-	padding: 0pt 0pt 3px;
+	padding: 0 0 3px;
 	border-bottom-style: solid;
 	border-bottom-width: 1px;
 	font-family: Georgia,"Times New Roman",Times,serif;
@@ -209,10 +228,13 @@
 #img_size {
 	float: right;
 	text-align: center;
-	cursor: pointer;
 	background-color: #f1f1f1;
-	padding: 5px 0;
-	width: 45px;
+	padding: 5px 4px;
+	width: 46px;
+	-moz-border-radius: 6px;
+	-khtml-border-radius: 6px;
+	-webkit-border-radius: 6px;
+	border-radius: 6px;
 }
 
 #img_size div {
@@ -234,15 +256,15 @@
 }
 
 #img_size_div {
-	width: 100px;
+	width: 50px;
 	float: left;
 	cursor: default;
 }
 
 #img_size_title {
-	margin: 0 7px 5px;
-	text-align: right;
+	text-align: center;
 	font-weight: bold;
+	padding: 3px 0;
 }
 
 #img_align_td {
@@ -281,10 +303,8 @@
 	border: 1px solid #dfdfdf;
 }
 
-
 .media-upload-form label,
 .media-upload-form legend {
-	font-weight: bold;
 	font-size: 13px;
 	color: #464646;
 }
@@ -294,6 +314,7 @@
 	padding: 0 0 0 28px;
 	margin: 0 1em 0 0;
 }
+
 .image-align-none-label {
 	background: url(../../../../../../wp-admin/images/align-none.png) no-repeat center left;
 }
@@ -341,3 +362,7 @@
 	height: 27px;
 	line-height: 26px;
 }
+
+#link_href {
+	margin-bottom: 6px;
+}
Index: editimage.html
===================================================================
--- editimage.html	(revision 12559)
+++ editimage.html	(working copy)
@@ -103,7 +103,7 @@
 				</label>
 			</th>
 			<td class="field">
-				<input type="text" id="link_href" name="link_href" value="" size="60" /><br />
+				<input type="text" id="link_href" name="link_href" class="code" value="" size="60" /><br />
 				<input type="button" class="button" onclick="wpImage.I('link_href').value='';" value="{#wpeditimage.none}" />
 				<input type="button" class="button" id="img_url_current" onclick="wpImage.img_seturl('current')" value="{#wpeditimage.current_link}" />
 				<input type="button" class="button" id="img_url_img" onclick="wpImage.img_seturl('link')" value="{#wpeditimage.link_to_img}" />
@@ -125,7 +125,7 @@
 				</label>
 			</th>
 			<td class="field">
-				<input type="text" id="img_src" name="img_src" value="" onblur="wpImage.checkVal(this)" aria-required="true" size="60" />
+				<input type="text" id="img_src" name="img_src" class="code" value="" onblur="wpImage.checkVal(this)" aria-required="true" size="60" />
 			</td>
 		</tr>
 		
@@ -164,7 +164,7 @@
 				</label>
 			</th>
 			<td class="field">
-				<input type="text" id="img_classes" name="img_classes" value="" size="60" />
+				<input type="text" id="img_classes" name="img_classes" class="code" value="" size="60" />
 			</td>
 		</tr>
 
@@ -231,7 +231,7 @@
 				</label>
 			</th>
 			<td class="field">
-				<input type="text" id="link_classes" name="link_classes" value="" size="60" />
+				<input type="text" id="link_classes" name="link_classes" class="code" value="" size="60" />
 			</td>
 		</tr>
 
Index: editor_plugin.dev.js
===================================================================
--- editor_plugin.dev.js	(revision 12559)
+++ editor_plugin.dev.js	(working copy)
@@ -198,7 +198,7 @@
 				author : 'WordPress',
 				authorurl : 'http://wordpress.org',
 				infourl : '',
-				version : "1.0"
+				version : "1.0.1"
 			};
 		}
 	});
Index: js/editimage.dev.js
===================================================================
--- js/editimage.dev.js	(revision 0)
+++ js/editimage.dev.js	(revision 0)
@@ -0,0 +1,609 @@
+
+var tinymce = null, tinyMCEPopup, tinyMCE;
+
+tinyMCEPopup = {
+	init: function() {
+		var t = this, w, ti, li, q, i, it;
+
+		li = ('' + document.location.search).replace(/^\?/, '').split('&');
+		q = {};
+		for (i=0; i<li.length; i++) {
+			it = li[i].split('=');
+			q[unescape(it[0])] = unescape(it[1]);
+		}
+
+		if (q.mce_rdomain)
+			document.domain = q.mce_rdomain;
+
+		// Find window & API
+		w = t.getWin();
+		tinymce = w.tinymce;
+		tinyMCE = w.tinyMCE;
+		t.editor = tinymce.EditorManager.activeEditor;
+		t.params = t.editor.windowManager.params;
+
+		// Setup local DOM
+		t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
+		t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window);
+	},
+
+	getWin : function() {
+		return window.dialogArguments || opener || parent || top;
+	},
+
+	getParam : function(n, dv) {
+		return this.editor.getParam(n, dv);
+	},
+
+	close : function() {
+		var t = this, win = t.getWin();
+
+		// To avoid domain relaxing issue in Opera
+		function close() {
+			win.tb_remove();
+			tinymce = tinyMCE = t.editor = t.dom = t.dom.doc = null; // Cleanup
+		};
+
+		if (tinymce.isOpera)
+			win.setTimeout(close, 0);
+		else
+			close();
+	},
+
+	execCommand : function(cmd, ui, val, a) {
+		a = a || {};
+		a.skip_focus = 1;
+
+		this.restoreSelection();
+		return this.editor.execCommand(cmd, ui, val, a);
+	},
+
+	storeSelection : function() {
+		this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');
+	},
+
+	restoreSelection : function() {
+		var t = tinyMCEPopup;
+
+		if (tinymce.isIE)
+			t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
+	}
+}
+tinyMCEPopup.init();
+
+var wpImage = {
+	preInit : function() {
+		// import colors stylesheet from parent
+		var win = tinyMCEPopup.getWin();
+		var styles = win.document.styleSheets;
+
+		for ( i = 0; i < styles.length; i++ ) {
+			var url = styles.item(i).href;
+			if ( url && url.indexOf('colors') != -1 )
+				document.write( '<link rel="stylesheet" href="'+url+'" type="text/css" media="all" />' );
+		}
+	},
+
+	I : function(e) {
+		return document.getElementById(e);
+	},
+
+	current : '',
+	link : '',
+	link_rel : '',
+	target_value : '',
+	current_size_sel : 's100',
+	width : '',
+	height : '',
+	align : '',
+	img_alt : '',
+
+	setTabs : function(tab) {
+		var t = this;
+
+		if ( 'current' == tab.className ) return false;
+		t.I('div_advanced').style.display = ( 'tab_advanced' == tab.id ) ? 'block' : 'none';
+		t.I('div_basic').style.display = ( 'tab_basic' == tab.id ) ? 'block' : 'none';
+		t.I('tab_basic').className = t.I('tab_advanced').className = '';
+		tab.className = 'current';
+		return false;
+	},
+
+	img_seturl : function(u) {
+		var t = this, rel = t.I('link_rel').value;
+
+		if ( 'current' == u ) {
+			t.I('link_href').value = t.current;
+			t.I('link_rel').value = t.link_rel;
+		} else {
+			t.I('link_href').value = t.link;
+			if ( rel ) {
+				rel = rel.replace( /attachment|wp-att-[0-9]+/gi, '' );
+				t.I('link_rel').value = tinymce.trim(rel);
+			}
+		}
+	},
+
+	imgAlignCls : function(v) {
+		var t = this, cls = t.I('img_classes').value;
+
+		t.I('img_demo').className = t.align = v;
+
+		cls = cls.replace( /align[^ "']+/gi, '' );
+		cls += (' ' + v);
+		cls = cls.replace( /\s+/g, ' ' ).replace( /^\s/, '' );
+
+		if ( 'aligncenter' == v ) {
+			t.I('hspace').value = '';
+			t.updateStyle('hspace');
+		}
+
+		t.I('img_classes').value = cls;
+	},
+
+	showSize : function(el) {
+		var t = this, demo = t.I('img_demo'), w = t.width, h = t.height, id = el.id || 's100', size;
+
+		size = parseInt(id.substring(1)) / 200;
+		demo.width = Math.round(w * size);
+		demo.height = Math.round(h * size);
+
+		t.showSizeClear();
+		el.style.borderColor = '#A3A3A3';
+		el.style.backgroundColor = '#E5E5E5';
+		el.style.cursor = 'pointer';
+	},
+
+	showSizeSet : function() {
+		var t = this;
+
+		if ( (t.width * 1.3) > parseInt(t.preloadImg.width) ) {
+			var s130 = t.I('s130'), s120 = t.I('s120'), s110 = t.I('s110');
+
+			s130.onclick = s120.onclick = s110.onclick = null;
+			s130.onmouseover = s120.onmouseover = s110.onmouseover = null;
+			s130.style.color = s120.style.color = s110.style.color = '#aaa';
+			s130.style.cursor = s120.style.cursor = s110.style.cursor = 'default';
+		}
+	},
+
+	showSizeRem : function() {
+		var t = this, demo = t.I('img_demo'), f = document.forms[0];
+
+		demo.width = Math.round(f.width.value * 0.5);
+		demo.height = Math.round(f.height.value * 0.5);
+		t.showSizeClear();
+		t.I(t.current_size_sel).style.borderColor = '#A3A3A3';
+		t.I(t.current_size_sel).style.backgroundColor = '#E5E5E5';
+
+		return false;
+	},
+
+	showSizeClear : function() {
+		var divs = this.I('img_size').getElementsByTagName('div');
+
+		for ( i = 0; i < divs.length; i++ ) {
+			divs[i].style.borderColor = '#f1f1f1';
+			divs[i].style.backgroundColor = '#f1f1f1';
+		}
+	},
+
+	imgEditSize : function(el) {
+		var t = this, f = document.forms[0];
+
+		if ( ! t.preloadImg || ! t.preloadImg.width || ! t.preloadImg.height )	return;
+		var W = parseInt(t.preloadImg.width), H = parseInt(t.preloadImg.height), w = t.width || W, h = t.height || H, id = el.id || 's100';
+
+		size = parseInt(id.substring(1)) / 100;
+
+		w = Math.round(w * size);
+		h = Math.round(h * size);
+
+		f.width.value = Math.min(W, w);
+		f.height.value = Math.min(H, h);
+
+		t.current_size_sel = id;
+		t.demoSetSize();
+	},
+
+	demoSetSize : function(img) {
+		var demo = this.I('img_demo'), f = document.forms[0];
+
+		demo.width = f.width.value ? Math.round(f.width.value * 0.5) : '';
+		demo.height = f.height.value ? Math.round(f.height.value * 0.5) : '';
+	},
+
+	demoSetStyle : function() {
+		var f = document.forms[0], demo = this.I('img_demo'), dom = tinyMCEPopup.editor.dom;
+
+		if (demo) {
+			dom.setAttrib(demo, 'style', f.img_style.value);
+			dom.setStyle(demo, 'width', '');
+			dom.setStyle(demo, 'height', '');
+		}
+	},
+
+	origSize : function() {
+		var t = this, f = document.forms[0], el = t.I('s100');
+
+		f.width.value = t.width = t.preloadImg.width;
+		f.height.value = t.height = t.preloadImg.height;
+		t.showSizeSet();
+		t.demoSetSize();
+		t.showSize(el);
+	},
+
+	init : function() {
+		var ed = tinyMCEPopup.editor, h;
+
+		h = document.body.innerHTML;
+
+		// Replace a=x with a="x" in IE
+		if (tinymce.isIE)
+			h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
+
+		document.body.innerHTML = ed.translate(h);
+		window.setTimeout( function(){wpImage.setup();}, 100 );
+	},
+
+	setup : function() {
+		var t = this, h, c, el, id, link, fname, f = document.forms[0], ed = tinyMCEPopup.editor, d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, caption = '';
+		document.dir = tinyMCEPopup.editor.getParam('directionality','');
+
+		if ( tinyMCEPopup.editor.getParam('wpeditimage_disable_captions', false) )
+			t.I('cap_field').style.display = 'none';
+
+		tinyMCEPopup.restoreSelection();
+		el = ed.selection.getNode();
+		if (el.nodeName != 'IMG') return;
+
+		f.img_src.value = d.src = link = ed.dom.getAttrib(el, 'src');
+		ed.dom.setStyle(el, 'float', '');
+		t.getImageData();
+		c = ed.dom.getAttrib(el, 'class');
+
+		if ( DL = dom.getParent(el, 'dl') ) {
+			var dlc = ed.dom.getAttrib(DL, 'class');
+			dlc = dlc.match(/align[^ "']+/i);
+			if ( dlc && ! dom.hasClass(el, dlc) ) {
+				c += ' '+dlc;
+				tinymce.trim(c);
+			}
+
+			tinymce.each(DL.childNodes, function(e) {
+				if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp-caption-dd') ) {
+					caption = e.innerHTML;
+					return;
+				}
+			});
+		}
+
+		f.img_cap.value = caption;
+		f.img_title.value = ed.dom.getAttrib(el, 'title');
+		f.img_alt.value = ed.dom.getAttrib(el, 'alt');
+		f.border.value = ed.dom.getAttrib(el, 'border');
+		f.vspace.value = ed.dom.getAttrib(el, 'vspace');
+		f.hspace.value = ed.dom.getAttrib(el, 'hspace');
+		f.align.value = ed.dom.getAttrib(el, 'align');
+		f.width.value = t.width = ed.dom.getAttrib(el, 'width');
+		f.height.value = t.height = ed.dom.getAttrib(el, 'height');
+		f.img_classes.value = c;
+		f.img_style.value = ed.dom.getAttrib(el, 'style');
+
+		// Move attribs to styles
+		if (dom.getAttrib(el, 'hspace'))
+			t.updateStyle('hspace');
+
+		if (dom.getAttrib(el, 'border'))
+			t.updateStyle('border');
+
+		if (dom.getAttrib(el, 'vspace'))
+			t.updateStyle('vspace');
+
+		if (pa = ed.dom.getParent(el, 'A')) {
+			f.link_href.value = t.current = ed.dom.getAttrib(pa, 'href');
+			f.link_title.value = ed.dom.getAttrib(pa, 'title');
+			f.link_rel.value = t.link_rel = ed.dom.getAttrib(pa, 'rel');
+			f.link_style.value = ed.dom.getAttrib(pa, 'style');
+			t.target_value = ed.dom.getAttrib(pa, 'target');
+			f.link_classes.value = ed.dom.getAttrib(pa, 'class');
+		}
+
+		f.link_target.checked = ( t.target_value && t.target_value == '_blank' ) ? 'checked' : '';
+
+		fname = link.substring( link.lastIndexOf('/') );
+		fname = fname.replace(/-[0-9]{2,4}x[0-9]{2,4}/, '' );
+		t.link = link.substring( 0, link.lastIndexOf('/') ) + fname;
+
+		if ( c.indexOf('alignleft') != -1 ) {
+			t.I('alignleft').checked = "checked";
+			d.className = t.align = "alignleft";
+		} else if ( c.indexOf('aligncenter') != -1 ) {
+			t.I('aligncenter').checked = "checked";
+			d.className = t.align = "aligncenter";
+		} else if ( c.indexOf('alignright') != -1 ) {
+			t.I('alignright').checked = "checked";
+			d.className = t.align = "alignright";
+		} else if ( c.indexOf('alignnone') != -1 ) {
+			t.I('alignnone').checked = "checked";
+			d.className = t.align = "alignnone";
+		}
+
+		if ( t.width && t.preloadImg.width ) t.showSizeSet();
+		document.body.style.display = '';
+	},
+
+	remove : function() {
+		var ed = tinyMCEPopup.editor, p, el;
+
+		tinyMCEPopup.restoreSelection();
+		el = ed.selection.getNode();
+		if (el.nodeName != 'IMG') return;
+
+		if ( (p = ed.dom.getParent(el, 'div')) && ed.dom.hasClass(p, 'mceTemp') )
+			ed.dom.remove(p);
+		else if ( (p = ed.dom.getParent(el, 'A')) && p.childNodes.length == 1 )
+			ed.dom.remove(p);
+		else ed.dom.remove(el);
+
+		ed.execCommand('mceRepaint');
+		tinyMCEPopup.close();
+		return;
+	},
+
+	update : function() {
+		var t = this, f = document.forms[0], ed = tinyMCEPopup.editor, el, b, fixSafari = null, DL, P, A, DIV, do_caption = null, img_class = f.img_classes.value, html;
+
+		tinyMCEPopup.restoreSelection();
+		el = ed.selection.getNode();
+
+		if (el.nodeName != 'IMG') return;
+		if (f.img_src.value === '') {
+			t.remove();
+			return;
+		}
+
+		if ( f.img_cap.value != '' && f.width.value != '' ) {
+			do_caption = 1;
+			img_class = img_class.replace( /align[^ "']+\s?/gi, '' );
+		}
+
+		A = ed.dom.getParent(el, 'a');
+		P = ed.dom.getParent(el, 'p');
+		DL = ed.dom.getParent(el, 'dl');
+		DIV = ed.dom.getParent(el, 'div');
+
+		tinyMCEPopup.execCommand("mceBeginUndoLevel");
+
+		ed.dom.setAttribs(el, {
+			src : f.img_src.value,
+			title : f.img_title.value,
+			alt : f.img_alt.value,
+			width : f.width.value,
+			height : f.height.value,
+			style : f.img_style.value,
+			'class' : img_class
+		});
+
+		if ( f.link_href.value ) {
+			// Create new anchor elements
+			if ( A == null ) {
+				if ( ! f.link_href.value.match(/https?:\/\//i) )
+					f.link_href.value = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.link_href.value);
+
+				if ( tinymce.isWebKit && ed.dom.hasClass(el, 'aligncenter') ) {
+					ed.dom.removeClass(el, 'aligncenter');
+					fixSafari = 1;
+				}
+
+				tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
+				if ( fixSafari ) ed.dom.addClass(el, 'aligncenter');
+
+				tinymce.each(ed.dom.select("a"), function(n) {
+					if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
+
+						ed.dom.setAttribs(n, {
+							href : f.link_href.value,
+							title : f.link_title.value,
+							rel : f.link_rel.value,
+							target : (f.link_target.checked == true) ? '_blank' : '',
+							'class' : f.link_classes.value,
+							style : f.link_style.value
+						});
+					}
+				});
+			} else {
+				ed.dom.setAttribs(A, {
+					href : f.link_href.value,
+					title : f.link_title.value,
+					rel : f.link_rel.value,
+					target : (f.link_target.checked == true) ? '_blank' : '',
+					'class' : f.link_classes.value,
+					style : f.link_style.value
+				});
+			}
+		}
+
+		if ( do_caption ) {
+			var id, cap_id = '', cap, DT, DD, cap_width = 10 + parseInt(f.width.value), align = t.align.substring(5), div_cls = (t.align == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp';
+
+			if ( DL ) {
+				ed.dom.setAttribs(DL, {
+					'class' : 'wp-caption '+t.align,
+					style : 'width: '+cap_width+'px;'
+				});
+
+				if ( DIV )
+					ed.dom.setAttrib(DIV, 'class', div_cls);
+
+				if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp-caption-dd') )
+					ed.dom.setHTML(DD, f.img_cap.value);
+
+			} else {
+				var lnk = '', pa;
+				if ( (id = f.img_classes.value.match( /wp-image-([0-9]{1,6})/ )) && id[1] )
+					cap_id = 'attachment_'+id[1];
+
+				if ( f.link_href.value && (lnk = ed.dom.getParent(el, 'a')) ) {
+					if ( lnk.childNodes.length == 1 )
+						html = ed.dom.getOuterHTML(lnk);
+					else {
+						html = ed.dom.getOuterHTML(lnk);
+						html = html.match(/<a[^>]+>/i);
+						html = html+ed.dom.getOuterHTML(el)+'</a>';
+					}
+				} else html = ed.dom.getOuterHTML(el);
+
+				html = '<dl id="'+cap_id+'" class="wp-caption '+t.align+'" style="width: '+cap_width+
+				'px"><dt class="wp-caption-dt">'+html+'</dt><dd class="wp-caption-dd">'+f.img_cap.value+'</dd></dl>';
+
+				cap = ed.dom.create('div', {'class': div_cls}, html);
+
+				if ( P ) {
+					P.parentNode.insertBefore(cap, P);
+					if ( P.childNodes.length == 1 )
+						ed.dom.remove(P);
+					else if ( lnk && lnk.childNodes.length == 1 )
+						ed.dom.remove(lnk);
+					else ed.dom.remove(el);
+				} else if ( pa = ed.dom.getParent(el, 'TD,TH,LI') ) {
+					pa.appendChild(cap);
+					if ( lnk && lnk.childNodes.length == 1 )
+						ed.dom.remove(lnk);
+					else ed.dom.remove(el);
+				}
+			}
+
+		} else {
+			if ( DL && DIV ) {
+				var aa;
+				if ( f.link_href.value && (aa = ed.dom.getParent(el, 'a')) ) html = ed.dom.getOuterHTML(aa);
+				else html = ed.dom.getOuterHTML(el);
+
+				P = ed.dom.create('p', {}, html);
+				DIV.parentNode.insertBefore(P, DIV);
+				ed.dom.remove(DIV);
+			}
+		}
+
+		if ( f.img_classes.value.indexOf('aligncenter') != -1 ) {
+			if ( P && ( ! P.style || P.style.textAlign != 'center' ) )
+				ed.dom.setStyle(P, 'textAlign', 'center');
+		} else {
+			if ( P && P.style && P.style.textAlign == 'center' )
+				ed.dom.setStyle(P, 'textAlign', '');
+		}
+
+		if ( ! f.link_href.value && A ) {
+			b = ed.selection.getBookmark();
+			ed.dom.remove(A, 1);
+			ed.selection.moveToBookmark(b);
+		}
+
+		tinyMCEPopup.execCommand("mceEndUndoLevel");
+		ed.execCommand('mceRepaint');
+		tinyMCEPopup.close();
+	},
+
+	updateStyle : function(ty) {
+		var dom = tinyMCEPopup.dom, st, v, f = document.forms[0], img = dom.create('img', {style : f.img_style.value});
+
+		if (tinyMCEPopup.editor.settings.inline_styles) {
+			// Handle align
+			if (ty == 'align') {
+				dom.setStyle(img, 'float', '');
+				dom.setStyle(img, 'vertical-align', '');
+
+				v = f.align.value;
+				if (v) {
+					if (v == 'left' || v == 'right')
+						dom.setStyle(img, 'float', v);
+					else
+						img.style.verticalAlign = v;
+				}
+			}
+
+			// Handle border
+			if (ty == 'border') {
+				dom.setStyle(img, 'border', '');
+
+				v = f.border.value;
+				if (v || v == '0') {
+					if (v == '0')
+						img.style.border = '0';
+					else
+						img.style.border = v + 'px solid black';
+				}
+			}
+
+			// Handle hspace
+			if (ty == 'hspace') {
+				dom.setStyle(img, 'marginLeft', '');
+				dom.setStyle(img, 'marginRight', '');
+
+				v = f.hspace.value;
+				if (v) {
+					img.style.marginLeft = v + 'px';
+					img.style.marginRight = v + 'px';
+				}
+			}
+
+			// Handle vspace
+			if (ty == 'vspace') {
+				dom.setStyle(img, 'marginTop', '');
+				dom.setStyle(img, 'marginBottom', '');
+
+				v = f.vspace.value;
+				if (v) {
+					img.style.marginTop = v + 'px';
+					img.style.marginBottom = v + 'px';
+				}
+			}
+
+			// Merge
+			f.img_style.value = dom.serializeStyle(dom.parseStyle(img.style.cssText));
+			this.demoSetStyle();
+		}
+	},
+
+	checkVal : function(f) {
+
+		if ( f.value == '' ) {
+	//		if ( f.id == 'width' ) f.value = this.width || this.preloadImg.width;
+	//		if ( f.id == 'height' ) f.value = this.height || this.preloadImg.height;
+			if ( f.id == 'img_src' ) f.value = this.I('img_demo').src || this.preloadImg.src;
+		}
+	},
+
+	resetImageData : function() {
+		var f = document.forms[0];
+
+		f.width.value = f.height.value = '';
+	},
+
+	updateImageData : function() {
+		var f = document.forms[0], t = wpImage;
+
+		if ( f.width.value == '' || f.height.value == '' ) {
+			f.width.value = t.width = t.preloadImg.width;
+			f.height.value = t.height = t.preloadImg.height;
+		}
+
+		t.showSizeSet();
+		t.demoSetSize();
+		if ( f.img_style.value )
+			t.demoSetStyle();
+	},
+
+	getImageData : function() {
+		var t = wpImage, f = document.forms[0];
+
+		t.preloadImg = new Image();
+		t.preloadImg.onload = t.updateImageData;
+		t.preloadImg.onerror = t.resetImageData;
+		t.preloadImg.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.img_src.value);
+	}
+};
+
+window.onload = function(){wpImage.init();}
+wpImage.preInit();
Index: js/editimage.js
===================================================================
--- js/editimage.js	(revision 12559)
+++ js/editimage.js	(working copy)
@@ -1,607 +1 @@
-
-var tinymce = null, tinyMCEPopup, tinyMCE;
-
-tinyMCEPopup = {
-	init: function() {
-		var t = this, w, ti, li, q, i, it;
-
-		li = ('' + document.location.search).replace(/^\?/, '').split('&');
-		q = {};
-		for (i=0; i<li.length; i++) {
-			it = li[i].split('=');
-			q[unescape(it[0])] = unescape(it[1]);
-		}
-
-		if (q.mce_rdomain)
-			document.domain = q.mce_rdomain;
-
-		// Find window & API
-		w = t.getWin();
-		tinymce = w.tinymce;
-		tinyMCE = w.tinyMCE;
-		t.editor = tinymce.EditorManager.activeEditor;
-		t.params = t.editor.windowManager.params;
-
-		// Setup local DOM
-		t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
-		t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window);
-	},
-
-	getWin : function() {
-		return window.dialogArguments || opener || parent || top;
-	},
-
-	getParam : function(n, dv) {
-		return this.editor.getParam(n, dv);
-	},
-
-	close : function() {
-		var t = this, win = t.getWin();
-
-		// To avoid domain relaxing issue in Opera
-		function close() {
-			win.tb_remove();
-			tinymce = tinyMCE = t.editor = t.dom = t.dom.doc = null; // Cleanup
-		};
-
-		if (tinymce.isOpera)
-			win.setTimeout(close, 0);
-		else
-			close();
-	},
-
-	execCommand : function(cmd, ui, val, a) {
-		a = a || {};
-		a.skip_focus = 1;
-
-		this.restoreSelection();
-		return this.editor.execCommand(cmd, ui, val, a);
-	},
-
-	storeSelection : function() {
-		this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');
-	},
-
-	restoreSelection : function() {
-		var t = tinyMCEPopup;
-
-		if (tinymce.isIE)
-			t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
-	}
-}
-tinyMCEPopup.init();
-
-var wpImage = {
-	preInit : function() {
-		// import colors stylesheet from parent
-		var win = tinyMCEPopup.getWin();
-		var styles = win.document.styleSheets;
-
-		for ( i = 0; i < styles.length; i++ ) {
-			var url = styles.item(i).href;
-			if ( url && url.indexOf('colors') != -1 )
-				document.write( '<link rel="stylesheet" href="'+url+'" type="text/css" media="all" />' );
-		}
-	},
-
-	I : function(e) {
-		return document.getElementById(e);
-	},
-
-	current : '',
-	link : '',
-	link_rel : '',
-	target_value : '',
-	current_size_sel : 's100',
-	width : '',
-	height : '',
-	align : '',
-	img_alt : '',
-
-	setTabs : function(tab) {
-		var t = this;
-
-		if ( 'current' == tab.className ) return false;
-		t.I('div_advanced').style.display = ( 'tab_advanced' == tab.id ) ? 'block' : 'none';
-		t.I('div_basic').style.display = ( 'tab_basic' == tab.id ) ? 'block' : 'none';
-		t.I('tab_basic').className = t.I('tab_advanced').className = '';
-		tab.className = 'current';
-		return false;
-	},
-
-	img_seturl : function(u) {
-		var t = this, rel = t.I('link_rel').value;
-
-		if ( 'current' == u ) {
-			t.I('link_href').value = t.current;
-			t.I('link_rel').value = t.link_rel;
-		} else {
-			t.I('link_href').value = t.link;
-			if ( rel ) {
-				rel = rel.replace( /attachment|wp-att-[0-9]+/gi, '' );
-				t.I('link_rel').value = tinymce.trim(rel);
-			}
-		}
-	},
-
-	imgAlignCls : function(v) {
-		var t = this, cls = t.I('img_classes').value;
-
-		t.I('img_demo').className = t.align = v;
-
-		cls = cls.replace( /align[^ "']+/gi, '' );
-		cls += (' ' + v);
-		cls = cls.replace( /\s+/g, ' ' ).replace( /^\s/, '' );
-
-		if ( 'aligncenter' == v ) {
-			t.I('hspace').value = '';
-			t.updateStyle('hspace');
-		}
-
-		t.I('img_classes').value = cls;
-	},
-
-	showSize : function(el) {
-		var t = this, demo = t.I('img_demo'), w = t.width, h = t.height, id = el.id || 's100', size;
-
-		size = parseInt(id.substring(1)) / 200;
-		demo.width = Math.round(w * size);
-		demo.height = Math.round(h * size);
-
-		t.showSizeClear();
-		el.style.borderColor = '#A3A3A3';
-		el.style.backgroundColor = '#E5E5E5';
-	},
-
-	showSizeSet : function() {
-		var t = this;
-
-		if ( (t.width * 1.3) > parseInt(t.preloadImg.width) ) {
-			var s130 = t.I('s130'), s120 = t.I('s120'), s110 = t.I('s110');
-
-			s130.onclick = s120.onclick = s110.onclick = null;
-			s130.onmouseover = s120.onmouseover = s110.onmouseover = null;
-			s130.style.color = s120.style.color = s110.style.color = '#aaa';
-		}
-	},
-
-	showSizeRem : function() {
-		var t = this, demo = t.I('img_demo'), f = document.forms[0];
-
-		demo.width = Math.round(f.width.value * 0.5);
-		demo.height = Math.round(f.height.value * 0.5);
-		t.showSizeClear();
-		t.I(t.current_size_sel).style.borderColor = '#A3A3A3';
-		t.I(t.current_size_sel).style.backgroundColor = '#E5E5E5';
-
-		return false;
-	},
-
-	showSizeClear : function() {
-		var divs = this.I('img_size').getElementsByTagName('div');
-
-		for ( i = 0; i < divs.length; i++ ) {
-			divs[i].style.borderColor = '#f1f1f1';
-			divs[i].style.backgroundColor = '#f1f1f1';
-		}
-	},
-
-	imgEditSize : function(el) {
-		var t = this, f = document.forms[0];
-
-		if ( ! t.preloadImg || ! t.preloadImg.width || ! t.preloadImg.height )	return;
-		var W = parseInt(t.preloadImg.width), H = parseInt(t.preloadImg.height), w = t.width || W, h = t.height || H, id = el.id || 's100';
-
-		size = parseInt(id.substring(1)) / 100;
-
-		w = Math.round(w * size);
-		h = Math.round(h * size);
-
-		f.width.value = Math.min(W, w);
-		f.height.value = Math.min(H, h);
-
-		t.current_size_sel = id;
-		t.demoSetSize();
-	},
-
-	demoSetSize : function(img) {
-		var demo = this.I('img_demo'), f = document.forms[0];
-
-		demo.width = f.width.value ? Math.round(f.width.value * 0.5) : '';
-		demo.height = f.height.value ? Math.round(f.height.value * 0.5) : '';
-	},
-
-	demoSetStyle : function() {
-		var f = document.forms[0], demo = this.I('img_demo'), dom = tinyMCEPopup.editor.dom;
-
-		if (demo) {
-			dom.setAttrib(demo, 'style', f.img_style.value);
-			dom.setStyle(demo, 'width', '');
-			dom.setStyle(demo, 'height', '');
-		}
-	},
-
-	origSize : function() {
-		var t = this, f = document.forms[0], el = t.I('s100');
-
-		f.width.value = t.width = t.preloadImg.width;
-		f.height.value = t.height = t.preloadImg.height;
-		t.showSizeSet();
-		t.demoSetSize();
-		t.showSize(el);
-	},
-
-	init : function() {
-		var ed = tinyMCEPopup.editor, h;
-
-		h = document.body.innerHTML;
-
-		// Replace a=x with a="x" in IE
-		if (tinymce.isIE)
-			h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
-
-		document.body.innerHTML = ed.translate(h);
-		window.setTimeout( function(){wpImage.setup();}, 100 );
-	},
-
-	setup : function() {
-		var t = this, h, c, el, id, link, fname, f = document.forms[0], ed = tinyMCEPopup.editor, d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, caption = '';
-		document.dir = tinyMCEPopup.editor.getParam('directionality','');
-
-		if ( tinyMCEPopup.editor.getParam('wpeditimage_disable_captions', false) )
-			t.I('cap_field').style.display = 'none';
-
-		tinyMCEPopup.restoreSelection();
-		el = ed.selection.getNode();
-		if (el.nodeName != 'IMG') return;
-
-		f.img_src.value = d.src = link = ed.dom.getAttrib(el, 'src');
-		ed.dom.setStyle(el, 'float', '');
-		t.getImageData();
-		c = ed.dom.getAttrib(el, 'class');
-
-		if ( DL = dom.getParent(el, 'dl') ) {
-			var dlc = ed.dom.getAttrib(DL, 'class');
-			dlc = dlc.match(/align[^ "']+/i);
-			if ( dlc && ! dom.hasClass(el, dlc) ) {
-				c += ' '+dlc;
-				tinymce.trim(c);
-			}
-
-			tinymce.each(DL.childNodes, function(e) {
-				if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp-caption-dd') ) {
-					caption = e.innerHTML;
-					return;
-				}
-			});
-		}
-
-		f.img_cap.value = caption;
-		f.img_title.value = ed.dom.getAttrib(el, 'title');
-		f.img_alt.value = ed.dom.getAttrib(el, 'alt');
-		f.border.value = ed.dom.getAttrib(el, 'border');
-		f.vspace.value = ed.dom.getAttrib(el, 'vspace');
-		f.hspace.value = ed.dom.getAttrib(el, 'hspace');
-		f.align.value = ed.dom.getAttrib(el, 'align');
-		f.width.value = t.width = ed.dom.getAttrib(el, 'width');
-		f.height.value = t.height = ed.dom.getAttrib(el, 'height');
-		f.img_classes.value = c;
-		f.img_style.value = ed.dom.getAttrib(el, 'style');
-
-		// Move attribs to styles
-		if (dom.getAttrib(el, 'hspace'))
-			t.updateStyle('hspace');
-
-		if (dom.getAttrib(el, 'border'))
-			t.updateStyle('border');
-
-		if (dom.getAttrib(el, 'vspace'))
-			t.updateStyle('vspace');
-
-		if (pa = ed.dom.getParent(el, 'A')) {
-			f.link_href.value = t.current = ed.dom.getAttrib(pa, 'href');
-			f.link_title.value = ed.dom.getAttrib(pa, 'title');
-			f.link_rel.value = t.link_rel = ed.dom.getAttrib(pa, 'rel');
-			f.link_style.value = ed.dom.getAttrib(pa, 'style');
-			t.target_value = ed.dom.getAttrib(pa, 'target');
-			f.link_classes.value = ed.dom.getAttrib(pa, 'class');
-		}
-
-		f.link_target.checked = ( t.target_value && t.target_value == '_blank' ) ? 'checked' : '';
-
-		fname = link.substring( link.lastIndexOf('/') );
-		fname = fname.replace(/-[0-9]{2,4}x[0-9]{2,4}/, '' );
-		t.link = link.substring( 0, link.lastIndexOf('/') ) + fname;
-
-		if ( c.indexOf('alignleft') != -1 ) {
-			t.I('alignleft').checked = "checked";
-			d.className = t.align = "alignleft";
-		} else if ( c.indexOf('aligncenter') != -1 ) {
-			t.I('aligncenter').checked = "checked";
-			d.className = t.align = "aligncenter";
-		} else if ( c.indexOf('alignright') != -1 ) {
-			t.I('alignright').checked = "checked";
-			d.className = t.align = "alignright";
-		} else if ( c.indexOf('alignnone') != -1 ) {
-			t.I('alignnone').checked = "checked";
-			d.className = t.align = "alignnone";
-		}
-
-		if ( t.width && t.preloadImg.width ) t.showSizeSet();
-		document.body.style.display = '';
-	},
-
-	remove : function() {
-		var ed = tinyMCEPopup.editor, p, el;
-
-		tinyMCEPopup.restoreSelection();
-		el = ed.selection.getNode();
-		if (el.nodeName != 'IMG') return;
-
-		if ( (p = ed.dom.getParent(el, 'div')) && ed.dom.hasClass(p, 'mceTemp') )
-			ed.dom.remove(p);
-		else if ( (p = ed.dom.getParent(el, 'A')) && p.childNodes.length == 1 )
-			ed.dom.remove(p);
-		else ed.dom.remove(el);
-
-		ed.execCommand('mceRepaint');
-		tinyMCEPopup.close();
-		return;
-	},
-
-	update : function() {
-		var t = this, f = document.forms[0], ed = tinyMCEPopup.editor, el, b, fixSafari = null, DL, P, A, DIV, do_caption = null, img_class = f.img_classes.value, html;
-
-		tinyMCEPopup.restoreSelection();
-		el = ed.selection.getNode();
-
-		if (el.nodeName != 'IMG') return;
-		if (f.img_src.value === '') {
-			t.remove();
-			return;
-		}
-
-		if ( f.img_cap.value != '' && f.width.value != '' ) {
-			do_caption = 1;
-			img_class = img_class.replace( /align[^ "']+\s?/gi, '' );
-		}
-
-		A = ed.dom.getParent(el, 'a');
-		P = ed.dom.getParent(el, 'p');
-		DL = ed.dom.getParent(el, 'dl');
-		DIV = ed.dom.getParent(el, 'div');
-
-		tinyMCEPopup.execCommand("mceBeginUndoLevel");
-
-		ed.dom.setAttribs(el, {
-			src : f.img_src.value,
-			title : f.img_title.value,
-			alt : f.img_alt.value,
-			width : f.width.value,
-			height : f.height.value,
-			style : f.img_style.value,
-			'class' : img_class
-		});
-
-		if ( f.link_href.value ) {
-			// Create new anchor elements
-			if ( A == null ) {
-				if ( ! f.link_href.value.match(/https?:\/\//i) )
-					f.link_href.value = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.link_href.value);
-
-				if ( tinymce.isWebKit && ed.dom.hasClass(el, 'aligncenter') ) {
-					ed.dom.removeClass(el, 'aligncenter');
-					fixSafari = 1;
-				}
-
-				tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
-				if ( fixSafari ) ed.dom.addClass(el, 'aligncenter');
-
-				tinymce.each(ed.dom.select("a"), function(n) {
-					if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
-
-						ed.dom.setAttribs(n, {
-							href : f.link_href.value,
-							title : f.link_title.value,
-							rel : f.link_rel.value,
-							target : (f.link_target.checked == true) ? '_blank' : '',
-							'class' : f.link_classes.value,
-							style : f.link_style.value
-						});
-					}
-				});
-			} else {
-				ed.dom.setAttribs(A, {
-					href : f.link_href.value,
-					title : f.link_title.value,
-					rel : f.link_rel.value,
-					target : (f.link_target.checked == true) ? '_blank' : '',
-					'class' : f.link_classes.value,
-					style : f.link_style.value
-				});
-			}
-		}
-
-		if ( do_caption ) {
-			var id, cap_id = '', cap, DT, DD, cap_width = 10 + parseInt(f.width.value), align = t.align.substring(5), div_cls = (t.align == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp';
-
-			if ( DL ) {
-				ed.dom.setAttribs(DL, {
-					'class' : 'wp-caption '+t.align,
-					style : 'width: '+cap_width+'px;'
-				});
-
-				if ( DIV )
-					ed.dom.setAttrib(DIV, 'class', div_cls);
-
-				if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp-caption-dd') )
-					ed.dom.setHTML(DD, f.img_cap.value);
-
-			} else {
-				var lnk = '', pa;
-				if ( (id = f.img_classes.value.match( /wp-image-([0-9]{1,6})/ )) && id[1] )
-					cap_id = 'attachment_'+id[1];
-
-				if ( f.link_href.value && (lnk = ed.dom.getParent(el, 'a')) ) {
-					if ( lnk.childNodes.length == 1 )
-						html = ed.dom.getOuterHTML(lnk);
-					else {
-						html = ed.dom.getOuterHTML(lnk);
-						html = html.match(/<a[^>]+>/i);
-						html = html+ed.dom.getOuterHTML(el)+'</a>';
-					}
-				} else html = ed.dom.getOuterHTML(el);
-
-				html = '<dl id="'+cap_id+'" class="wp-caption '+t.align+'" style="width: '+cap_width+
-				'px"><dt class="wp-caption-dt">'+html+'</dt><dd class="wp-caption-dd">'+f.img_cap.value+'</dd></dl>';
-
-				cap = ed.dom.create('div', {'class': div_cls}, html);
-
-				if ( P ) {
-					P.parentNode.insertBefore(cap, P);
-					if ( P.childNodes.length == 1 )
-						ed.dom.remove(P);
-					else if ( lnk && lnk.childNodes.length == 1 )
-						ed.dom.remove(lnk);
-					else ed.dom.remove(el);
-				} else if ( pa = ed.dom.getParent(el, 'TD,TH,LI') ) {
-					pa.appendChild(cap);
-					if ( lnk && lnk.childNodes.length == 1 )
-						ed.dom.remove(lnk);
-					else ed.dom.remove(el);
-				}
-			}
-
-		} else {
-			if ( DL && DIV ) {
-				var aa;
-				if ( f.link_href.value && (aa = ed.dom.getParent(el, 'a')) ) html = ed.dom.getOuterHTML(aa);
-				else html = ed.dom.getOuterHTML(el);
-
-				P = ed.dom.create('p', {}, html);
-				DIV.parentNode.insertBefore(P, DIV);
-				ed.dom.remove(DIV);
-			}
-		}
-
-		if ( f.img_classes.value.indexOf('aligncenter') != -1 ) {
-			if ( P && ( ! P.style || P.style.textAlign != 'center' ) )
-				ed.dom.setStyle(P, 'textAlign', 'center');
-		} else {
-			if ( P && P.style && P.style.textAlign == 'center' )
-				ed.dom.setStyle(P, 'textAlign', '');
-		}
-
-		if ( ! f.link_href.value && A ) {
-			b = ed.selection.getBookmark();
-			ed.dom.remove(A, 1);
-			ed.selection.moveToBookmark(b);
-		}
-
-		tinyMCEPopup.execCommand("mceEndUndoLevel");
-		ed.execCommand('mceRepaint');
-		tinyMCEPopup.close();
-	},
-
-	updateStyle : function(ty) {
-		var dom = tinyMCEPopup.dom, st, v, f = document.forms[0], img = dom.create('img', {style : f.img_style.value});
-
-		if (tinyMCEPopup.editor.settings.inline_styles) {
-			// Handle align
-			if (ty == 'align') {
-				dom.setStyle(img, 'float', '');
-				dom.setStyle(img, 'vertical-align', '');
-
-				v = f.align.value;
-				if (v) {
-					if (v == 'left' || v == 'right')
-						dom.setStyle(img, 'float', v);
-					else
-						img.style.verticalAlign = v;
-				}
-			}
-
-			// Handle border
-			if (ty == 'border') {
-				dom.setStyle(img, 'border', '');
-
-				v = f.border.value;
-				if (v || v == '0') {
-					if (v == '0')
-						img.style.border = '0';
-					else
-						img.style.border = v + 'px solid black';
-				}
-			}
-
-			// Handle hspace
-			if (ty == 'hspace') {
-				dom.setStyle(img, 'marginLeft', '');
-				dom.setStyle(img, 'marginRight', '');
-
-				v = f.hspace.value;
-				if (v) {
-					img.style.marginLeft = v + 'px';
-					img.style.marginRight = v + 'px';
-				}
-			}
-
-			// Handle vspace
-			if (ty == 'vspace') {
-				dom.setStyle(img, 'marginTop', '');
-				dom.setStyle(img, 'marginBottom', '');
-
-				v = f.vspace.value;
-				if (v) {
-					img.style.marginTop = v + 'px';
-					img.style.marginBottom = v + 'px';
-				}
-			}
-
-			// Merge
-			f.img_style.value = dom.serializeStyle(dom.parseStyle(img.style.cssText));
-			this.demoSetStyle();
-		}
-	},
-
-	checkVal : function(f) {
-
-		if ( f.value == '' ) {
-	//		if ( f.id == 'width' ) f.value = this.width || this.preloadImg.width;
-	//		if ( f.id == 'height' ) f.value = this.height || this.preloadImg.height;
-			if ( f.id == 'img_src' ) f.value = this.I('img_demo').src || this.preloadImg.src;
-		}
-	},
-
-	resetImageData : function() {
-		var f = document.forms[0];
-
-		f.width.value = f.height.value = '';
-	},
-
-	updateImageData : function() {
-		var f = document.forms[0], t = wpImage;
-
-		if ( f.width.value == '' || f.height.value == '' ) {
-			f.width.value = t.width = t.preloadImg.width;
-			f.height.value = t.height = t.preloadImg.height;
-		}
-
-		t.showSizeSet();
-		t.demoSetSize();
-		if ( f.img_style.value )
-			t.demoSetStyle();
-	},
-
-	getImageData : function() {
-		var t = wpImage, f = document.forms[0];
-
-		t.preloadImg = new Image();
-		t.preloadImg.onload = t.updateImageData;
-		t.preloadImg.onerror = t.resetImageData;
-		t.preloadImg.src = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.img_src.value);
-	}
-};
-
-window.onload = function(){wpImage.init();}
-wpImage.preInit();
+var tinymce=null,tinyMCEPopup,tinyMCE;tinyMCEPopup={init:function(){var d=this,b,f,a,g,c,e;a=(""+document.location.search).replace(/^\?/,"").split("&");g={};for(c=0;c<a.length;c++){e=a[c].split("=");g[unescape(e[0])]=unescape(e[1])}if(g.mce_rdomain){document.domain=g.mce_rdomain}b=d.getWin();tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.params=d.editor.windowManager.params;d.dom=d.editor.windowManager.createInstance("tinymce.dom.DOMUtils",document);d.editor.windowManager.onOpen.dispatch(d.editor.windowManager,window)},getWin:function(){return window.dialogArguments||opener||parent||top},getParam:function(b,a){return this.editor.getParam(b,a)},close:function(){var a=this,b=a.getWin();function c(){b.tb_remove();tinymce=tinyMCE=a.editor=a.dom=a.dom.doc=null}if(tinymce.isOpera){b.setTimeout(c,0)}else{c()}},execCommand:function(d,c,e,b){b=b||{};b.skip_focus=1;this.restoreSelection();return this.editor.execCommand(d,c,e,b)},storeSelection:function(){this.editor.windowManager.bookmark=tinyMCEPopup.editor.selection.getBookmark("simple")},restoreSelection:function(){var a=tinyMCEPopup;if(tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}}};tinyMCEPopup.init();var wpImage={preInit:function(){var c=tinyMCEPopup.getWin();var b=c.document.styleSheets;for(i=0;i<b.length;i++){var a=b.item(i).href;if(a&&a.indexOf("colors")!=-1){document.write('<link rel="stylesheet" href="'+a+'" type="text/css" media="all" />')}}},I:function(a){return document.getElementById(a)},current:"",link:"",link_rel:"",target_value:"",current_size_sel:"s100",width:"",height:"",align:"",img_alt:"",setTabs:function(b){var a=this;if("current"==b.className){return false}a.I("div_advanced").style.display=("tab_advanced"==b.id)?"block":"none";a.I("div_basic").style.display=("tab_basic"==b.id)?"block":"none";a.I("tab_basic").className=a.I("tab_advanced").className="";b.className="current";return false},img_seturl:function(b){var c=this,a=c.I("link_rel").value;if("current"==b){c.I("link_href").value=c.current;c.I("link_rel").value=c.link_rel}else{c.I("link_href").value=c.link;if(a){a=a.replace(/attachment|wp-att-[0-9]+/gi,"");c.I("link_rel").value=tinymce.trim(a)}}},imgAlignCls:function(b){var c=this,a=c.I("img_classes").value;c.I("img_demo").className=c.align=b;a=a.replace(/align[^ "']+/gi,"");a+=(" "+b);a=a.replace(/\s+/g," ").replace(/^\s/,"");if("aligncenter"==b){c.I("hspace").value="";c.updateStyle("hspace")}c.I("img_classes").value=a},showSize:function(e){var c=this,f=c.I("img_demo"),a=c.width,d=c.height,g=e.id||"s100",b;b=parseInt(g.substring(1))/200;f.width=Math.round(a*b);f.height=Math.round(d*b);c.showSizeClear();e.style.borderColor="#A3A3A3";e.style.backgroundColor="#E5E5E5";e.style.cursor="pointer"},showSizeSet:function(){var b=this;if((b.width*1.3)>parseInt(b.preloadImg.width)){var d=b.I("s130"),c=b.I("s120"),a=b.I("s110");d.onclick=c.onclick=a.onclick=null;d.onmouseover=c.onmouseover=a.onmouseover=null;d.style.color=c.style.color=a.style.color="#aaa";d.style.cursor=c.style.cursor=a.style.cursor="default"}},showSizeRem:function(){var a=this,c=a.I("img_demo"),b=document.forms[0];c.width=Math.round(b.width.value*0.5);c.height=Math.round(b.height.value*0.5);a.showSizeClear();a.I(a.current_size_sel).style.borderColor="#A3A3A3";a.I(a.current_size_sel).style.backgroundColor="#E5E5E5";return false},showSizeClear:function(){var a=this.I("img_size").getElementsByTagName("div");for(i=0;i<a.length;i++){a[i].style.borderColor="#f1f1f1";a[i].style.backgroundColor="#f1f1f1"}},imgEditSize:function(g){var d=this,j=document.forms[0];if(!d.preloadImg||!d.preloadImg.width||!d.preloadImg.height){return}var a=parseInt(d.preloadImg.width),c=parseInt(d.preloadImg.height),b=d.width||a,e=d.height||c,k=g.id||"s100";size=parseInt(k.substring(1))/100;b=Math.round(b*size);e=Math.round(e*size);j.width.value=Math.min(a,b);j.height.value=Math.min(c,e);d.current_size_sel=k;d.demoSetSize()},demoSetSize:function(a){var c=this.I("img_demo"),b=document.forms[0];c.width=b.width.value?Math.round(b.width.value*0.5):"";c.height=b.height.value?Math.round(b.height.value*0.5):""},demoSetStyle:function(){var b=document.forms[0],a=this.I("img_demo"),c=tinyMCEPopup.editor.dom;if(a){c.setAttrib(a,"style",b.img_style.value);c.setStyle(a,"width","");c.setStyle(a,"height","")}},origSize:function(){var a=this,c=document.forms[0],b=a.I("s100");c.width.value=a.width=a.preloadImg.width;c.height.value=a.height=a.preloadImg.height;a.showSizeSet();a.demoSetSize();a.showSize(b)},init:function(){var a=tinyMCEPopup.editor,b;b=document.body.innerHTML;if(tinymce.isIE){b=b.replace(/ (value|title|alt)=([^"][^\s>]+)/gi,' $1="$2"')}document.body.innerHTML=a.translate(b);window.setTimeout(function(){wpImage.setup()},100)},setup:function(){var s=this,k,o,e,b,p,g,m=document.forms[0],l=tinyMCEPopup.editor,n=s.I("img_demo"),j=tinyMCEPopup.dom,a,r="";document.dir=tinyMCEPopup.editor.getParam("directionality","");if(tinyMCEPopup.editor.getParam("wpeditimage_disable_captions",false)){s.I("cap_field").style.display="none"}tinyMCEPopup.restoreSelection();e=l.selection.getNode();if(e.nodeName!="IMG"){return}m.img_src.value=n.src=p=l.dom.getAttrib(e,"src");l.dom.setStyle(e,"float","");s.getImageData();o=l.dom.getAttrib(e,"class");if(a=j.getParent(e,"dl")){var q=l.dom.getAttrib(a,"class");q=q.match(/align[^ "']+/i);if(q&&!j.hasClass(e,q)){o+=" "+q;tinymce.trim(o)}tinymce.each(a.childNodes,function(c){if(c.nodeName=="DD"&&j.hasClass(c,"wp-caption-dd")){r=c.innerHTML;return}})}m.img_cap.value=r;m.img_title.value=l.dom.getAttrib(e,"title");m.img_alt.value=l.dom.getAttrib(e,"alt");m.border.value=l.dom.getAttrib(e,"border");m.vspace.value=l.dom.getAttrib(e,"vspace");m.hspace.value=l.dom.getAttrib(e,"hspace");m.align.value=l.dom.getAttrib(e,"align");m.width.value=s.width=l.dom.getAttrib(e,"width");m.height.value=s.height=l.dom.getAttrib(e,"height");m.img_classes.value=o;m.img_style.value=l.dom.getAttrib(e,"style");if(j.getAttrib(e,"hspace")){s.updateStyle("hspace")}if(j.getAttrib(e,"border")){s.updateStyle("border")}if(j.getAttrib(e,"vspace")){s.updateStyle("vspace")}if(pa=l.dom.getParent(e,"A")){m.link_href.value=s.current=l.dom.getAttrib(pa,"href");m.link_title.value=l.dom.getAttrib(pa,"title");m.link_rel.value=s.link_rel=l.dom.getAttrib(pa,"rel");m.link_style.value=l.dom.getAttrib(pa,"style");s.target_value=l.dom.getAttrib(pa,"target");m.link_classes.value=l.dom.getAttrib(pa,"class")}m.link_target.checked=(s.target_value&&s.target_value=="_blank")?"checked":"";g=p.substring(p.lastIndexOf("/"));g=g.replace(/-[0-9]{2,4}x[0-9]{2,4}/,"");s.link=p.substring(0,p.lastIndexOf("/"))+g;if(o.indexOf("alignleft")!=-1){s.I("alignleft").checked="checked";n.className=s.align="alignleft"}else{if(o.indexOf("aligncenter")!=-1){s.I("aligncenter").checked="checked";n.className=s.align="aligncenter"}else{if(o.indexOf("alignright")!=-1){s.I("alignright").checked="checked";n.className=s.align="alignright"}else{if(o.indexOf("alignnone")!=-1){s.I("alignnone").checked="checked";n.className=s.align="alignnone"}}}}if(s.width&&s.preloadImg.width){s.showSizeSet()}document.body.style.display=""},remove:function(){var a=tinyMCEPopup.editor,c,b;tinyMCEPopup.restoreSelection();b=a.selection.getNode();if(b.nodeName!="IMG"){return}if((c=a.dom.getParent(b,"div"))&&a.dom.hasClass(c,"mceTemp")){a.dom.remove(c)}else{if((c=a.dom.getParent(b,"A"))&&c.childNodes.length==1){a.dom.remove(c)}else{a.dom.remove(b)}}a.execCommand("mceRepaint");tinyMCEPopup.close();return},update:function(){var n=this,x=document.forms[0],g=tinyMCEPopup.editor,e,z,d=null,o,h,q,s,p=null,l=x.img_classes.value,m;tinyMCEPopup.restoreSelection();e=g.selection.getNode();if(e.nodeName!="IMG"){return}if(x.img_src.value===""){n.remove();return}if(x.img_cap.value!=""&&x.width.value!=""){p=1;l=l.replace(/align[^ "']+\s?/gi,"")}q=g.dom.getParent(e,"a");h=g.dom.getParent(e,"p");o=g.dom.getParent(e,"dl");s=g.dom.getParent(e,"div");tinyMCEPopup.execCommand("mceBeginUndoLevel");g.dom.setAttribs(e,{src:x.img_src.value,title:x.img_title.value,alt:x.img_alt.value,width:x.width.value,height:x.height.value,style:x.img_style.value,"class":l});if(x.link_href.value){if(q==null){if(!x.link_href.value.match(/https?:\/\//i)){x.link_href.value=tinyMCEPopup.editor.documentBaseURI.toAbsolute(x.link_href.value)}if(tinymce.isWebKit&&g.dom.hasClass(e,"aligncenter")){g.dom.removeClass(e,"aligncenter");d=1}tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1});if(d){g.dom.addClass(e,"aligncenter")}tinymce.each(g.dom.select("a"),function(b){if(g.dom.getAttrib(b,"href")=="#mce_temp_url#"){g.dom.setAttribs(b,{href:x.link_href.value,title:x.link_title.value,rel:x.link_rel.value,target:(x.link_target.checked==true)?"_blank":"","class":x.link_classes.value,style:x.link_style.value})}})}else{g.dom.setAttribs(q,{href:x.link_href.value,title:x.link_title.value,rel:x.link_rel.value,target:(x.link_target.checked==true)?"_blank":"","class":x.link_classes.value,style:x.link_style.value})}}if(p){var r,w="",k,j,u,a=10+parseInt(x.width.value),v=n.align.substring(5),C=(n.align=="aligncenter")?"mceTemp mceIEcenter":"mceTemp";if(o){g.dom.setAttribs(o,{"class":"wp-caption "+n.align,style:"width: "+a+"px;"});if(s){g.dom.setAttrib(s,"class",C)}if((j=g.dom.getParent(e,"dt"))&&(u=j.nextSibling)&&g.dom.hasClass(u,"wp-caption-dd")){g.dom.setHTML(u,x.img_cap.value)}}else{var y="",c;if((r=x.img_classes.value.match(/wp-image-([0-9]{1,6})/))&&r[1]){w="attachment_"+r[1]}if(x.link_href.value&&(y=g.dom.getParent(e,"a"))){if(y.childNodes.length==1){m=g.dom.getOuterHTML(y)}else{m=g.dom.getOuterHTML(y);m=m.match(/<a[^>]+>/i);m=m+g.dom.getOuterHTML(e)+"</a>"}}else{m=g.dom.getOuterHTML(e)}m='<dl id="'+w+'" class="wp-caption '+n.align+'" style="width: '+a+'px"><dt class="wp-caption-dt">'+m+'</dt><dd class="wp-caption-dd">'+x.img_cap.value+"</dd></dl>";k=g.dom.create("div",{"class":C},m);if(h){h.parentNode.insertBefore(k,h);if(h.childNodes.length==1){g.dom.remove(h)}else{if(y&&y.childNodes.length==1){g.dom.remove(y)}else{g.dom.remove(e)}}}else{if(c=g.dom.getParent(e,"TD,TH,LI")){c.appendChild(k);if(y&&y.childNodes.length==1){g.dom.remove(y)}else{g.dom.remove(e)}}}}}else{if(o&&s){var B;if(x.link_href.value&&(B=g.dom.getParent(e,"a"))){m=g.dom.getOuterHTML(B)}else{m=g.dom.getOuterHTML(e)}h=g.dom.create("p",{},m);s.parentNode.insertBefore(h,s);g.dom.remove(s)}}if(x.img_classes.value.indexOf("aligncenter")!=-1){if(h&&(!h.style||h.style.textAlign!="center")){g.dom.setStyle(h,"textAlign","center")}}else{if(h&&h.style&&h.style.textAlign=="center"){g.dom.setStyle(h,"textAlign","")}}if(!x.link_href.value&&q){z=g.selection.getBookmark();g.dom.remove(q,1);g.selection.moveToBookmark(z)}tinyMCEPopup.execCommand("mceEndUndoLevel");g.execCommand("mceRepaint");tinyMCEPopup.close()},updateStyle:function(a){var g=tinyMCEPopup.dom,d,c,e=document.forms[0],b=g.create("img",{style:e.img_style.value});if(tinyMCEPopup.editor.settings.inline_styles){if(a=="align"){g.setStyle(b,"float","");g.setStyle(b,"vertical-align","");c=e.align.value;if(c){if(c=="left"||c=="right"){g.setStyle(b,"float",c)}else{b.style.verticalAlign=c}}}if(a=="border"){g.setStyle(b,"border","");c=e.border.value;if(c||c=="0"){if(c=="0"){b.style.border="0"}else{b.style.border=c+"px solid black"}}}if(a=="hspace"){g.setStyle(b,"marginLeft","");g.setStyle(b,"marginRight","");c=e.hspace.value;if(c){b.style.marginLeft=c+"px";b.style.marginRight=c+"px"}}if(a=="vspace"){g.setStyle(b,"marginTop","");g.setStyle(b,"marginBottom","");c=e.vspace.value;if(c){b.style.marginTop=c+"px";b.style.marginBottom=c+"px"}}e.img_style.value=g.serializeStyle(g.parseStyle(b.style.cssText));this.demoSetStyle()}},checkVal:function(a){if(a.value==""){if(a.id=="img_src"){a.value=this.I("img_demo").src||this.preloadImg.src}}},resetImageData:function(){var a=document.forms[0];a.width.value=a.height.value=""},updateImageData:function(){var b=document.forms[0],a=wpImage;if(b.width.value==""||b.height.value==""){b.width.value=a.width=a.preloadImg.width;b.height.value=a.height=a.preloadImg.height}a.showSizeSet();a.demoSetSize();if(b.img_style.value){a.demoSetStyle()}},getImageData:function(){var a=wpImage,b=document.forms[0];a.preloadImg=new Image();a.preloadImg.onload=a.updateImageData;a.preloadImg.onerror=a.resetImageData;a.preloadImg.src=tinyMCEPopup.editor.documentBaseURI.toAbsolute(b.img_src.value)}};window.onload=function(){wpImage.init()};wpImage.preInit();
\ No newline at end of file
