/* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function(){var a=1,b=2,c=4,d=8,e=/^\s*(\d+)((px)|\%)?\s*$/i,f=/(^\s*(\d+)((px)|\%)?\s*$)|^$/i,g=function(){var m=this.getValue(),n=this.getDialog(),o=m.match(e);if(o){if(o[2]=='%')i(n,false);m=o[1];}if(n.lockRatio){var p=n.originalElement;if(p.getCustomData('isReady')=='true')if(this.id=='txtHeight'){if(m&&m!='0')m=Math.round(p.$.width*(m/p.$.height));if(!isNaN(m))n.setValueOf('info','txtWidth',m);}else{if(m&&m!='0')m=Math.round(p.$.height*(m/p.$.width));if(!isNaN(m))n.setValueOf('info','txtHeight',m);}}h(n);},h=function(m){if(!m.originalElement||!m.preview)return 1;m.commitContent(c,m.preview);return 0;},i=function(m,n){var o=m.originalElement,p=CKEDITOR.document.getById('btnLockSizes');if(o.getCustomData('isReady')=='true'){if(n=='check'){var q=m.getValueOf('info','txtWidth'),r=m.getValueOf('info','txtHeight'),s=o.$.width*1000/o.$.height,t=q*1000/r;m.lockRatio=false;if(!q&&!r)m.lockRatio=true;else if(!isNaN(s)&&!isNaN(t))if(Math.round(s)==Math.round(t))m.lockRatio=true;}else if(n!=undefined)m.lockRatio=n;else m.lockRatio=!m.lockRatio;}else if(n!='check')m.lockRatio=false;if(m.lockRatio)p.removeClass('cke_btn_unlocked');else p.addClass('cke_btn_unlocked');return m.lockRatio;},j=function(m){var n=m.originalElement;if(n.getCustomData('isReady')=='true'){m.setValueOf('info','txtWidth',n.$.width);m.setValueOf('info','txtHeight',n.$.height);}h(m);},k=function(m,n){if(m!=a)return;function o(t,u){var v=t.match(e);if(v){if(v[2]=='%'){v[1]+='%';i(p,false);}return v[1];}return u;};var p=this.getDialog(),q='',r=this.id=='txtWidth'?'width':'height',s=n.getAttribute(r);if(s)q=o(s,q);q=o(n.$.style[r],q);this.setValue(q);},l=function(m,n){var o=function(){var r=this;var q=r.originalElement;q.setCustomData('isReady','true');q.removeListener('load',o);q.removeListener('error',p);q.removeListener('abort',p);CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');if(!r.dontResetSize)j(r);if(r.firstLoad)i(r,'check');r.firstLoad=false;r.dontResetSize=false;},p=function(){var s=this;var q=s.originalElement;q.removeListener('load',o);q.removeListener('error',p);q.removeListener('abort',p);var r=CKEDITOR.getUrl(m.skinPath+'images/noimage.png');if(s.preview)s.preview.setAttribute('src',r);CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');i(s,false);};return{title:n=='image'?m.lang.image.title:m.lang.image.titleButton,minWidth:420,minHeight:310,onShow:function(){var u=this;u.imageElement=false;u.linkElement=false;u.imageEditMode=false;u.linkEditMode=false; u.lockRatio=true;u.dontResetSize=false;u.firstLoad=true;u.addLink=false;CKEDITOR.document.getById('ImagePreviewLoader').setStyle('display','none');u.preview=CKEDITOR.document.getById('previewImage');var q=u.getParentEditor(),r=u.getParentEditor().getSelection().getSelectedElement();u.originalElement=q.document.createElement('img');u.originalElement.setAttribute('alt','');u.originalElement.setCustomData('isReady','false');if(r&&r.getName()=='a'){u.linkElement=r;u.linkEditMode=true;var s=r.getChildren();if(s.count()==1){var t=s.getItem(0).getName();if(t=='img'||t=='input'){u.imageElement=s.getItem(0);if(u.imageElement.getName()=='img')u.imageEditMode='img';else if(u.imageElement.getName()=='input')u.imageEditMode='input';}}if(n=='image')u.setupContent(b,r);}else if(r&&r.getName()=='img'&&!r.getAttribute('_cke_protected_html'))u.imageEditMode='img';else if(r&&r.getName()=='input'&&r.getAttribute('type')&&r.getAttribute('type')=='image')u.imageEditMode='input';if(u.imageEditMode||u.imageElement){if(!u.imageElement)u.imageElement=r;u.setupContent(a,u.imageElement);i(u,true);}},onOk:function(){var s=this;if(s.imageEditMode){var q=s.imageEditMode,r=s.imageElement;if(n=='image'&&q=='input'&&confirm(m.lang.image.button2Img)){q='img';s.imageElement=m.document.createElement('img');s.imageElement.setAttribute('alt','');r.insertBeforeMe(s.imageElement);r.remove(false);}else if(n!='image'&&q=='img'&&confirm(m.lang.image.img2Button)){q='input';s.imageElement=m.document.createElement('input');s.imageElement.setAttributes({type:'image',alt:''});r.insertBeforeMe(s.imageElement);r.remove(false);}}else{if(n=='image')s.imageElement=m.document.createElement('img');else{s.imageElement=m.document.createElement('input');s.imageElement.setAttribute('type','image');}s.imageElement.setAttribute('alt','');}if(!s.linkEditMode)s.linkElement=m.document.createElement('a');s.commitContent(a,s.imageElement);s.commitContent(b,s.linkElement);if(!s.imageEditMode){if(s.addLink){if(!s.linkEditMode){s.linkElement.append(s.imageElement,false);m.insertElement(s.linkElement);}else s.linkElement.append(s.imageElement,false);}else m.insertElement(s.imageElement);}else if(!s.linkEditMode&&s.addLink){s.imageElement.insertBeforeMe(s.linkElement);s.imageElement.appendTo(s.linkElement);}else if(s.linkEditMode&&!s.addLink)s.linkElement.remove(true);},onLoad:function(){if(n!='image')this.hidePage('Link');},onHide:function(){var q=this;if(q.preview)q.commitContent(d,q.preview);if(q.originalElement){q.originalElement.removeListener('load',o); q.originalElement.removeListener('error',p);q.originalElement.removeListener('abort',p);q.originalElement.remove();q.originalElement=false;}},contents:[{id:'info',label:m.lang.image.infoTab,accessKey:'I',elements:[{type:'vbox',padding:0,children:[{type:'html',html:''+CKEDITOR.tools.htmlEncode(m.lang.image.url)+''},{type:'hbox',widths:['280px','110px'],align:'right',children:[{id:'txtUrl',type:'text',label:'',onChange:function(){var q=this.getDialog(),r=this.getValue();if(r.length>0){q=this.getDialog();var s=q.originalElement;s.setCustomData('isReady','false');var t=CKEDITOR.document.getById('ImagePreviewLoader');if(t)t.setStyle('display','');s.on('load',o,q);s.on('error',p,q);s.on('abort',p,q);s.setAttribute('src',r);q.preview.setAttribute('src',r);h(q);}},setup:function(q,r){if(q==a){var s=this.getDialog(),t=r.getAttribute('_cke_saved_src');if(!t)t=r.getAttribute('src');s.dontResetSize=true;this.setValue(t);this.focus();}},commit:function(q,r){var s=this;if(q==a&&(s.getValue()||s.isChanged())){r.setAttribute('_cke_saved_src',decodeURI(s.getValue()));r.setAttribute('src',decodeURI(s.getValue()));}else if(q==d){r.setAttribute('src','');r.removeAttribute('src');}}},{type:'button',id:'browse',align:'center',label:m.lang.common.browseServer,hidden:true,filebrowser:'info:txtUrl'}]}]},{id:'txtAlt',type:'text',label:m.lang.image.alt,accessKey:'A','default':'',onChange:function(){h(this.getDialog());},setup:function(q,r){if(q==a)this.setValue(r.getAttribute('alt'));},commit:function(q,r){var s=this;if(q==a){if(s.getValue()||s.isChanged())r.setAttribute('alt',s.getValue());}else if(q==c)r.setAttribute('alt',s.getValue());else if(q==d)r.removeAttribute('alt');}},{type:'hbox',widths:['140px','240px'],children:[{type:'vbox',padding:10,children:[{type:'hbox',widths:['70%','30%'],children:[{type:'vbox',padding:1,children:[{type:'text',id:'txtWidth',labelLayout:'horizontal',label:m.lang.image.width,onKeyUp:g,validate:function(){var q=this.getValue().match(f);if(!q)alert(m.lang.common.validateNumberFailed);return!!q;},setup:k,commit:function(q,r){var v=this;if(q==a){var s=v.getValue();if(s)r.setAttribute('width',s);else if(!s&&v.isChanged())r.removeAttribute('width');}else if(q==c){s=v.getValue();var t=s.match(e);if(!t){var u=v.getDialog().originalElement;if(u.getCustomData('isReady')=='true')r.setStyle('width',u.$.width+'px');}else r.setStyle('width',s+'px');}else if(q==d){r.setStyle('width','0px');r.removeAttribute('width');r.removeStyle('width');}}},{type:'text',id:'txtHeight',labelLayout:'horizontal',label:m.lang.image.height,onKeyUp:g,validate:function(){var q=this.getValue().match(f); if(!q)alert(m.lang.common.validateNumberFailed);return!!q;},setup:k,commit:function(q,r){var v=this;if(q==a){var s=v.getValue();if(s)r.setAttribute('height',s);else if(!s&&v.isChanged())r.removeAttribute('height');}else if(q==c){s=v.getValue();var t=s.match(e);if(!t){var u=v.getDialog().originalElement;if(u.getCustomData('isReady')=='true')r.setStyle('height',u.$.height+'px');}else r.setStyle('height',s+'px');}else if(q==d){r.setStyle('height','0px');r.removeAttribute('height');r.removeStyle('height');}}}]},{type:'html',style:'position:relative;top:10px;height:50px;',onLoad:function(){var q=CKEDITOR.document.getById('btnResetSize'),r=CKEDITOR.document.getById('btnLockSizes');if(q){q.on('click',function(){j(this);},this.getDialog());q.on('mouseover',function(){this.addClass('BtnOver');},q);q.on('mouseout',function(){this.removeClass('BtnOver');},q);}if(r){r.on('click',function(){var w=this;var s=i(w),t=w.originalElement,u=w.getValueOf('info','txtWidth');if(t.getCustomData('isReady')=='true'&&u){var v=t.$.height/t.$.width*u;if(!isNaN(v)){w.setValueOf('info','txtHeight',Math.round(v));h(w);}}},this.getDialog());r.on('mouseover',function(){this.addClass('BtnOver');},r);r.on('mouseout',function(){this.removeClass('BtnOver');},r);}},html:'