(function($){$.fn.document=function(){var element=this.get(0);if(element.nodeName.toLowerCase()=="iframe")return element.contentWindow.document;return this};$.fn.documentSelection=function(){var element=this.get(0);if(element.contentWindow.document.selection)return element.contentWindow.document.selection.createRange().text;else return element.contentWindow.getSelection().toString()};$.fn.wysiwyg=function(options){if(arguments.length>0&&arguments[0].constructor==String){var action=arguments[0].toString(); var params=[];for(var i=1;iSTYLE_SHEETINITIAL_CONTENT', css:{},debug:false,autoSave:true,rmUnwantedBr:true,brIE:true,controls:{},messages:{}},options);options.messages=$.extend(true,options.messages,Wysiwyg.MSGS_EN);options.controls=$.extend(true,options.controls,Wysiwyg.TOOLBAR);for(var control in controls)if(control in options.controls)$.extend(options.controls[control],controls[control]);else options.controls[control]=controls[control];return this.each(function(){Wysiwyg(this,options)})};function Wysiwyg(element,options){return this instanceof Wysiwyg? this.init(element,options):new Wysiwyg(element,options)}$.extend(Wysiwyg,{resize:function(){var self=$.data(this,"wysiwyg");$(this).show();var newX=this.width||this.clientWidth;var newY=this.height||this.clientHeight;$(this).hide();$(self.editor).css({minHeight:(newY-6).toString()+"px",width:(newX-8).toString()+"px"});$(self.element).css({width:newX>0?newX.toString()+"px":"100%"})},insertImage:function(szURL,attributes){var self=$.data(this,"wysiwyg");if(self.constructor==Wysiwyg&&szURL&&szURL.length> 0){if($.browser.msie)self.focus();if(attributes){self.editorDoc.execCommand("insertImage",false,"#jwysiwyg#");var img=self.getElementByAttributeValue("img","src","#jwysiwyg#");if(img){img.src=szURL;for(var attribute in attributes)img.setAttribute(attribute,attributes[attribute])}}else self.editorDoc.execCommand("insertImage",false,szURL)}},createLink:function(szURL){var self=$.data(this,"wysiwyg");if(self.constructor==Wysiwyg&&szURL&&szURL.length>0){var selection=$(self.editor).documentSelection(); if(selection.length>0){if($.browser.msie)self.focus();self.editorDoc.execCommand("unlink",false,[]);self.editorDoc.execCommand("createLink",false,szURL)}else if(self.options.messages.nonSelection)alert(self.options.messages.nonSelection)}},insertHtml:function(szHTML){var self=$.data(this,"wysiwyg");if(self.constructor==Wysiwyg&&szHTML&&szHTML.length>0)if($.browser.msie){self.focus();self.editorDoc.execCommand("insertImage",false,"#jwysiwyg#");var img=self.getElementByAttributeValue("img","src","#jwysiwyg#"); if(img)$(img).replaceWith(szHTML)}else self.editorDoc.execCommand("insertHTML",false,szHTML)},setContent:function(newContent){var self=$.data(this,"wysiwyg");self.setContent(newContent);self.saveContent()},clear:function(){var self=$.data(this,"wysiwyg");self.setContent("");self.saveContent()},MSGS_EN:{nonSelection:"select the text you wish to link"},TOOLBAR:{bold:{visible:true,tags:["b","strong"],css:{fontWeight:"bold"},tooltip:"Bold"},italic:{visible:true,tags:["i","em"],css:{fontStyle:"italic"}, tooltip:"Italic"},strikeThrough:{visible:true,tags:["s","strike"],css:{textDecoration:"line-through"},tooltip:"Strike-through"},underline:{visible:true,tags:["u"],css:{textDecoration:"underline"},tooltip:"Underline"},separator00:{visible:true,separator:true},justifyLeft:{visible:true,css:{textAlign:"left"},tooltip:"Justify Left"},justifyCenter:{visible:true,tags:["center"],css:{textAlign:"center"},tooltip:"Justify Center"},justifyRight:{visible:true,css:{textAlign:"right"},tooltip:"Justify Right"}, justifyFull:{visible:true,css:{textAlign:"justify"},tooltip:"Justify Full"},separator01:{visible:true,separator:true},indent:{visible:true,tooltip:"Indent"},outdent:{visible:true,tooltip:"Outdent"},separator02:{visible:false,separator:true},subscript:{visible:true,tags:["sub"],tooltip:"Subscript"},superscript:{visible:true,tags:["sup"],tooltip:"Superscript"},separator03:{visible:true,separator:true},undo:{visible:true,tooltip:"Undo"},redo:{visible:true,tooltip:"Redo"},separator04:{visible:true,separator:true}, insertOrderedList:{visible:true,tags:["ol"],tooltip:"Insert Ordered List"},insertUnorderedList:{visible:true,tags:["ul"],tooltip:"Insert Unordered List"},insertHorizontalRule:{visible:true,tags:["hr"],tooltip:"Insert Horizontal Rule"},separator05:{separator:true},createLink:{visible:true,exec:function(){var selection=$(this.editor).documentSelection();if(selection.length>0)if($.browser.msie){this.focus();this.editorDoc.execCommand("createLink",true,null)}else{var szURL=prompt("URL","http://");if(szURL&& szURL.length>0){this.editorDoc.execCommand("unlink",false,[]);this.editorDoc.execCommand("createLink",false,szURL)}}else if(this.options.messages.nonSelection)alert(this.options.messages.nonSelection)},tags:["a"],tooltip:"Create link"},insertImage:{visible:true,exec:function(){if($.browser.msie){this.focus();this.editorDoc.execCommand("insertImage",true,null)}else{var szURL=prompt("URL","http://");if(szURL&&szURL.length>0)this.editorDoc.execCommand("insertImage",false,szURL)}},tags:["img"],tooltip:"Insert image"}, separator06:{separator:true},h1mozilla:{visible:true&&$.browser.mozilla,className:"h1",command:"heading",arguments:["h1"],tags:["h1"],tooltip:"Header 1"},h2mozilla:{visible:true&&$.browser.mozilla,className:"h2",command:"heading",arguments:["h2"],tags:["h2"],tooltip:"Header 2"},h3mozilla:{visible:true&&$.browser.mozilla,className:"h3",command:"heading",arguments:["h3"],tags:["h3"],tooltip:"Header 3"},h1:{visible:true&&!$.browser.mozilla,className:"h1",command:"formatBlock",arguments:["

"],tags:["h1"], tooltip:"Header 1"},h2:{visible:true&&!$.browser.mozilla,className:"h2",command:"formatBlock",arguments:["

"],tags:["h2"],tooltip:"Header 2"},h3:{visible:true&&!$.browser.mozilla,className:"h3",command:"formatBlock",arguments:["

"],tags:["h3"],tooltip:"Header 3"},separator07:{visible:false,separator:true},cut:{visible:false,tooltip:"Cut"},copy:{visible:false,tooltip:"Copy"},paste:{visible:false,tooltip:"Paste"},separator08:{separator:false&&!$.browser.msie},increaseFontSize:{visible:false&& !$.browser.msie,tags:["big"],tooltip:"Increase font size"},decreaseFontSize:{visible:false&&!$.browser.msie,tags:["small"],tooltip:"Decrease font size"},separator09:{separator:true},html:{visible:false,exec:function(){if(this.viewHTML){this.setContent($(this.original).val());$(this.original).hide()}else{this.saveContent();$(this.original).show()}this.viewHTML=!this.viewHTML},tooltip:"View source code"},removeFormat:{visible:true,exec:function(){if($.browser.msie)this.focus();this.editorDoc.execCommand("removeFormat", false,[]);this.editorDoc.execCommand("unlink",false,[])},tooltip:"Remove formatting"}}});$.extend(Wysiwyg.prototype,{original:null,options:{},element:null,editor:null,focus:function(){$(this.editorDoc.body).focus()},init:function(element,options){var self=this;this.editor=element;this.options=options||{};$.data(element,"wysiwyg",this);var newX=element.width||element.clientWidth;var newY=element.height||element.clientHeight;if(element.nodeName.toLowerCase()=="textarea"){this.original=element;if(newX== 0&&element.cols)newX=element.cols*8+21;if(newY==0&&element.rows)newY=element.rows*16+16;var editor=this.editor=$('').css({minHeight:(newY-6).toString()+"px",width:(newX-8).toString()+"px"}).attr("id",$(element).attr("id")+"IFrame").attr("frameborder","0");this.editor.attr("tabindex",$(element).attr("tabindex"));if($.browser.msie)this.editor.css("height",newY.toString()+"px")}var panel=this.panel=$('');this.appendControls(); this.element=$("
").css({width:newX>0?newX.toString()+"px":"100%"}).addClass("wysiwyg").append(panel).append($("