	function ReplaceAll(str)
	{
		for(i=0;i<str.length;i++)
		{
			str = str.replace('\"','\'');
		}
		return str;
	}
	function passData(str)
	{
		var Range=WebEditor.document.selection.createRange();
		//WebEditor.document.execCommand("ForeColor",false,"#F0F0F0");
		//Range.pasteHTML(ReplaceAll(strImg));
		Range.pasteHTML(str);
	}
	
	function EditorValidateMode()
	{
		if (document.frm.BT_EditHTML.checked)
		{
			alert("Please uncheck the \"Edit HTML\" checkbox to use the toolbars.");
			return false;
		}
		return true;	
	}
	
	function EnableWebEditor()
	{	
		//WebEditor.document.execCommand("ForeColor",true,"#F0F0F0");

		WebEditor.contentEditable=true;
		WebEditor.FontNameList=new Array("","Arial","Courier New","Courier","Helvetica","Times New Roman","Times","MS sans-serif","MS serif","mono","Georgia","Geneva","Verdana");
		
	}
	
	function SL_FontSize_OnChange() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			if(document.frm.SL_FontSize.value=="")
			{
				alert("Please choose a font size!");
				return false;
			}
			WebEditor.focus();
			WebEditor.document.execCommand("FontSize",false,document.frm.SL_FontSize.value);
		}
	}

	function SL_FontName_OnChange() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			if(document.frm.SL_FontName.value=="")
			{
				//alert("Please choose a font name!");
				//return false;
			}
			WebEditor.focus();
			WebEditor.document.execCommand("FontName",false,document.frm.SL_FontName.value);
		}
	}

	function BT_FontColor_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			var BrdColor=window.showModalDialog("Popup_ChooseColor.htm","","dialogHeight:140px;dialogWidth:303px;help:off;status:no");
			WebEditor.focus();
			if(BrdColor!="")WebEditor.document.execCommand("ForeColor",false,BrdColor);
		}
	}

	function BT_Bold_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			WebEditor.focus();
			WebEditor.document.execCommand("Bold");
			document.frm.BT_Bold.style.borderStyle=document.frm.BT_Bold.style.borderStyle=="inset"?"outset":"inset";
		}
	}

	function BT_Italic_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			WebEditor.focus();
			WebEditor.document.execCommand("Italic");
			document.frm.BT_Italic.style.borderStyle=document.frm.BT_Italic.style.borderStyle=="inset"?"outset":"inset";
		}
	}

	function BT_Underline_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			WebEditor.focus();
			WebEditor.document.execCommand("Underline");
			document.frm.BT_Underline.style.borderStyle=document.frm.BT_Underline.style.borderStyle=="inset"?"outset":"inset";
		}
	}

	function BT_JustifyLeft_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			WebEditor.focus();
			WebEditor.document.execCommand("JustifyLeft");
			document.frm.BT_JustifyRight.style.borderStyle="outset";
			document.frm.BT_JustifyCenter.style.borderStyle="outset";
			document.frm.BT_JustifyLeft.style.borderStyle="inset";
		}
	}

	function BT_JustifyCenter_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			WebEditor.focus();
			WebEditor.document.execCommand("JustifyCenter");
			document.frm.BT_JustifyLeft.style.borderStyle="outset";
			document.frm.BT_JustifyRight.style.borderStyle="outset";
			document.frm.BT_JustifyCenter.style.borderStyle="inset";
		}
	}

	function BT_JustifyRight_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			WebEditor.focus();
			WebEditor.document.execCommand("JustifyRight");
			document.frm.BT_JustifyLeft.style.borderStyle="outset";
			document.frm.BT_JustifyCenter.style.borderStyle="outset";
			document.frm.BT_JustifyRight.style.borderStyle="inset";
		}
	}

	function BT_InsertImage_onclick(CKey,CLanguage) 
	{
		WebEditor.focus();
		if(EditorValidateMode())
		{
			WebEditor.focus();   
			var insertimage = window.open("popup_process_image.php?CKey="+CKey+"&CLanguage="+CLanguage,"insertimage", "screenY='0',top='50',screenX='0',left='50',width=700,height=250,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,help=off,status=no");					
			insertimage.focus();   
		}
	}

	function BT_ListBu_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			WebEditor.focus();
			WebEditor.document.execCommand("InsertUnorderedList");
			document.frm.BT_ListBu.style.borderStyle="inset";
			document.frm.BT_ListNu.style.borderStyle="outset";
		}
	}

	function BT_ListNu_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			WebEditor.focus();
			WebEditor.document.execCommand("InsertOrderedList");
			document.frm.BT_ListBu.style.borderStyle="outset";
			document.frm.BT_ListNu.style.borderStyle="inset";
		}
	}

	function BT_HyperLink_onclick() 
	{
		if(WebEditor.document.selection.type!="Control")
		{
			WebEditor.focus();
			WebEditor.document.execCommand("CreateLink",true);
		}
	}
	
	function BT_EditHTML_onclick() 
	{
		if(document.frm.BT_EditHTML.checked)
		{
			WebEditor.innerText=WebEditor.innerHTML;
			
		}
		else
		{
			WebEditor.innerHTML=WebEditor.innerText;
		}
	}

	function DIV_OnClick()
	{
		if(WebEditor.document.selection.type=="Text")
		{
			//WebEditor.document.execCommand("ForeColor",false,"#F0F0F0");
			var ParentObj=WebEditor.document.selection.createRange().parentElement();

			document.frm.BT_Bold.style.borderStyle="outset";
			document.frm.BT_Italic.style.borderStyle="outset";
			document.frm.BT_Underline.style.borderStyle="outset";
			document.frm.BT_ListBu.style.borderStyle="outset";
			document.frm.BT_ListNu.style.borderStyle="outset";
			document.frm.SL_FontName.selectedIndex=0;
			WebEditor.FontNameUpdated=0;
			document.frm.SL_FontSize.selectedIndex=0;
			WebEditor.FontSizeUpdated=0;
			document.frm.BT_JustifyCenter.style.borderStyle="outset";
			document.frm.BT_JustifyRight.style.borderStyle="outset";
			document.frm.BT_JustifyLeft.style.borderStyle="inset";
			
			while(ParentObj.tagName!="DIV")
			{
				switch(ParentObj.tagName)
				{
				case "STRONG":
					document.frm.BT_Bold.style.borderStyle="inset";
					break;
				case "EM":
					document.frm.BT_Italic.style.borderStyle="inset";
					break;
				case "U":
					document.frm.BT_Underline.style.borderStyle="inset";
					break;
				case "P":
					switch(ParentObj.align)
					{
						case "left":
							break;
						case "center":
							document.frm.BT_JustifyLeft.style.borderStyle="outset";
							document.frm.BT_JustifyCenter.style.borderStyle="inset";
							document.frm.BT_JustifyRight.style.borderStyle="outset";
							break;
						case "right":
							document.frm.BT_JustifyLeft.style.borderStyle="outset";
							document.frm.BT_JustifyCenter.style.borderStyle="outset";
							document.frm.BT_JustifyRight.style.borderStyle="inset";
							break;
					}
					break;
				case "UL":
					document.frm.BT_ListBu.style.borderStyle="inset";
					document.frm.BT_ListNu.style.borderStyle="outset";
					break;
				case "OL":
					document.frm.BT_ListBu.style.borderStyle="outset";
					document.frm.BT_ListNu.style.borderStyle="inset";
					break;
				case "FONT":
					i=0;
					while(WebEditor.FontNameList[i]!=ParentObj.face && i<12)i++;
					if(i%12>0 && WebEditor.FontNameUpdated==0)
					{
						document.frm.SL_FontName.selectedIndex=i%12;
						WebEditor.FontNameUpdated=1;
					}

					if(ParentObj.size!="" && WebEditor.FontSizeUpdated==0)
					{
						document.frm.SL_FontSize.selectedIndex=parseInt(ParentObj.size);
						WebEditor.FontSizeUpdated=1;
					}
					break;
				}
				ParentObj=ParentObj.parentNode;
			}
		}
		else
		{
		}
	}