
var WYSIWYG={Settings:function(){this.ImagesDir="images/";this.PopupsDir="popups/";this.CSSFile="styles/wysiwyg.css";this.Width="500px";this.Height="200px";this.DefaultStyle="font-family: Arial; font-size: 12px; background-color: #FFFFFF";this.DisabledStyle="font-family: Arial; font-size: 12px; background-color: #EEEEEE";this.PreviewWidth=500;this.PreviewHeight=400;this.RemoveFormatConfMessage="Clean HTML inserted by MS Word ?";this.NoValidBrowserMessage="openWYSIWYG does not support your browser.";this.AnchorPathToStrip="auto";this.ImagePathToStrip="auto";this.ContextMenu=true;this.StatusBarEnabled=true;this.InvertIELineBreaks=false;this.ReplaceLineBreaks=false;this.Opener="admin.asp";this.ImagePopupFile="";this.ImagePopupWidth=0;this.ImagePopupHeight=0;this.Toolbar=new Array();this.Toolbar[0]=new Array("font","fontsize","headings","bold","italic","underline","strikethrough","seperator","forecolor","backcolor","seperator","justifyfull","justifyleft","justifycenter","justifyright","seperator","unorderedlist","orderedlist","outdent","indent");this.Toolbar[1]=new Array("save","seperator","subscript","superscript","seperator","cut","copy","paste","removeformat","seperator","undo","redo","seperator","inserttable","insertimage","createlink","seperator","preview","print","seperator","viewSource","maximize","seperator","help");this.DropDowns=new Array();this.DropDowns['font']={id:"fonts",command:"FontName",label:"<span style=\"font-family:{value};font-size:12px;\">{value}</span>",width:"90px",elements:new Array("Tahoma","Courier New")};this.DropDowns['fontsize']={id:"fontsizes",command:"FontSize",label:"<font size=\"{value}\">Size {value}</font>",width:"54px",elements:new Array("1","2","3","4")};this.DropDowns['headings']={id:"headings",command:"FormatBlock",label:"<{value} style=\"margin:0px;text-decoration:none;font-family:Tahoma\">{value}</{value}>",width:"74px",elements:new Array("H2","H3")};this.addToolbarElement=function(element,toolbar,position){if(element!="seperator"){this.removeToolbarElement(element);}
if(this.Toolbar[toolbar-1]==null){this.Toolbar[toolbar-1]=new Array();}
this.Toolbar[toolbar-1].splice(position+1,1,element);};this.removeToolbarElement=function(element){if(element=="seperator"){return;}
for(var i=0;i<this.Toolbar.length;i++){if(this.Toolbar[i]){var toolbar=this.Toolbar[i];for(var j=0;j<toolbar.length;j++){if(toolbar[j]!=null&&toolbar[j]==element){this.Toolbar[i].splice(j,1);}}}}};this.clearToolbar=function(toolbar){if(typeof toolbar=="undefined"){this.Toolbar=new Array();}
else{this.Toolbar[toolbar+1]=new Array();}};},ToolbarList:{"bold":['Bold','Bold','bold.gif','bold_on.gif'],"italic":['Italic','Italic','italics.gif','italics_on.gif'],"underline":['Underline','Underline','underline.gif','underline_on.gif'],"strikethrough":['Strikethrough','Strikethrough','strikethrough.gif','strikethrough_on.gif'],"seperator":['','','seperator.gif','seperator.gif'],"subscript":['Subscript','Subscript','subscript.gif','subscript_on.gif'],"superscript":['Superscript','Superscript','superscript.gif','superscript_on.gif'],"justifyleft":['Justifyleft','Justifyleft','justify_left.gif','justify_left_on.gif'],"justifycenter":['Justifycenter','Justifycenter','justify_center.gif','justify_center_on.gif'],"justifyright":['Justifyright','Justifyright','justify_right.gif','justify_right_on.gif'],"justifyfull":['Justifyfull','Justifyfull','justify_justify.gif','justify_justify_on.gif'],"unorderedlist":['InsertUnorderedList','Insert Unordered List','list_unordered.gif','list_unordered_on.gif'],"orderedlist":['InsertOrderedList','Insert Ordered List','list_ordered.gif','list_ordered_on.gif'],"outdent":['Outdent','Outdent','indent_left.gif','indent_left_on.gif'],"indent":['Indent','Indent','indent_right.gif','indent_right_on.gif'],"cut":['Cut','Cut','cut.gif','cut_on.gif'],"copy":['Copy','Copy','copy.gif','copy_on.gif'],"paste":['Paste','Paste','paste.gif','paste_on.gif'],"forecolor":['ForeColor','Fore Color','forecolor.gif','forecolor_on.gif'],"backcolor":['BackColor','Back Color','backcolor.gif','backcolor_on.gif'],"undo":['Undo','Undo','undo.gif','undo_on.gif'],"redo":['Redo','Redo','redo.gif','redo_on.gif'],"inserttable":['InsertTable','Insert Table','insert_table.gif','insert_table_on.gif'],"insertimage":['InsertImage','Insert Image','insert_picture.gif','insert_picture_on.gif'],"createlink":['CreateLink','Create Link','insert_hyperlink.gif','insert_hyperlink_on.gif'],"viewSource":['ViewSource','View Source','view_source.gif','view_source_on.gif'],"viewText":['ViewText','View Text','view_text.gif','view_text_on.gif'],"help":['Help','Help','help.gif','help_on.gif'],"fonts":['Fonts','Select Font','select_font.gif','select_font_on.gif'],"fontsizes":['Fontsizes','Select Size','select_size.gif','select_size_on.gif'],"headings":['Headings','Select Size','select_heading.gif','select_heading_on.gif'],"preview":['Preview','Preview','preview.gif','preview_on.gif'],"print":['Print','Print','print.gif','print_on.gif'],"removeformat":['RemoveFormat','Strip Word HTML','remove_format.gif','remove_format_on.gif'],"delete":['Delete','Delete','delete.gif','delete_on.gif'],"save":['Save','Save document','save.gif','save_on.gif'],"return":['Return','Return without saving','return.gif','return_on.gif'],"maximize":['Maximize','Maximize the editor','maximize.gif','maximize_on.gif']},config:new Array(),viewTextMode:new Array(),maximized:new Array(),getRange:function(sel){return sel.createRange?sel.createRange():sel.getRangeAt(0);},getEditorDiv:function(n){return $("wysiwyg_div_"+n);},getEditorTable:function(n){return $("wysiwyg_table_"+n);},getEditor:function(n){return $("wysiwyg"+n);},getEditorWindow:function(n){return this.getEditor(n).contentWindow;},attach:function(id,settings){if(id!="all"){this.setSettings(id,settings);WYSIWYG_Core.includeCSS(this.config[id].CSSFile);WYSIWYG_Core.addEvent(window,"load",function generateEditor(){WYSIWYG._generate(id,settings);});}
else{WYSIWYG_Core.addEvent(window,"load",function generateEditor(){WYSIWYG.attachAll(settings);});}},attachAll:function(settings){var areas=document.getElementsByTagName("textarea");for(var i=0;i<areas.length;i++){var id=areas[i].getAttribute("id");if(id==null||id=="")continue;this.setSettings(id,settings);WYSIWYG_Core.includeCSS(this.config[id].CSSFile);WYSIWYG._generate(id,settings);}},display:function(id,settings){if(id!="all"){this.setSettings(id,settings);WYSIWYG_Core.includeCSS(this.config[id].CSSFile);WYSIWYG_Core.addEvent(window,"load",function displayIframe(){WYSIWYG._display(id,settings);});}
else{WYSIWYG_Core.addEvent(window,"load",function displayIframe(){WYSIWYG.displayAll(settings);});}},displayAll:function(settings){var areas=document.getElementsByTagName("textarea");for(var i=0;i<areas.length;i++){var id=areas[i].getAttribute("id");if(id==null||id=="")continue;this.setSettings(id,settings);WYSIWYG_Core.includeCSS(this.config[id].CSSFile);WYSIWYG._display(id,settings);}},setSettings:function(n,settings){if(typeof(settings)!="object"){this.config[n]=new this.Settings();}
else{this.config[n]=settings;}},insertImage:function(src,width,height,align,border,alt,hspace,vspace,n){var doc=this.getEditorWindow(n).document;var sel=this.getSelection(n);var range=this.getRange(sel);var img=this.findParent("img",range);var update=(img==null)?false:true;if(!update){img=doc.createElement("img");}
WYSIWYG_Core.setAttribute(img,"src",src);WYSIWYG_Core.setAttribute(img,"style","width:"+width+";height:"+height);if(align!=""){WYSIWYG_Core.setAttribute(img,"align",align);}else{img.removeAttribute("align");}
WYSIWYG_Core.setAttribute(img,"border",border);WYSIWYG_Core.setAttribute(img,"alt",alt);WYSIWYG_Core.setAttribute(img,"hspace",hspace);WYSIWYG_Core.setAttribute(img,"vspace",vspace);img.removeAttribute("width");img.removeAttribute("height");if(update){return;}
if(WYSIWYG_Core.isMSIE){range.pasteHTML(img.outerHTML);}
else{this.insertNodeAtSelection(img,n);}},insertLink:function(href,target,style,styleClass,name,n){var doc=this.getEditorWindow(n).document;var sel=this.getSelection(n);var range=this.getRange(sel);var lin=null;if(WYSIWYG_Core.isMSIE){if(sel.type=="Control"&&range.length==1){range=this.getTextRange(range(0));range.select();}}
lin=this.findParent("a",range);var update=(lin==null)?false:true;if(!update){lin=doc.createElement("a");}
WYSIWYG_Core.setAttribute(lin,"href",href);WYSIWYG_Core.setAttribute(lin,"class",styleClass);WYSIWYG_Core.setAttribute(lin,"className",styleClass);WYSIWYG_Core.setAttribute(lin,"target",target);WYSIWYG_Core.setAttribute(lin,"name",name);WYSIWYG_Core.setAttribute(lin,"style",style);if(update){return;}
if(WYSIWYG_Core.isMSIE){range.select();lin.innerHTML=range.htmlText;range.pasteHTML(lin.outerHTML);}
else{var node=range.startContainer;var pos=range.startOffset;if(node.nodeType!=3){node=node.childNodes[pos];}
if(node.tagName)
lin.appendChild(node);else
lin.innerHTML=sel;this.insertNodeAtSelection(lin,n);}},removeFormat:function(n){if(!confirm(this.config[n].RemoveFormatConfMessage)){return;}
var doc=this.getEditorWindow(n).document;var str=doc.body.innerHTML;str=str.replace(/<span([^>])*>(&nbsp;)*\s*<\/span>/gi,'');str=str.replace(/<span[^>]*>/gi,'');str=str.replace(/<\/span[^>]*>/gi,'');str=str.replace(/<p([^>])*>(&nbsp;)*\s*<\/p>/gi,'');str=str.replace(/<p[^>]*>/gi,'');str=str.replace(/<\/p[^>]*>/gi,'');str=str.replace(/<h([^>])[0-9]>(&nbsp;)*\s*<\/h>/gi,'');str=str.replace(/<h[^>][0-9]>/gi,'');str=str.replace(/<\/h[^>][0-9]>/gi,'');str=str.replace(/<B [^>]*>/ig,'<b>');str=str.replace(/<DIV[^>]*>/ig,'');str=str.replace(/<\/DIV>/gi,'');str=str.replace(/<[\/\w?]+:[^>]*>/ig,'');str=str.replace(/(&nbsp;){2,}/ig,'&nbsp;');str=str.replace(/<STRONG>/ig,'');str=str.replace(/<\/STRONG>/ig,'');str=str.replace(/<TT>/ig,'');str=str.replace(/<\/TT>/ig,'');str=str.replace(/<FONT [^>]*>/ig,'');str=str.replace(/<\/FONT>/ig,'');str=str.replace(/STYLE=\"[^\"]*\"/ig,'');str=str.replace(/<([\w]+) class=([^ |>]*)([^>]*)/gi,'<$1$3');str=str.replace(/<([\w]+) style="([^"]*)"([^>]*)/gi,'<$1$3');str=str.replace(/width=([^ |>]*)([^>]*)/gi,'');str=str.replace(/classname=([^ |>]*)([^>]*)/gi,'');str=str.replace(/align=([^ |>]*)([^>]*)/gi,'');str=str.replace(/valign=([^ |>]*)([^>]*)/gi,'');str=str.replace(/<\\?\??xml[^>]>/gi,'');str=str.replace(/<\/?\w+:[^>]*>/gi,'');str=str.replace(/<st1:.*?>/gi,'');str=str.replace(/o:/gi,'');str=str.replace(/<!--([^>])*>(&nbsp;)*\s*<\/-->/gi,'');str=str.replace(/<!--[^>]*>/gi,'');str=str.replace(/<\/--[^>]*>/gi,'');doc.body.innerHTML=str;},_display:function(n,settings){var textarea=$(n);if(textarea==null){alert("No textarea found with the given identifier (ID: "+n+").");return;}
if(!WYSIWYG_Core.isBrowserCompatible()){if(this.config[n].NoValidBrowserMessage!=""){alert(this.config[n].NoValidBrowserMessage);}
return;}
if(typeof(settings)!="object"){this.config[n]=new this.Settings();}
else{this.config[n]=settings;}
textarea.style.display="none";if(textarea.style.width){this.config[n].Width=textarea.style.width;}
if(textarea.style.height){this.config[n].Height=textarea.style.height}
var currentWidth=this.config[n].Width;var currentHeight=this.config[n].Height;var ifrmWidth="100%";var ifrmHeight="100%";if(currentWidth.search(/%/)==-1){ifrmWidth=currentWidth;ifrmHeight=currentHeight;}
var iframe='<table cellpadding="0" cellspacing="0" border="0" style="width:'+currentWidth+'; height:'+currentHeight+';" class="tableTextareaEditor"><tr><td valign="top">\n'
+'<iframe frameborder="0" id="wysiwyg'+n+'" class="iframeText" style="width:'+ifrmWidth+';height:'+ifrmHeight+';"></iframe>\n'
+'</td></tr></table>\n';textarea.insertAdjacentHTML("afterEnd",iframe);var content=textarea.value;var doc=this.getEditorWindow(n).document;if(this.config[n].ReplaceLineBreaks){content=content.replace(/(\r\n)|(\n)/ig,"<br>");}
doc.open();doc.write(content);doc.close();WYSIWYG_Core.setAttribute(doc.body,"style",this.config[n].DefaultStyle);},_generate:function(n,settings){var textarea=$(n);if(textarea==null){alert("No textarea found with the given identifier (ID: "+n+").");return;}
if(!WYSIWYG_Core.isBrowserCompatible()){if(this.config[n].NoValidBrowserMessage!=""){alert(this.config[n].NoValidBrowserMessage);}
return;}
textarea.style.display='none';if(textarea.style.width){this.config[n].Width=textarea.style.width;}
if(textarea.style.height){this.config[n].Height=textarea.style.height}
var currentWidth=this.config[n].Width;var currentHeight=this.config[n].Height;var toolbarWidth=currentWidth;var ifrmWidth="100%";var ifrmHeight="100%";if(currentWidth.search(/%/)==-1){toolbarWidth=currentWidth.replace(/px/gi,"");toolbarWidth=(parseFloat(toolbarWidth)+2)+"px";ifrmWidth=currentWidth;ifrmHeight=currentHeight;}
var editor="";editor+='<div id="wysiwyg_div_'+n+'" style="width:'+currentWidth+';">';editor+='<table border="0" cellpadding="0" cellspacing="0" class="tableTextareaEditor" id="wysiwyg_table_'+n+'" style="width:'+currentWidth+'; height:'+currentHeight+';">';editor+='<tr><td style="height:22px;vertical-align:top;">';for(var j=0;j<this.config[n].Toolbar.length;j++){if(this.config[n].Toolbar[j]&&this.config[n].Toolbar[j].length>0){var toolbar=this.config[n].Toolbar[j];editor+='<table border="0" cellpadding="0" cellspacing="0" class="toolbar1" style="width:100%;" id="toolbar'+j+'_'+n+'">';editor+='<tr><td style="width:6px;"><img src="'+this.config[n].ImagesDir+'seperator2.gif" alt="" hspace="3"></td>';for(var i=0;i<toolbar.length;i++){var id=toolbar[i];if(toolbar[i]){if(typeof(this.config[n].DropDowns[id])!="undefined"){var dropdown=this.config[n].DropDowns[id];editor+='<td style="width: '+dropdown.width+';">';editor+=this.writeDropDown(n,id);editor+='</td>';}
else{var buttonObj=this.ToolbarList[toolbar[i]];if(buttonObj){var buttonID=buttonObj[0];var buttonTitle=buttonObj[1];var buttonImage=this.config[n].ImagesDir+buttonObj[2];var buttonImageRollover=this.config[n].ImagesDir+buttonObj[3];if(toolbar[i]=="seperator"){editor+='<td style="width: 12px;" align="center">';editor+='<img src="'+buttonImage+'" border=0 unselectable="on" width="2" height="18" hspace="2" unselectable="on">';editor+='</td>';}
else if(toolbar[i]=="viewSource"){editor+='<td style="width: 22px;">';editor+='<span id="HTMLMode'+n+'"><img src="'+buttonImage+'" border="0" unselectable="on" title="'+buttonTitle+'" id="'+buttonID+'" class="buttonEditor" onmouseover="this.className=\'buttonEditorOver\'; this.src=\''+buttonImageRollover+'\';" onmouseout="this.className=\'buttonEditor\'; this.src=\''+buttonImage+'\';" onclick="WYSIWYG.execCommand(\''+n+'\', \''+buttonID+'\');" unselectable="on" width="20" height="20"></span>';editor+='<span id="textMode'+n+'"><img src="'+this.config[n].ImagesDir+'view_text.gif" border="0" unselectable="on" title="viewText" id="ViewText" class="buttonEditor" onmouseover="this.className=\'buttonEditorOver\'; this.src=\''+this.config[n].ImagesDir+'view_text_on.gif\';" onmouseout="this.className=\'buttonEditor\'; this.src=\''+this.config[n].ImagesDir+'view_text.gif\';" onclick="WYSIWYG.execCommand(\''+n+'\',\'ViewText\');" unselectable="on"  width="20" height="20"></span>';editor+='</td>';}
else{editor+='<td style="width: 22px;">';editor+='<img src="'+buttonImage+'" border=0 unselectable="on" title="'+buttonTitle+'" id="'+buttonID+'" class="buttonEditor" onmouseover="this.className=\'buttonEditorOver\'; this.src=\''+buttonImageRollover+'\';" onmouseout="this.className=\'buttonEditor\'; this.src=\''+buttonImage+'\';" onclick="WYSIWYG.execCommand(\''+n+'\', \''+buttonID+'\');" unselectable="on" width="20" height="20">';editor+='</td>';}}}}}
editor+='<td>&nbsp;</td></tr></table>';}}
editor+='</td></tr><tr><td valign="top">\n';editor+='<iframe frameborder="0" id="wysiwyg'+n+'" class="iframeText" style="width:100%;height:'+currentHeight+';"></iframe>\n'
+'</td></tr>';if(this.config[n].StatusBarEnabled){editor+='<tr><td class="wysiwyg-statusbar" style="height:10px;" id="wysiwyg_statusbar_'+n+'">&nbsp;</td></tr>';}
editor+='</table>';editor+='</div>';textarea.insertAdjacentHTML("afterEnd",editor);if($("textMode"+n)){$("textMode"+n).style.display='none';}
var content=textarea.value;var doc=this.getEditorWindow(n).document;if(this.config[n].ReplaceLineBreaks){content=content.replace(/\n\r|\n/ig,"<br>");}
doc.open();doc.write(content);doc.close();if(doc.body.contentEditable){doc.body.contentEditable=true;}
else{doc.designMode="on";}
WYSIWYG_Core.setAttribute(doc.body,"style",this.config[n].DefaultStyle);WYSIWYG_Table.refreshHighlighting(n);for(var idx=0;idx<document.forms.length;idx++){WYSIWYG_Core.addEvent(document.forms[idx],"submit",function xxx_aa(){WYSIWYG.updateTextArea(n);});}
WYSIWYG_Core.addEvent(doc,"mouseover",function xxx_bb(){WYSIWYG.closeDropDowns(n);});if(this.config[n].InvertIELineBreaks){WYSIWYG_Core.addEvent(doc,"keypress",function xxx_cc(){WYSIWYG.invertIELineBreakCapability(n);});}
if(this.config[n].StatusBarEnabled){WYSIWYG_Core.addEvent(doc,"mouseup",function xxx_dd(){WYSIWYG.updateStatusBar(n);});}
if(this.config[n].ContextMenu){WYSIWYG_ContextMenu.init(n);}
this.viewTextMode[n]=false;},disable:function(n){var editor=this.getEditorWindow(n);if(editor==null){alert("No editor found with the given identifier (ID: "+n+").");return;}
if(editor){if(editor.document.body.contentEditable){editor.document.body.contentEditable=false;}
else{editor.document.designMode="Off";}
WYSIWYG_Core.setAttribute(editor.document.body,"style",this.config[n].DisabledStyle);this.hideStatusBar(n);this.hideToolbars(n);}},enable:function(n){var editor=this.getEditorWindow(n);if(editor==null){alert("No editor found with the given identifier (ID: "+n+").");return;}
if(editor){if(editor.document.body.contentEditable){editor.document.body.contentEditable=true;}
else{editor.document.designMode="On";}
WYSIWYG_Core.setAttribute(editor.document.body,"style",this.config[n].DefaultStyle);this.showStatusBar(n);this.showToolbars(n);}},getNodeTree:function(n){var sel=this.getSelection(n);var range=this.getRange(sel);var tag=this.getTag(range);if(tag==null){return;}
var node=this.getParent(tag);var nodeTree=new Array(tag);var ii=1;while(node!=null&&node.nodeName!="#document"){nodeTree[ii]=node;node=this.getParent(node);ii++;}
return nodeTree;},removeNode:function(n){var sel=this.getSelection(n);var range=this.getRange(sel);var tag=this.getTag(range);var parent=tag.parentNode;if(tag==null||parent==null){return;}
if(tag.nodeName=="HTML"||tag.nodeName=="BODY"){return;}
var childNodes=new Array();for(var i=0;i<tag.childNodes.length;i++)
childNodes[i]=tag.childNodes[i];for(var i=0;i<childNodes.length;i++)
parent.insertBefore(childNodes[i],tag);parent.removeChild(tag);if(parent.nodeName=="A"&&!parent.hasChildNodes()){if(parent.parentNode){parent.parentNode.removeChild(parent);}}
this.updateStatusBar(n);},getSelection:function(n){var ifrm=this.getEditorWindow(n);var doc=ifrm.document;var sel=null;if(ifrm.getSelection){sel=ifrm.getSelection();}
else if(doc.getSelection){sel=doc.getSelection();}
else if(doc.selection){sel=doc.selection;}
return sel;},updateStatusBar:function(n){var nodeTree=this.getNodeTree(n);if(nodeTree==null){return;}
var outputTree="";var max=nodeTree.length-1;for(var i=max;i>=0;i--){if(nodeTree[i].nodeName!="HTML"&&nodeTree[i].nodeName!="BODY"){outputTree+='<a class="wysiwyg-statusbar" href="javascript:WYSIWYG.selectNode(\''+n+'\','+i+');">'+nodeTree[i].nodeName+'</a>';}
else{outputTree+=nodeTree[i].nodeName;}
if(i>0){outputTree+=" > ";}}
var statusbar=$("wysiwyg_statusbar_"+n);if(statusbar){statusbar.innerHTML=outputTree;}},execCommand:function(n,cmd,value){this.getEditorWindow(n).focus();var textModeCommands=new Array("ViewText","Print");var cmdValid=false;for(var i=0;i<textModeCommands.length;i++){if(textModeCommands[i]==cmd){cmdValid=true;}}
if(this.viewTextMode[n]&&!cmdValid){alert("You are in TEXT Mode. This feature has been disabled.");return;}
var toHexColor=WYSIWYG_Core.isMSIE?WYSIWYG_Core._dec_to_rgb:WYSIWYG_Core.toHexColor;var popupPosition={left:parseInt(window.screen.availWidth/3),top:parseInt(window.screen.availHeight/3)};var imagePopupFile=this.config[n].PopupsDir+'insert_image.html';var imagePopupWidth=400;var imagePopupHeight=210;if(typeof this.config[n].ImagePopupFile!="undefined"&&this.config[n].ImagePopupFile!=""){imagePopupFile=this.config[n].ImagePopupFile;}
if(typeof this.config[n].ImagePopupWidth&&this.config[n].ImagePopupWidth>0){imagePopupWidth=this.config[n].ImagePopupWidth;}
if(typeof this.config[n].ImagePopupHeight&&this.config[n].ImagePopupHeight>0){imagePopupHeight=this.config[n].ImagePopupHeight;}
switch(cmd){case"Maximize":this.maximize(n);break;case"FormatBlock":WYSIWYG_Core.execCommand(n,cmd,"<"+value+">");break;case"ForeColor":var rgb=this.getEditorWindow(n).document.queryCommandValue(cmd);var currentColor=rgb!=''?toHexColor(this.getEditorWindow(n).document.queryCommandValue(cmd)):"000000";window.open(this.config[n].PopupsDir+'select_color.html?color='+currentColor+'&command='+cmd+'&wysiwyg='+n,'popup','location=0,status=0,scrollbars=0,width=210,height=165,top='+popupPosition.top+',left='+popupPosition.left).focus();break;case"BackColor":var currentColor=toHexColor(this.getEditorWindow(n).document.queryCommandValue(cmd));window.open(this.config[n].PopupsDir+'select_color.html?color='+currentColor+'&command='+cmd+'&wysiwyg='+n,'popup','location=0,status=0,scrollbars=0,width=210,height=165,top='+popupPosition.top+',left='+popupPosition.left).focus();break;case"InsertImage":window.open(imagePopupFile+'?wysiwyg='+n,'popup','location=0,status=0,scrollbars=0,resizable=0,width='+imagePopupWidth+',height='+imagePopupHeight+',top='+popupPosition.top+',left='+popupPosition.left).focus();break;case"RemoveImage":this.removeImage(n);break;case"RemoveLink":this.removeLink(n);break;case"RemoveNode":this.removeNode(n);break;case"CreateLink":window.open(this.config[n].PopupsDir+'insert_hyperlink.html?wysiwyg='+n,'popup','location=0,status=0,scrollbars=0,resizable=0,width=350,height=160,top='+popupPosition.top+',left='+popupPosition.left).focus();break;case"InsertTable":window.open(this.config[n].PopupsDir+'create_table.html?wysiwyg='+n,'popup','location=0,status=0,scrollbars=0,resizable=0,width=500,height=260,top='+popupPosition.top+',left='+popupPosition.left).focus();break;case"ViewSource":this.viewSource(n);break;case"ViewText":this.viewText(n);break;case"Help":window.open(this.config[n].PopupsDir+'about.html?wysiwyg='+n,'popup','location=0,status=0,scrollbars=0,resizable=0,width=400,height=350,top='+popupPosition.top+',left='+popupPosition.left).focus();break;case"RemoveFormat":this.removeFormat(n);break;case"Preview":window.open(this.config[n].PopupsDir+'preview.html?wysiwyg='+n,'popup','location=0,status=0,scrollbars=1,resizable=1,width='+this.config[n].PreviewWidth+',height='+this.config[n].PreviewHeight+',top='+popupPosition.top+',left='+popupPosition.left).focus();break;case"Print":this.print(n);break;case"Save":WYSIWYG.updateTextArea(n);var form=WYSIWYG_Core.findParentNode("FORM",this.getEditor(n));if(form==null){alert("Can not submit the content, because no form element found.");return;}
form.submit();break;case"Return":location.replace(this.config[n].Opener);break;default:WYSIWYG_Core.execCommand(n,cmd,value);}
this.closeDropDowns(n);},maximize:function(n){var divElm=this.getEditorDiv(n);var tableElm=this.getEditorTable(n);var editor=this.getEditor(n);var setting=this.config[n];var size=WYSIWYG_Core.windowSize();size.width-=5;if(this.maximized[n]){WYSIWYG_Core.setAttribute(divElm,"style","position:static;z-index:9998;top:0px;left:0px;width:"+setting.Width+";height:100%;");WYSIWYG_Core.setAttribute(tableElm,"style","width:"+setting.Width+";height:"+setting.Height+";");WYSIWYG_Core.setAttribute(editor,"style","width:100%;height:"+setting.Height+";");this.maximized[n]=false;}
else{WYSIWYG_Core.setAttribute(divElm,"style","position:absolute;z-index:9998;top:0px;left:0px;width:"+size.width+"px;height:"+size.height+"px;");WYSIWYG_Core.setAttribute(tableElm,"style","width:100%;height:100%;");WYSIWYG_Core.setAttribute(editor,"style","width:100%;height:100%;");this.maximized[n]=true;}},insertHTML:function(html,n){if(WYSIWYG_Core.isMSIE){this.getEditorWindow(n).document.selection.createRange().pasteHTML(html);}
else{var span=this.getEditorWindow(n).document.createElement("span");span.innerHTML=html;this.insertNodeAtSelection(span,n);}},insertNodeAtSelection:function(insertNode,n){var doc=this.getEditorWindow(n).document;var sel=this.getSelection(n);var range=sel.getRangeAt(0);sel.removeAllRanges();range.deleteContents();var container=range.startContainer;var pos=range.startOffset;range=doc.createRange();if(container.nodeType==3&&insertNode.nodeType==3){container.insertData(pos,insertNode.data);range.setEnd(container,pos+insertNode.length);range.setStart(container,pos+insertNode.length);}
else{var afterNode;var beforeNode;if(container.nodeType==3){var textNode=container;container=textNode.parentNode;var text=textNode.nodeValue;var textBefore=text.substr(0,pos);var textAfter=text.substr(pos);beforeNode=document.createTextNode(textBefore);afterNode=document.createTextNode(textAfter);container.insertBefore(afterNode,textNode);container.insertBefore(insertNode,afterNode);container.insertBefore(beforeNode,insertNode);container.removeChild(textNode);}
else{afterNode=container.childNodes[pos];container.insertBefore(insertNode,afterNode);}
try{range.setEnd(afterNode,0);range.setStart(afterNode,0);}
catch(e){alert(e);}}
sel.addRange(range);},print:function(n){if(document.all&&navigator.appVersion.substring(22,23)==4){var doc=this.getEditorWindow(n).document;doc.focus();var OLECMDID_PRINT=6;var OLECMDEXECOPT_DONTPROMPTUSER=2;var OLECMDEXECOPT_PROMPTUSER=1;var WebBrowser='<object id="WebBrowser1" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';doc.body.insertAdjacentHTML('beforeEnd',WebBrowser);WebBrowser.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);WebBrowser.outerHTML='';}else{this.getEditorWindow(n).print();}},writeDropDown:function(n,id){var dropdown=this.config[n].DropDowns[id];var toolbarObj=this.ToolbarList[dropdown.id];var image=this.config[n].ImagesDir+toolbarObj[2];var imageOn=this.config[n].ImagesDir+toolbarObj[3];dropdown.elements.sort();var output="";output+='<table border="0" cellpadding="0" cellspacing="0"><tr>';output+='<td onMouseOver="$(\'img_'+dropdown.id+'_'+n+'\').src=\''+imageOn+'\';" onMouseOut="$(\'img_'+dropdown.id+'_'+n+'\').src=\''+image+'\';">';output+='<img src="'+image+'" id="img_'+dropdown.id+'_'+n+'" height="20" onClick="WYSIWYG.openDropDown(\''+n+'\',\''+dropdown.id+'\');" unselectable="on" border="0"><br>';output+='<span id="elm_'+dropdown.id+'_'+n+'" class="dropdown" style="width: 145px;display:none;">';for(var i=0;i<dropdown.elements.length;i++){if(dropdown.elements[i]){var value=dropdown.elements[i];var label=dropdown.label.replace(/{value}/gi,value);output+='<button type="button" onClick="WYSIWYG.execCommand(\''+n+'\',\''+dropdown.command+'\',\''+value+'\')\;" onMouseOver="this.className=\'mouseOver\'" onMouseOut="this.className=\'mouseOut\'" class="mouseOut" style="width: 120px;">';output+='<table cellpadding="0" cellspacing="0" border="0"><tr>';output+='<td align="left">'+label+'</td>';output+='</tr></table></button><br>';}}
output+='</span></td></tr></table>';return output;},closeDropDowns:function(n,exid){if(typeof(exid)=="undefined")exid="";var dropdowns=this.config[n].DropDowns;for(var id in dropdowns){var dropdown=dropdowns[id];if(dropdown.id!=exid){var divId="elm_"+dropdown.id+"_"+n;if($(divId))$(divId).style.display='none';}}},openDropDown:function(n,id){var divId="elm_"+id+"_"+n;if($(divId).style.display=="none"){$(divId).style.display="block";}
else{$(divId).style.display="none";}
$(divId).style.position="absolute";this.closeDropDowns(n,id);},viewSource:function(n){var doc=this.getEditorWindow(n).document;WYSIWYG_Table.disableHighlighting(n);if(WYSIWYG_Core.isMSIE){var iHTML=doc.body.innerHTML;iHTML=this.stripURLPath(n,iHTML);iHTML=WYSIWYG_Core.replaceRGBWithHexColor(iHTML);doc.body.innerText=iHTML;}
else{var html=WYSIWYG_Core.replaceRGBWithHexColor(doc.body.innerHTML);html=document.createTextNode(html);doc.body.innerHTML="";doc.body.appendChild(html);}
if($('HTMLMode'+n)){$('HTMLMode'+n).style.display='none';}
if($('textMode'+n)){$('textMode'+n).style.display='block';}
doc.body.style.fontSize="12px";doc.body.style.fontFamily="Courier New";this.viewTextMode[n]=true;},viewText:function(n){var doc=this.getEditorWindow(n).document;if(WYSIWYG_Core.isMSIE){var iText=doc.body.innerText;iText=this.stripURLPath(n,iText);iText=WYSIWYG_Core.replaceRGBWithHexColor(iText);doc.body.innerHTML=iText;}
else{var html=doc.body.ownerDocument.createRange();html.selectNodeContents(doc.body);html=WYSIWYG_Core.replaceRGBWithHexColor(html.toString());doc.body.innerHTML=html;}
WYSIWYG_Table.refreshHighlighting(n);if($('textMode'+n)){$('textMode'+n).style.display='none';}
if($('HTMLMode'+n)){$('HTMLMode'+n).style.display='block';}
WYSIWYG_Core.setAttribute(doc.body,"style",this.config[n].DefaultStyle);this.viewTextMode[n]=false;},stripURLPath:function(n,content,exact){if(typeof exact=="undefined"){exact=true;}
var stripImgageUrl=null;var stripAnchorUrl=null;if(this.config[n].AnchorPathToStrip=="auto"){stripAnchorUrl=WYSIWYG_Core.getDocumentUrl(document);}
else if(this.config[n].AnchorPathToStrip!=""){stripAnchorUrl=this.config[n].AnchorPathToStrip;}
if(this.config[n].ImagePathToStrip=="auto"){stripImgageUrl=WYSIWYG_Core.getDocumentUrl(document);}
else if(this.config[n].ImagePathToStrip!=""){stripImgageUrl=this.config[n].ImagePathToStrip;}
var url;var regex;var result;if(stripImgageUrl){url=WYSIWYG_Core.stringToRegex(WYSIWYG_Core.getDocumentPathOfUrl(stripImgageUrl));if(exact){regex=eval("/(src=\")("+url+")([^\"]*)/gi");content=content.replace(regex,"$1$3");}
else{regex=eval("/("+url+")(.+)/gi");content=content.replace(regex,"$2");}
result=WYSIWYG_Core.getDocumentPathOfUrl(stripImgageUrl).match(/.+[\/]{2,3}[^\/]*/,"");if(result){url=WYSIWYG_Core.stringToRegex(result[0]);if(exact){regex=eval("/(src=\")("+url+")([^\"]*)/gi");content=content.replace(regex,"$1$3");}
else{regex=eval("/("+url+")(.+)/gi");content=content.replace(regex,"$2");}}}
if(stripAnchorUrl){url=WYSIWYG_Core.stringToRegex(WYSIWYG_Core.getDocumentPathOfUrl(stripAnchorUrl));if(exact){regex=eval("/(href=\")("+url+")([^\"]*)/gi");content=content.replace(regex,"$1$3");}
else{regex=eval("/("+url+")(.+)/gi");content=content.replace(regex,"$2");}
result=WYSIWYG_Core.getDocumentPathOfUrl(stripAnchorUrl).match(/.+[\/]{2,3}[^\/]*/,"");if(result){url=WYSIWYG_Core.stringToRegex(result[0]);if(exact){regex=eval("/(href=\")("+url+")([^\"]*)/gi");content=content.replace(regex,"$1$3");}
else{regex=eval("/("+url+")(.+)/gi");content=content.replace(regex,"$2");}}
url=WYSIWYG_Core.stringToRegex(stripAnchorUrl);if(exact){regex=eval("/(href=\")("+url+")(#[^\"]*)/gi");content=content.replace(regex,"$1$3");}
else{regex=eval("/("+url+")(.+)/gi");content=content.replace(regex,"$2");}
url=WYSIWYG_Core.getDocumentUrl(document);var pos=url.lastIndexOf("/");if(pos!=-1){url=url.substring(pos+1,url.length);url=WYSIWYG_Core.stringToRegex(url);if(exact){regex=eval("/(href=\")("+url+")(#[^\"]*)/gi");content=content.replace(regex,"$1$3");}
else{regex=eval("/("+url+")(.+)/gi");content=content.replace(regex,"$2");}}}
return content;},updateTextArea:function(n){if(this.viewTextMode[n]){this.viewText(n);}
var content=this.getEditorWindow(n).document.body.innerHTML;content=this.stripURLPath(n,content);content=WYSIWYG_Core.replaceRGBWithHexColor(content);if(this.config[n].ReplaceLineBreaks){content=content.replace(/(\r\n)|(\n)/ig,"");}
$(n).value=content;},hideToolbars:function(n){for(var i=0;i<this.config[n].Toolbar.length;i++){var toolbar=$("toolbar"+i+"_"+n);if(toolbar){toolbar.style.display="none";}}},showToolbars:function(n){for(var i=0;i<this.config[n].Toolbar.length;i++){var toolbar=$("toolbar"+i+"_"+n);if(toolbar){toolbar.style.display="";}}},hideStatusBar:function(n){var statusbar=$('wysiwyg_statusbar_'+n);if(statusbar){statusbar.style.display="none";}},showStatusBar:function(n){var statusbar=$('wysiwyg_statusbar_'+n);if(statusbar){statusbar.style.display="";}},findParent:function(parentTagName,range){parentTagName=parentTagName.toUpperCase();var rangeWorking;var elmWorking=null;try{if(!WYSIWYG_Core.isMSIE){var node=range.startContainer;var pos=range.startOffset;if(node.nodeType!=3){node=node.childNodes[pos];}
return WYSIWYG_Core.findParentNode(parentTagName,node);}
else{elmWorking=(range.length>0)?range.item(0):range.parentElement();elmWorking=WYSIWYG_Core.findParentNode(parentTagName,elmWorking);if(elmWorking!=null)return elmWorking;rangeWorking=range.duplicate();rangeWorking.collapse(true);rangeWorking.moveEnd("character",1);if(rangeWorking.text.length>0){while(rangeWorking.compareEndPoints("EndToEnd",range)<0){rangeWorking.move("Character");if(null!=this.findParentTag(parentTagName,rangeWorking)){return this.findParentTag(parentTagName,rangeWorking);}}}
return null;}}
catch(e){return null;}},getTag:function(range){try{if(!WYSIWYG_Core.isMSIE){var node=range.startContainer;var pos=range.startOffset;if(node.nodeType!=3){node=node.childNodes[pos];}
if(node.nodeName&&node.nodeName.search(/#/)!=-1){return node.parentNode;}
return node;}
else{if(range.length>0){return range.item(0);}
else if(range.parentElement()){return range.parentElement();}}
return null;}
catch(e){return null;}},getParent:function(element){if(element.parentNode){return element.parentNode;}
return null;},getTextRange:function(element){var range=element.parentTextEdit.createTextRange();range.moveToElementText(element);return range;},invertIELineBreakCapability:function(n){var editor=this.getEditorWindow(n);var sel;if(editor.event.keyCode==13){if(!editor.event.shiftKey){sel=this.getRange(this.getSelection(n));sel.pasteHTML("<br>");editor.event.cancelBubble=true;editor.event.returnValue=false;sel.select();sel.moveEnd("character",1);sel.moveStart("character",1);sel.collapse(false);return false;}
else{sel=this.getRange(this.getSelection(n));sel.pasteHTML("<p>");editor.event.cancelBubble=true;editor.event.returnValue=false;sel.select();sel.moveEnd("character",1);sel.moveStart("character",1);sel.collapse(false);return false;}}},selectNode:function(n,level){var sel=this.getSelection(n);var range=this.getRange(sel);var parentnode=this.getTag(range);var i=0;for(var node=parentnode;(node&&(node.nodeType==1));node=node.parentNode){if(i==level){this.nodeSelection(n,node);}
i++;}
this.updateStatusBar(n);},nodeSelection:function(n,node){var doc=this.getEditorWindow(n).document;var sel=this.getSelection(n);var range=this.getRange(sel);if(!WYSIWYG_Core.isMSIE){if(node.nodeName=="BODY"){range.selectNodeContents(node);}else{range.selectNode(node);}
if(sel){sel.removeAllRanges();}
if(sel){sel.addRange(range);}}
else{if((node.nodeName=="TABLE")||(node.nodeName=="IMG")||(node.nodeName=="INPUT")||(node.nodeName=="SELECT")||(node.nodeName=="TEXTAREA")){try{range=doc.body.createControlRange();range.addElement(node);range.select();}
catch(e){}}
else{range=doc.body.createTextRange();if(range){range.collapse();if(range.moveToElementText){try{range.moveToElementText(node);range.select();}catch(e){try{range=doc.body.createTextRange();range.moveToElementText(node);range.select();}
catch(e){}}}else{try{range=doc.body.createTextRange();range.moveToElementText(node);range.select();}
catch(e){}}}}}}}
var WYSIWYG_Core={isMSIE:navigator.appName=="Microsoft Internet Explorer"?true:false,isFF:!document.all&&document.getElementById&&!this.isOpera,isOpera:navigator.appName=="Opera"?true:false,trim:function(str){return str.replace(/^\s*|\s*$/g,"");},defined:function(p){return typeof p=="undefined"?false:true;},isBrowserCompatible:function(){if((navigator.userAgent.indexOf('Safari')!=-1)||!document.getElementById||!document.designMode){return false;}
return true;},_setStyleAttribute:function(node,style){if(style==null)return;var styles=style.split(";");var pos;for(var i=0;i<styles.length;i++){var attributes=styles[i].split(":");if(attributes.length==2){try{var attr=WYSIWYG_Core.trim(attributes[0]);while((pos=attr.search(/-/))!=-1){var strBefore=attr.substring(0,pos);var strToUpperCase=attr.substring(pos+1,pos+2);var strAfter=attr.substring(pos+2,attr.length);attr=strBefore+strToUpperCase.toUpperCase()+strAfter;}
var value=WYSIWYG_Core.trim(attributes[1]).toLowerCase();node.style[attr]=value;}
catch(e){alert(e);}}}},_getStyleAttribute:function(node){if(this.isMSIE){return node.style['cssText'].toLowerCase();}
else{return node.getAttribute("style");}},setAttribute:function(node,attr,value){if(value==null||node==null||attr==null)return;if(attr.toLowerCase()=="style"){this._setStyleAttribute(node,value);}
else{node.setAttribute(attr,value);}},removeAttribute:function(node,attr){node.removeAttribute(attr,false);},getAttribute:function(node,attr){if(node==null||attr==null)return;if(attr.toLowerCase()=="style"){return this._getStyleAttribute(node);}
else{return node.getAttribute(attr);}},getDocumentPathOfUrl:function(url){var path=null;url=url.replace(/file:\/\//gi,"file:///");url=url.replace(/\\/gi,"\/");var pos=url.lastIndexOf("/");if(pos!=-1){path=url.substring(0,pos+1);}
return path;},getDocumentUrl:function(doc){var url=doc.URL;url=url.replace(/file:\/\//gi,"file:///");url=url.replace(/\\/gi,"\/");return url;},findParentNode:function(tagName,node){while(node.tagName!="HTML"){if(node.tagName==tagName){return node;}
node=node.parentNode;}
return null;},cancelEvent:function(e){if(!e)return false;if(this.isMSIE){e.returnValue=false;e.cancelBubble=true;}else{e.preventDefault();e.stopPropagation&&e.stopPropagation();}
return false;},toHexColor:function(color){color=color.replace(/^rgb/g,'');color=color.replace(/\(/g,'');color=color.replace(/\)/g,'');color=color.replace(/ /g,'');color=color.split(',');var r=parseFloat(color[0]).toString(16).toUpperCase();var g=parseFloat(color[1]).toString(16).toUpperCase();var b=parseFloat(color[2]).toString(16).toUpperCase();if(r.length<2){r='0'+r;}
if(g.length<2){g='0'+g;}
if(b.length<2){b='0'+b;}
return r+g+b;},_dec_to_rgb:function(value){var hex_string="";for(var hexpair=0;hexpair<3;hexpair++){var myByte=value&0xFF;value>>=8;var nybble2=myByte&0x0F;var nybble1=(myByte>>4)&0x0F;hex_string+=nybble1.toString(16);hex_string+=nybble2.toString(16);}
return hex_string.toUpperCase();},replaceRGBWithHexColor:function(str){if(str==null)return"";var matcher=str.match(/rgb\([0-9 ]+,[0-9 ]+,[0-9 ]+\)/gi);if(matcher){for(var j=0;j<matcher.length;j++){var regex=eval("/"+WYSIWYG_Core.stringToRegex(matcher[j])+"/gi");str=str.replace(regex,"#"+this.toHexColor(matcher[j]));}}
return str;},execCommand:function(n,cmd,value){if(typeof(value)=="undefined")value=null;if(cmd=='BackColor'&&WYSIWYG_Core.isFF)cmd='HiliteColor';if(WYSIWYG_Core.isFF&&(cmd=="Cut"||cmd=="Paste"||cmd=="Copy")){try{WYSIWYG.getEditorWindow(n).document.execCommand(cmd,false,value);}
catch(e){if(confirm("Copy/Cut/Paste is not available in Mozilla and Firefox\nDo you want more information about this issue?")){window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html');}}}
else{WYSIWYG.getEditorWindow(n).document.execCommand(cmd,false,value);}},stringToRegex:function(string){string=string.replace(/\//gi,"\\/");string=string.replace(/\(/gi,"\\(");string=string.replace(/\)/gi,"\\)");string=string.replace(/\[/gi,"\\[");string=string.replace(/\]/gi,"\\]");string=string.replace(/\+/gi,"\\+");string=string.replace(/\$/gi,"\\$");string=string.replace(/\*/gi,"\\*");string=string.replace(/\?/gi,"\\?");string=string.replace(/\^/gi,"\\^");string=string.replace(/\\b/gi,"\\\\b");string=string.replace(/\\B/gi,"\\\\B");string=string.replace(/\\d/gi,"\\\\d");string=string.replace(/\\B/gi,"\\\\B");string=string.replace(/\\D/gi,"\\\\D");string=string.replace(/\\f/gi,"\\\\f");string=string.replace(/\\n/gi,"\\\\n");string=string.replace(/\\r/gi,"\\\\r");string=string.replace(/\\t/gi,"\\\\t");string=string.replace(/\\v/gi,"\\\\v");string=string.replace(/\\s/gi,"\\\\s");string=string.replace(/\\S/gi,"\\\\S");string=string.replace(/\\w/gi,"\\\\w");string=string.replace(/\\W/gi,"\\\\W");return string;},addEvent:function(obj,ev,fu){if(obj.attachEvent)
obj.attachEvent("on"+ev,fu);else
obj.addEventListener(ev,fu,false);},removeEvent:function(obj,ev,fu){if(obj.attachEvent)
obj.detachEvent("on"+ev,fu);else
obj.removeEventListener(ev,fu,false);},includeJS:function(file){var script=document.createElement("script");this.setAttribute(script,"type","text/javascript");this.setAttribute(script,"src",file);var heads=document.getElementsByTagName("head");for(var i=0;i<heads.length;i++){heads[i].appendChild(script);}},includeCSS:function(path){var link=document.createElement("link");this.setAttribute(link,"rel","stylesheet");this.setAttribute(link,"type","text/css");this.setAttribute(link,"href",path);var heads=document.getElementsByTagName("head");for(var i=0;i<heads.length;i++){heads[i].appendChild(link);}},getElementPosition:function(elm1,elm2){var top=0,left=0;while(elm1&&elm1!=elm2){left+=elm1.offsetLeft;top+=elm1.offsetTop;elm1=elm1.offsetParent;}
return{left:left,top:top};},windowSize:function(){if(window.innerWidth){return{width:window.innerWidth,height:window.innerHeight};}
else if(document.body&&document.body.offsetWidth){return{width:document.body.offsetWidth,height:document.body.offsetHeight};}
else{return{width:0,height:0};}}}
var WYSIWYG_ContextMenu={html:"",contextMenuDiv:null,init:function(n){var doc=WYSIWYG.getEditorWindow(n).document;this.contextMenuDiv=document.createElement("div");this.contextMenuDiv.className="wysiwyg-context-menu-div";this.contextMenuDiv.setAttribute("class","wysiwyg-context-menu-div");this.contextMenuDiv.style.display="none";this.contextMenuDiv.style.position="absolute";this.contextMenuDiv.style.zIndex=9999;this.contextMenuDiv.style.left="0";this.contextMenuDiv.style.top="0";this.contextMenuDiv.unselectable="on";document.body.insertBefore(this.contextMenuDiv,document.body.firstChild);WYSIWYG_Core.addEvent(doc,"contextmenu",function context(e){WYSIWYG_ContextMenu.show(e,n);});WYSIWYG_Core.addEvent(doc,"click",function context(e){WYSIWYG_ContextMenu.close();});WYSIWYG_Core.addEvent(doc,"keydown",function context(e){WYSIWYG_ContextMenu.close();});WYSIWYG_Core.addEvent(document,"click",function context(e){WYSIWYG_ContextMenu.close();});},show:function(e,n){if(this.contextMenuDiv==null)return false;var ifrm=WYSIWYG.getEditor(n);var doc=WYSIWYG.getEditorWindow(n).document;var pos=WYSIWYG_Core.getElementPosition(ifrm);var x=WYSIWYG_Core.isMSIE?pos.left+e.clientX:pos.left+(e.pageX-doc.body.scrollLeft);var y=WYSIWYG_Core.isMSIE?pos.top+e.clientY:pos.top+(e.pageY-doc.body.scrollTop);this.contextMenuDiv.style.left=x+"px";this.contextMenuDiv.style.top=y+"px";this.contextMenuDiv.style.visibility="visible";this.contextMenuDiv.style.display="block";window.setTimeout("WYSIWYG_ContextMenu.output('"+n+"')",10);WYSIWYG_Core.cancelEvent(e);return false;},output:function(n){var sel=WYSIWYG.getSelection(n);var range=WYSIWYG.getRange(sel);var tag=WYSIWYG.getTag(range);if(tag==null){return;}
this.clear();var isImg=(tag.nodeName=="IMG")?true:false;var isLink=(tag.nodeName=="A")?true:false;var len=0;if(WYSIWYG_Core.isMSIE)
len=(document.selection&&range.text)?range.text.length:0;else
len=range.toString().length;var sel=len!=0||isImg;var iconLink={enabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["createlink"][3],disabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["createlink"][2]};var iconImage={enabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["insertimage"][3],disabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["insertimage"][2]};var iconDelete={enabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["delete"][3],disabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["delete"][2]};var iconCopy={enabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["copy"][3],disabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["copy"][2]};var iconCut={enabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["cut"][3],disabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["cut"][2]};var iconPaste={enabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["paste"][3],disabled:WYSIWYG.config[n].ImagesDir+WYSIWYG.ToolbarList["paste"][2]};this.html+='<table class="wysiwyg-context-menu" border="0" cellpadding="0" cellspacing="0">';this.addItem(n,'Copy',iconCopy,'Copy',sel);this.addItem(n,'Cut',iconCut,'Cut',sel);this.addItem(n,'Paste',iconPaste,'Paste',true);this.addSeperator();this.addItem(n,'InsertImage',iconImage,'Modify Image Properties...',isImg);this.addItem(n,'CreateLink',iconLink,'Create or Modify Link...',sel||isLink);this.addItem(n,'RemoveNode',iconDelete,'Remove',true);this.html+='</table>';this.contextMenuDiv.innerHTML=this.html;},close:function(){this.contextMenuDiv.style.visibility="hidden";this.contextMenuDiv.style.display="none";},clear:function(){this.contextMenuDiv.innerHTML="";this.html="";},addItem:function(n,cmd,icon,title,disabled){var item='';if(disabled){item+='<tr>';item+='<td class="icon"><a href="javascript:WYSIWYG.execCommand(\''+n+'\',\''+cmd+'\', null);"><img src="'+icon.enabled+'" border="0"></a></td>';item+='<td onmouseover="this.className=\'mouseover\'" onmouseout="this.className=\'\'" onclick="WYSIWYG.execCommand(\''+n+'\', \''+cmd+'\', null);WYSIWYG_ContextMenu.close();"><a href="javascript:void(0);">'+title+'</a></td>';item+='</tr>';}
else{item+='<tr>';item+='<td class="icon"><img src="'+icon.disabled+'" border="0"></td>';item+='<td onmouseover="this.className=\'mouseover\'" onmouseout="this.className=\'\'"><span class="disabled">'+title+'</span></td>';item+='</tr>';}
this.html+=item;},addSeperator:function(){var output='';output+='<tr>';output+='<td colspan="2" style="text-align:center;"><hr size="1" color="#C9C9C9" width="95%"></td>';output+='</tr>';this.html+=output;}}
var WYSIWYG_Table={create:function(n,tbl){var doc=WYSIWYG.getEditorWindow(n).document;var sel=WYSIWYG.getSelection(n);var range=WYSIWYG.getRange(sel);var table=null;if(WYSIWYG_Core.isMSIE){if(sel.type=="Control"&&range.length==1){range=WYSIWYG.getTextRange(range(0));range.select();}}
table=tbl;var rows=WYSIWYG_Core.getAttribute(tbl,"tmprows");var cols=WYSIWYG_Core.getAttribute(tbl,"tmpcols");WYSIWYG_Core.removeAttribute(tbl,"tmprows");WYSIWYG_Core.removeAttribute(tbl,"tmpcols");for(var i=0;i<rows;i++){var tr=doc.createElement("tr");for(var j=0;j<cols;j++){var td=createTD();tr.appendChild(td);}
table.appendChild(tr);}
if(WYSIWYG_Core.isMSIE){range.pasteHTML(table.outerHTML);}
else{WYSIWYG.insertNodeAtSelection(table,n);}
this.refreshHighlighting(n);function createTD(){var td=doc.createElement("td");td.innerHTML="&nbsp;";return td;}},refreshHighlighting:function(n){var doc=WYSIWYG.getEditorWindow(n).document;var tables=doc.getElementsByTagName("table");for(var i=0;i<tables.length;i++){this._enableHighlighting(tables[i]);}
var tds=doc.getElementsByTagName("td");for(var i=0;i<tds.length;i++){this._enableHighlighting(tds[i]);}},disableHighlighting:function(n){var doc=WYSIWYG.getEditorWindow(n).document;var tables=doc.getElementsByTagName("table");for(var i=0;i<tables.length;i++){this._disableHighlighting(tables[i]);}
var tds=doc.getElementsByTagName("td");for(var i=0;i<tds.length;i++){this._disableHighlighting(tds[i]);}},_enableHighlighting:function(node){var style=WYSIWYG_Core.getAttribute(node,"style");if(style==null)style=" ";WYSIWYG_Core.removeAttribute(node,"prevstyle");WYSIWYG_Core.setAttribute(node,"prevstyle",style);WYSIWYG_Core.setAttribute(node,"style","border:1px dashed #AAAAAA;");},_disableHighlighting:function(node){var style=WYSIWYG_Core.getAttribute(node,"prevstyle");if(style==null||style==""){this._enableHighlighting(node);return;}
WYSIWYG_Core.removeAttribute(node,"prevstyle");WYSIWYG_Core.removeAttribute(node,"style");WYSIWYG_Core.setAttribute(node,"style",style);}}
function $(id){return document.getElementById(id);}
if(typeof HTMLElement!="undefined"&&!HTMLElement.prototype.insertAdjacentElement){HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){switch(where){case'beforeBegin':this.parentNode.insertBefore(parsedNode,this);break;case'afterBegin':this.insertBefore(parsedNode,this.firstChild);break;case'beforeEnd':this.appendChild(parsedNode);break;case'afterEnd':if(this.nextSibling){this.parentNode.insertBefore(parsedNode,this.nextSibling);}
else{this.parentNode.appendChild(parsedNode);}
break;}};HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr){var r=this.ownerDocument.createRange();r.setStartBefore(this);var parsedHTML=r.createContextualFragment(htmlStr);this.insertAdjacentElement(where,parsedHTML);};HTMLElement.prototype.insertAdjacentText=function(where,txtStr){var parsedText=document.createTextNode(txtStr);this.insertAdjacentElement(where,parsedText);};}