var ImageDialog={preInit:function(){var b;tinyMCEPopup.requireLangPack();if(b=tinyMCEPopup.getParam("external_image_list_url")){document.write('<script language="javascript" type="text/javascript" src="'+tinyMCEPopup.editor.documentBaseURI.toAbsolute(b)+'"><\/script>')}},init:function(){var c=document.forms[0],d=tinyMCEPopup.editor;document.getElementById("srcbrowsercontainer").innerHTML=getBrowserHTML("srcbrowser","src","image","theme_advanced_image");if(isVisible("srcbrowser")){document.getElementById("src").style.width="180px"}e=d.selection.getNode();this.fillFileList("image_list","tinyMCEImageList");if(e.nodeName=="IMG"){c.src.value=d.dom.getAttrib(e,"src");c.alt.value=d.dom.getAttrib(e,"alt");c.border.value=this.getAttrib(e,"border");c.vspace.value=this.getAttrib(e,"vspace");c.hspace.value=this.getAttrib(e,"hspace");c.width.value=d.dom.getAttrib(e,"width");c.height.value=d.dom.getAttrib(e,"height");c.insert.value=d.getLang("update");this.styleVal=d.dom.getAttrib(e,"style");selectByValue(c,"image_list",c.src.value);selectByValue(c,"align",this.getAttrib(e,"align"));this.updateStyle()}},fillFileList:function(j,m){var k=tinyMCEPopup.dom,i=k.get(j),l,h;m=window[m];if(m&&m.length>0){i.options[i.options.length]=new Option("","");tinymce.each(m,function(a){i.options[i.options.length]=new Option(a[0],a[1])})}else{k.remove(k.getParent(j,"tr"))}},update:function(){var i=document.forms[0],h=i.elements,f=tinyMCEPopup.editor,k={},j;tinyMCEPopup.restoreSelection();if(i.src.value===""){if(f.selection.getNode().nodeName=="IMG"){f.dom.remove(f.selection.getNode());f.execCommand("mceRepaint")}tinyMCEPopup.close();return}if(!f.settings.inline_styles){k=tinymce.extend(k,{vspace:h.vspace.value,hspace:h.hspace.value,border:h.border.value,align:getSelectValue(i,"align")})}else{k.style=this.styleVal}tinymce.extend(k,{src:i.src.value,alt:i.alt.value,width:i.width.value,height:i.height.value});j=f.selection.getNode();if(j&&j.nodeName=="IMG"){f.dom.setAttribs(j,k)}else{f.execCommand("mceInsertContent",false,'<img id="__mce_tmp" />',{skip_undo:1});f.dom.setAttribs("__mce_tmp",k);f.dom.setAttrib("__mce_tmp","id","");f.undoManager.add()}tinyMCEPopup.close()},updateStyle:function(){var h=tinyMCEPopup.dom,f,g,i=document.forms[0];if(tinyMCEPopup.editor.settings.inline_styles){f=tinyMCEPopup.dom.parseStyle(this.styleVal);g=getSelectValue(i,"align");if(g){if(g=="left"||g=="right"){f["float"]=g;delete f["vertical-align"]}else{f["vertical-align"]=g;delete f["float"]}}else{delete f["float"];delete f["vertical-align"]}g=i.border.value;if(g||g=="0"){if(g=="0"){f.border="0"}else{f.border=g+"px solid black"}}else{delete f.border}g=i.hspace.value;if(g){delete f.margin;f["margin-left"]=g+"px";f["margin-right"]=g+"px"}else{delete f["margin-left"];delete f["margin-right"]}g=i.vspace.value;if(g){delete f.margin;f["margin-top"]=g+"px";f["margin-bottom"]=g+"px"}else{delete f["margin-top"];delete f["margin-bottom"]}f=tinyMCEPopup.dom.parseStyle(h.serializeStyle(f),"img");this.styleVal=h.serializeStyle(f,"img")}},getAttrib:function(l,i){var m=tinyMCEPopup.editor,j=m.dom,h,k;if(m.settings.inline_styles){switch(i){case"align":if(h=j.getStyle(l,"float")){return h}if(h=j.getStyle(l,"vertical-align")){return h}break;case"hspace":h=j.getStyle(l,"margin-left");k=j.getStyle(l,"margin-right");if(h&&h==k){return parseInt(h.replace(/[^0-9]/g,""))}break;case"vspace":h=j.getStyle(l,"margin-top");k=j.getStyle(l,"margin-bottom");if(h&&h==k){return parseInt(h.replace(/[^0-9]/g,""))}break;case"border":h=0;tinymce.each(["top","right","bottom","left"],function(a){a=j.getStyle(l,"border-"+a+"-width");if(!a||(a!=h&&h!==0)){h=0;return false}if(a){h=a}});if(h){return parseInt(h.replace(/[^0-9]/g,""))}break}}if(h=j.getAttrib(l,i)){return h}return""},resetImageData:function(){var b=document.forms[0];b.width.value=b.height.value=""},updateImageData:function(){var c=document.forms[0],d=ImageDialog;if(c.width.value==""){c.width.value=d.preloadImg.width}if(c.height.value==""){c.height.value=d.preloadImg.height}},getImageData:function(){var b=document.forms[0];this.preloadImg=new Image();this.preloadImg.onload=this.updateImageData;this.preloadImg.onerror=this.resetImageData;this.preloadImg.src=tinyMCEPopup.editor.documentBaseURI.toAbsolute(b.src.value)}};ImageDialog.preInit();tinyMCEPopup.onInit.add(ImageDialog.init,ImageDialog);