
			wysiwygEditor={
				Firefox:(navigator.userAgent.toLowerCase().indexOf('gecko')!=-1),
				IE:(navigator.userAgent.toLowerCase().indexOf('msie')!=-1),
				currentId:1,
				_virtKeyboardWindow:false,
				_curVirtKeyboardParent:false,
				_previewWindow:false,
				_curPreviewParent:false,
				insertWysiwygInto:function(data){
					var id=this.currentId;
					this.currentId++;
					var thisObjName='wsgobj'+id;
					window[thisObjName]=new wsgClass(id,thisObjName,data);
					window[thisObjName].Show();
					return window[thisObjName];
				},
				popVirtKeyboard:function(parent){
					if (this._virtKeyboardWindow) {
						this.hideVirtKeyboard();
					};
					var url='/Api/Wysiwyg/wysiwygVirtualKeyboard/0,12970,,00.html';
					var props='toolbar=no,location=no,directories=no,top=0,';
					props+='left=440,status=yes,menubar=no,scrollbars=no,movable=yes,resizable=yes,';
					props+='width=342,height=160';
					this._virtKeyboardWindow=window.open(url,'wsgVirtKeyboardWindow',props)
					this._curVirtKeyboardParent=parent;
				},
				hideVirtKeyboard:function(){
					if (this._virtKeyboardWindow) {
						this._virtKeyboardWindow.close();
					};
					this._virtKeyboardWindow=false;
					this._curVirtKeyboardParent=false;
				},
				onVKAction:function(action,param){
					if (typeof(param)=='undefined') var param=false;
					if (this._curVirtKeyboardParent) {
						this._curVirtKeyboardParent.onVKAction(action,param);
					};
				},
				focusVirtKeyboard:function(){
					this._virtKeyboardWindow.focus();
				},
				popPreview:function(parent,width,height){
					if (this._previewWindow) {
						this.hidePreview();
					};
					var url='/Api/Wysiwyg/wysiwygPreviewPopup/1,12969,,00.html?PPSTAGE=3&WSGBRWSR='+this.getBrowserName();
					var props='toolbar=no,location=no,directories=no,top=0,';
					props+='left=440,status=yes,menubar=no,scrollbars=no,movable=yes,resizable=yes,';
					props+='width='+width+',height='+height;
					this._previewWindow=window.open(url,'wsgPopupPreviewWindow',props);
					this._curPreviewParent=parent;
				},
				hidePreview:function(){
					if (this._previewWindow) {
						this._previewWindow.close();
					};
					this._previewWindow=false;
					this._curPreviewParent=false;
				},
				loadPreviewRenderedContent:function(data){
					if (this._curPreviewParent) {
						this._curPreviewParent.loadPreviewRenderedContent(data);
					};
				},
				getPreviewTextAreaContent:function(){
					if (this._curPreviewParent) {
						var str=this._curPreviewParent.GetTextAreaContent();
						if (this._curPreviewParent.isAlt) str=str.replace(/\n/g,'<br/>');
						return str;
					};
				},
				getPreviewDivStyle:function(){
					if (this._curPreviewParent) {
						return this._curPreviewParent.bodyStyle;
					};
				},
				getBrowserName:function(){
					if (this.IE) {
						return 'IE';
					} else {
						return 'FF';
					};
				},
				disableInterface:function(){
					this._callWsgObjectsFunc('disableInterface');
					this._interfaceDisabled=true;
				},
				enableInterface:function(){
					this._callWsgObjectsFunc('enableInterface');
					this._interfaceDisabled=false;
				},
				isInterfaceDisabled:function(){
					return this._interfaceDisabled;
				},
				_callWsgObjectsFunc:function(funcName,data){
					if (typeof(data)=='undefined') var data=false;
					for(var i=1;i<this.currentId;i++) {
						var wsgObjName='wsgobj'+i;
						if ((typeof(window[wsgObjName])=='object')&&(typeof(window[wsgObjName][funcName])=='function')) {
							window[wsgObjName][funcName](data);
						};
					};
				}
			};
			function wsgClass(id,thisObjName,data) {
				this.width=380;
				this.height=200;
				this.altStyle='font-family:arial;font-size:12px;color:black;direction:rtl;text-align:right;background:#FFFFFF;'
				this.bodyStyle='margin:2;font-family:arial;font-size:12px;color:black;direction:rtl;text-align:right;background:#FFFFFF;';
				this.toolsPanelStyle='direction:ltr;text-align:left;background:#D9E2EB;overflow:visible';
				this.frameBorder='1px solid #ACAFB6';
				this.toolbarButtons={
					'VirtualKeyboard':"<img alt='מקלדת וירטואלית' src='/images/stlkri_vkeyboard.gif'>",
					'Bold':"<img alt='הדגשה' src='/images/stlkri_bold.gif'><div style='height:6px;overflow:hidden;'>&#160;</div>",
					'Italic':"<img alt='הטיית טקסט' src='/images/stlkri_italics.gif'><div style='height:6px;overflow:hidden;'>&#160;</div>",
					'Underline':"<img alt='קו תחתון' src='/images/stlkri_underline.gif'><div style='height:6px;overflow:hidden;'>&#160;</div>",
					'JustifyLeft':"<img alt='יישור לשמאל' src='/images/stlkri_aleft.gif'><div style='height:6px;overflow:hidden;'>&#160;</div>",
					'JustifyRight':"<img alt='יישור לימין' src='/images/stlkri_aright.gif'><div style='height:6px;overflow:hidden;'>&#160;</div>",
					'CreateLink':"<img alt='קישור טקסט' src='/images/stlkri_link.gif'><div style='height:6px;overflow:hidden;'>&#160;</div>",
					'Unlink':"<img alt='הסרת קישור' src='/images/stlkri_unlink.gif'><div style='height:6px;overflow:hidden;'>&#160;</div>",
					'|':'&#1514;&#1493;&#1499;&#1503;'
				};
				this.altToolbarButtons={
					'VirtualKeyboard':"<img alt='מקלדת וירטואלית' src='/images/stlkri_vkeyboard.gif'>",
					'||':'&#1514;&#1493;&#1499;&#1503;'
				};
				this.content='';
				for(var k in data) {
					this[k]=data[k];
				};
				this.id=id;
				this.thisObjName=thisObjName;
				this.iframeHeight=this.height-35;
				this._interfaceDisabled=false;
				this._maxTlButtonI=false;
			};
			wsgClass.prototype={
				enableInterface:function(){
					this._interfaceDisabled=false;
					this._changeButtonCursors('pointer');
				},
				disableInterface:function(){
					this._interfaceDisabled=true;
					this._changeButtonCursors('default');
				},
				_changeButtonCursors:function(tp){
					if (this._maxTlButtonI===false) return;
					for(var i=0;i<=this._maxTlButtonI;i++){
						var btid='wsg'+this.id+'tlbutton'+i;
						if (document.getElementById(btid)) {
							document.getElementById(btid).style.cursor=tp;
						};
					};
				},
				popPreviewWindow:function(width,height){
					if (this._interfaceDisabled) return;
					wysiwygEditor.popPreview(this,width,height);
				},
				GetTextAreaContent:function(){
					this.RefreshTextAreaContent();
					return document.getElementById('wysiwygTA'+this.id).value;
				},
				loadPreviewRenderedContent:function(data){
					this.loadPreivewRenderedContentCallback(data);
				},
				RefreshTextAreaContent:function(){
					if (!this.isAlt) {
						this._getHTML();
					};
				},
				getHtmlFreeContent:function(){
					if (this.isAlt) {
						return document.getElementById('wysiwygTA'+this.id).value;
					} else {
						var iDoc=this._getIDoc();
						return iDoc.body.innerText;
					};
				},
				Show:function() {
					if (this._interfaceDisabled) return;
					var insElt=document.getElementById(this.InsertIntoElement);
					this.isAlt=(!wysiwygEditor.IE);
					if (this.isAlt) {
						this.toolbarButtons=this.altToolbarButtons;
					};
					if (insElt) {
						insElt.innerHTML=[
							"<div id='wysiwygMainDiv"+this.id+"' style='width:"+this.width+"px;'>",
								"<div id='wysiwygToolBar"+this.id+"' style='"+this.toolsPanelStyle+"width:"+(parseInt(this.width)+2)+"px;'>",
									this._ShowButtons(this.toolbarButtons),
								"</div>",
								this._ShowIframe(),
								this._ShowTextarea(),
							"</div>"
						].join('');
						this._InitializeIframe();
					};
				},
				_ShowButtons:function(buttons){
					var ans='<table><tr>';
					var i=-1;
					for(var buttonName in buttons) {
						i++;
						var button=buttons[buttonName];
						if (buttonName.substring(0,1)=='|') {
							if (buttonName.substring(1,2)=='|') {
								var wdth=297;
							} else {
								var wdth=80;
							};
							ans+="<td style='cursor:default;font-weight:bold;color:black;font-size:12px;font-family:arial;' width='"+wdth+"' align='right'>"+button+"</td>";
						} else {
							if (buttonName=='Unlink') buttonName='RemoveLink';
							switch (buttonName) {
								case 'VirtualKeyboard':
									//ans+= "<button type='button' class='editorButtons' style='height:30px;width:60px;' onClick='"+this.thisObjName+".onClickBtnOpenKeyBoardInsertWindow();'>"+button+"</button>";		
									ans+="<td><button id='wsg"+this.id+"tlbutton"+i+"' title='מקלדת וירטואלית' onClick='"+this.thisObjName+".onClickBtnOpenKeyBoardInsertWindow();return false;' style='cursor:pointer;width:60px;border:0;background:none;'>"+button+"</button></td><td width='2'></td>";
									break;
								default:
									if (i>1) {
										ans+="<td style='color:#a1a6ac;'>&#160;|&#160;</td>";
									};
									ans+="<td><div style='height:5px;overflow:hidden;'>&#160;</div><button id='wsg"+this.id+"tlbutton"+i+"' onClick='"+this.thisObjName+".onClickBtn"+buttonName+"();' style='cursor:pointer;border:0;background:none;'>"+button+"</button></td>";
									break;
							};
						};
					};
					this._maxTlButtonI=i;
					ans+='</tr></table>';
					return ans;
				},
				_ShowIframe:function(){
					if (this.isAlt) {
						return [
							"<div id='wysiwygAltDiv"+this.id+"'>",
								"<textarea name='"+this.name+"' tabIndex='1' id='wysiwygTA"+this.id+"' style='"+this.altStyle+"width:"+this.width+"px;height:"+this.iframeHeight+"px;border:"+this.frameBorder+"'>",
									this.content,
								"</textarea>",
							"</div>"
						].join('');
					} else {
						return [
							"<iframe id='wysiwygIframe"+this.id+"' src='#' width='"+this.width+"' height='"+this.iframeHeight+"' frameborder='0' tabindex='1' style='border:"+this.frameBorder+";'>",
							"</iframe>"
						].join('');
					};
				},
				_ShowTextarea:function() {
					if (!this.isAlt) {
						return [
							"<div id='wysiwygETA"+this.id+"'>",
								"<textarea id='wysiwygTA"+this.id+"' name='"+this.name+"' style='display:none;'>",
								"</textarea>",
							"</div>"
						].join('');
					} else {
						return '';
					};
				},
				_InitializeIframe:function(){
					if (!this.isAlt) {
						var iHTML=[
							"<html>",
								"<head>",
									"<style>",
										"html,body {overflow:auto;} ",
										"p {",
											"padding:0px;",
											"margin:0px;",
										"}",
									"</style>",
								"</head>",
								"<body style='"+this.bodyStyle+"'>",
									''+this.content,
								"</body>",
							"</html>"
						].join('');
						var iDoc=this._getIDoc();
						iDoc.open();
						iDoc.write(iHTML);
						iDoc.close();
						iDoc.designMode='On';
					};
				},
				
				onClickBtnUnderline:function(){
					if (this._interfaceDisabled) return;
					var iWin=this._getIWin();iWin.focus();
					iWin.document.execCommand('Underline',null,'');
				},
				onClickBtnJustifyLeft:function(){
					if (this._interfaceDisabled) return;
					var iWin=this._getIWin();iWin.focus();
					iWin.document.execCommand('JustifyLeft',null,'');
				},
				onClickBtnJustifyRight:function(){
					if (this._interfaceDisabled) return;
					var iWin=this._getIWin();iWin.focus();
					iWin.document.execCommand('JustifyRight',null,'');
				},
				onClickBtnBold:function(){
					if (this._interfaceDisabled) return;
					var iWin=this._getIWin();iWin.focus();
					iWin.document.execCommand('Bold',null,'');
				},
				onClickBtnItalic:function(){
					if (this._interfaceDisabled) return;
					var iWin=this._getIWin();iWin.focus();
					iWin.document.execCommand('Italic',null,'');
				},
				onClickBtnCodeMode:function(){
					if (this._interfaceDisabled) return;
					this.getHTML(id);
					document.getElementById(id).style.display='none';
					document.getElementById('wysiwygTA'+this.id).style.display='';
				},
				onClickBtnDesignMode:function() {},
				onClickBtnCreateLink:function() {
					if (this._interfaceDisabled) return;
					this._openLinkInsertWindow();
				},
				onClickBtnRemoveLink:function() {
					if (this._interfaceDisabled) return;
					var iWin=this._getIWin();
					iWin.focus();
					iWin.document.execCommand('Unlink',false, '');
				},
				onClickBtnInsertImage:function() {},
				onVKAction:function(action,param) {
					switch(action){
						case 'insert':
							this._insertSymbol(param);
							break;
						case 'delete':
							this._deleteSymbol();
							break;
					};
				},
				onClickBtnOpenKeyBoardInsertWindow:function() {
					if (!this._interfaceDisabled) wysiwygEditor.popVirtKeyboard(this);
					return;
				},
				updateTabIndex:function(tabindex) {
					if (this.isAlt) {
						document.getElementById('wysiwygTA'+this.id).tabIndex=tabindex;
					} else {
						document.getElementById('wysiwygIframe'+this.id).tabIndex=tabindex;
					};
				},
				getValue:function(){
					this.RefreshTextAreaContent();
					return document.getElementById('wysiwygTA'+this.id).value;
				},
			
				_focusIframe:function(){
					if (this.isAlt) {
						document.getElementById('wysiwygTA'+this.id).focus();
					} else {
						var iWin=this._getIWin();
						iWin.focus();
					};
				},
				
				
				
				_getHTML:function() {
					var iDoc=this._getIDoc();
					var html=iDoc.createTextNode(iDoc.body.innerHTML);
					document.getElementById('wysiwygTA'+this.id).value=html.data;
				},
				_openLinkInsertWindow:function(){
					var iWin=this._getIWin();
					var iDoc=this._getIDoc();
					iWin.focus();
					var selrange=iDoc.selection.createRange();
					if (selrange.text.length==0) {
						alert('עליך לבחור טקסט שיקושר');
					} else {
						if (!document.getElementById('wysiwygLinkWind'+this.id)) {
							var linkWindow=this._createNewElement('wysiwygLinkWind'+this.id,'div');
							linkWindow.style.position='relative';
							linkWindow.style.width='382px';
							linkWindow.style.height='60px';
							linkWindow.style.background='#F3F3F3';
							linkWindow.style.top='0px';
							document.getElementById('wysiwygToolBar'+this.id).appendChild(linkWindow);
							linkWindow.innerHTML=[
								"<div dir='rtl' align='right' style='width:382px;'>",
									"<div style='padding-top:3px;padding-bottom:3px;padding-right:5px;background-color:#f3f3f3;'>",
										"<div class='text12b' style='color:black;'>",
											"הזן את הקישור הרצוי:",
										"</div>",
										"<div style='width:97%;'>",
											"<div>",
												"<input id='wysiwygLinkInput"+this.id+"' dir='ltr' type='text' style='border:1px solid #C2C2C0;width:100%;' value='http://'/>",
											"</div>",
											"<div align='left'>",
												"<table cellspacing='0' cellpadding='0'><tr>",
													"<td><img style='cursor:pointer;' id='wysiwygButtonForInputLink"+this.id+"' src='/images/stlkrlinkok.gif'/></td>",
													"<td width='10'></td>",
													"<td><img style='cursor:pointer;' id='wysiwygButtonCloseForInputLink"+this.id+"' src='/images/stlkrlinkcancel.gif'/></td>",
												"</tr></table>",
											"</div>",
										"</div>",
									"</div>",
								"</div>"
							].join('');
						} else {
							document.getElementById('wysiwygLinkWind'+this.id).style.display='block';
						};
						var _this=this;
						document.getElementById('wysiwygLinkInput'+this.id).focus();
						document.getElementById('wysiwygButtonForInputLink'+_this.id).onclick=function() {
							var ot=document.getElementById('wysiwygLinkInput'+_this.id).value;
							var urlregexp=new RegExp('^(http(s?)://[a-z0-9\\-.]+([/?]\\S*)?)?$');
							if (ot!='http://') {
								if (urlregexp.test(ot)) {
									iWin.focus();
									if (iDoc.selection.type=='None') selrange.select();
									iWin.document.execCommand('CreateLink',false,ot);
									document.getElementById('wysiwygLinkWind'+_this.id).style.display='none';
									document.getElementById(_this.InsertIntoElement).parentElement.scrollTop=0;
								} else {
									alert('הכתובת שהוקלדה אינה תקנית');
								};
							};
						};
						document.getElementById('wysiwygButtonCloseForInputLink'+_this.id).onclick=function() {
							if (iDoc.selection.type=='None') selrange.select();
							document.getElementById('wysiwygLinkWind'+_this.id).style.display='none';
							document.getElementById(_this.InsertIntoElement).parentElement.scrollTop=0;
							document.getElementById('wysiwygLinkInput'+_this.id).value='http://';
						};
					};
				},
				_getIFrame:function(){
					return (wysiwygEditor.Firefox)?document.getElementById('wysiwygIframe'+this.id):frames['wysiwygIframe'+this.id];
				},
				_getIDoc:function(){
					return (wysiwygEditor.Firefox)?this._getIFrame().contentDocument:this._getIFrame().document;
				},
				_getIWin:function(){
					return (wysiwygEditor.Firefox)?this._getIFrame().contentWindow:this._getIFrame().window;
				},
				_removeElement:function(el) {
					el.parentNode.removeChild(el);
				},
				_createNewElement:function(eltId,el) {
					var element=document.createElement(el);
					element.id=eltId;
					return element;
				},
				_deleteSymbol:function(){
					if (this.isAlt) {
						var taelt=document.getElementById('wysiwygTA'+this.id);
						if ((typeof(taelt.selectionStart)!='undefined')&&(typeof(taelt.selectionEnd)!='undefined')) {
							var selstart=taelt.selectionStart;var selend=taelt.selectionEnd;
							if (selstart==selend) {
								if (selstart>0) {
									selstart=selstart-1;
								} else if (selend>0) {
									selend=selend+1;
								};
							};
							var before=taelt.value.substring(0,selstart);
							var after=taelt.value.substring(selend,taelt.value.length);
							taelt.value=before+after;
							taelt.selectionStart=selstart;
							taelt.selectionEnd=selstart;
						} else {
							taelt.value+=ot;
						};
					} else {
						var iDoc=this._getIDoc();
						var p=iDoc.body.createTextRange();
						p.moveStart('textedit');
						p.moveStart('character',-1);
						p.text='';
					};
				},
				_insertSymbol:function(ot){
					if (this.isAlt) {
						var taelt=document.getElementById('wysiwygTA'+this.id);
						if ((typeof(taelt.selectionStart)!='undefined')&&(typeof(taelt.selectionEnd)!='undefined')) {
							var selstart=taelt.selectionStart;var selend=taelt.selectionEnd;
							var before=taelt.value.substring(0,selstart);
							var after=taelt.value.substring(selend,taelt.value.length);
							taelt.value=before+ot+after;
							taelt.selectionStart=selstart+ot.length;
							taelt.selectionEnd=selstart+ot.length;
						} else {
							taelt.value+=ot;
						};
					} else {
						var iDoc=this._getIDoc();
						var p=iDoc.body.createTextRange();
						p.moveStart('textedit');
						p.text=ot;
					};
				},
				_setColor:function(color) {
					var iWin=this._getIWin();
					iWin.focus(); 
					iWin.document.execCommand('ForeColor',false,color);
				}
				
			};
		
