window.jQuery&&function(a){a.extend(a,{fck:{waitFor:10,config:{Config:{}},path:"/fckeditor/",editors:[],loaded:false,intercepted:null,content:function(c,b){try{var d=FCKeditorAPI.GetInstance(c);b&&d.SetHTML(b);return d.GetXHTML(true)}catch(f){return""}},setHTML:function(c,b){if(typeof c=="object"){b=c.html;c=c.InstanceName||c.instance}return a.fck.content(c,b)},update:function(){for(var c=a.fck.editors,b=0;b<c.length;b++){var d=c[b].textarea,f=a.fck.content(c[b].InstanceName);d.val(f).filter("textarea").text(f);
f!=d.val()&&alert("Critical error in FCK plugin:\nUnable to update form data")}},clean:function(){var c={},b=[];a.each(a.fck.editors,function(){if(a("#"+this.InstanceName).length>0)c[this.InstanceName]=this});a.each(c,function(){b[b.length]=this});a.fck.editors=b},create:function(c){var b=a.extend({},a.fck.config||{},c||{});a.extend(b,{selector:b.selector||"textarea.fck, textarea.fckeditor",BasePath:b.path||b.BasePath||a.fck.path});var d=a(b.e);if(!d.length>0)d=a(b.selector);if(!(!d.length>0)){b=
a.extend({},b,(a.meta?d.data():a.metadata?d.metadata():null)||{});if(!a.fck.loading&&!a.fck.loaded){a.fck.loading=true;a.getScript(b.BasePath+"fckeditor.js",function(){a.fck.loaded=true})}var f=function(){if(a.fck.loaded)a.fck.editor(d,b);else if(a.fck.waited<=0)alert("jQuery.fckeditor plugin error: The FCKEditor script did not load.");else{a.fck.waitFor--;window.setTimeout(f,1E3)}};f(d);return d}},intercept:function(){if(!a.fck.intercepted){a.fck.intercepted={ajaxSubmit:a.fn.ajaxSubmit||function(){}};
a.fn.ajaxSubmit=function(){a.fck.update();return a.fck.intercepted.ajaxSubmit.apply(this,arguments)}}},editor:function(c,b){b=a.extend({},a.fck.config||{},b||{});a.extend(b,{Width:b.width||b.Width||"100%",Height:b.height||b.Height||"500px",BasePath:b.path||b.BasePath||a.fck.path,ToolbarSet:b.toolbar||b.ToolbarSet||"Default",Config:b.config||b.Config||{}});c=a(c);if(c.size()>0){var d=a.fck.editors;c.each(function(f,e){if((e.tagName||"").toLowerCase()!="textarea")return alert(["An invalid parameter has been passed to the $.fckeditor.editor function",
"tagName:"+e.tagName,"name:"+e.name,"id:"+e.id].join("\n"));f=a(e);if(!e.name)e.name="fck"+(a.fck.editors.length+1);if(!e.id)e.id=e.name;if(e.id&&!e.fck){var g=d.length;d[g]=new FCKeditor(e.name);a.extend(d[g],b,b.Config||{});d[g].ReplaceTextarea();d[g].textarea=f;e.fck=d[g]}});a.fck.editors=d;a.fck.clean()}return c},start:function(c){a.fck.intercept();return a.fck.create(c)}}});a.extend(a.fn,{fck:function(c){a.fck.start(a.extend(c||{},{e:this}))}})}(jQuery);
