		var sourceText= '';
		var imgStatusBold = 'No';
		var imgStatusItalic = 'No';
		var imgStatusUnderLine = 'No';
		var imgStatusLeft = 'No';
		var imgStatusCenter = 'No';
		var imgStatusRight = 'No';
		var imgStatusRemoveF= 'No';
		var imgStatusWCount = 'No';
		var imgStatusInsertL = 'No';

		function ChangeFont(editorId)
		{
			// Get the Iframe Id.
			var finalid = editorId + '_content';
			
			document.frames[finalid].focus();
					
			var fontSize = document.getElementById('FontDropDownonchange');
			
			// Change the font size.
			document.frames[finalid].document.execCommand('FontSize',0,fontSize.options[fontSize.selectedIndex].value);
			
			// Set the focus back to the Text Editor.
			document.frames[finalid].focus();
		}
		
		function AlignLeft(leftover,left,editorId)
		{
			var img = document.getElementById('leftAlign')
			var imgLeft = "Images/" + leftover
			var imgNotLeft = "Images/" + left
			
			// Change the icon of the left Align to "Over"
			img.src = imgLeft;
			
				// Check if Center icon was clicked before
				if(imgStatusCenter == 'Yes')
				{
					// reset the variable
					imgStatusCenter = 'No';
					
					// Change the Center alignment icon to the previous
					document.getElementById('centerAlign').src = "Images/justifyfull.gif";
				}
				
				// Check if right icon was clicked before
				if(imgStatusRight == 'Yes')
				{
					// reset the variable
					imgStatusRight = 'No';
					
					// Change the right alignment icon to the previous
					document.getElementById('rightAlign').src = "Images/justifyright.gif";
				}
			
			// Check if the left alignment icon was clicked b4
			if(imgStatusLeft == 'Yes')
			{
			 // Reset the variable
			 imgStatusLeft='No';
			 
			 // change the image to regular icon
			 img.src = "Images/" + left;
			}
			else
			{
			// change the image to the "over"
			imgStatusLeft= 'Yes'
			}
			
			// Apply the Left Aligment
			var finalid = editorId + '_content';
			
			// Set the focus back to the editor
			document.frames[finalid].focus();
			
			document.frames[finalid].document.execCommand('JustifyLeft',false,null);
			
			// Set the focus back to the editor
			document.frames[finalid].focus();
		}
		
		function AlignCenter(centerover,center,editorId)
		{
			var img = document.getElementById('centerAlign')
			
			// Save the center over address into a variable
			var imgCenter = "Images/" + centerover
			
			// Save the center address into a variable
			var imgNotCenter = "Images/" + center
			
			// Set the icon source to the over one
			img.src = imgCenter;
			
			// Check if the left alignment is clicked
			if(imgStatusLeft == 'Yes')
				{
				
					// Set the variable to false
					imgStatusLeft = 'No';
					
					// Change the icon to the left alignment
					document.getElementById('leftAlign').src = "Images/justifyleft.gif";
				}
			// Check if the Right Alignment is clicked	
			if(imgStatusRight == 'Yes')
				{
					// Set the variable to false
					imgStatusCenter = 'No';
					
					// Change the icon to the right alignment
					document.getElementById('rightAlign').src = "Images/justifyright.gif";
				}
			
			// Check if the center alignment is clicked
			if(imgStatusCenter == 'Yes')
			{
			
			 // Set the variable to false
			 imgStatusCenter='No';
			 
			 // Change the icon source to center
			 img.src = "Images/" + center;
			}
			else
			{
			
			// Change the icon source to center over
			imgStatusCenter= 'Yes'
			}
			
			// Save the Iframe Id
			var finalid = editorId + '_content';
			
			// Set the focus back to the text
			document.frames[finalid].focus();
			
			
			// Apply center alignment
			document.frames[finalid].document.execCommand('JustifyCenter',false,null);
			
			// Set the focus back to the text
			document.frames[finalid].focus();
		}
		
		function AlignRight(rightover,right,editorId)
		{
		
			var img = document.getElementById('rightAlign')
			
			// Save the right over address into a variable
			var imgRight = "Images/" + rightover
			
			// Assign the right address to a variable
			var imgNotRight = "Images/" + right
			
			// Change the icon to right over
			img.src = imgRight;
			
			// Check if the left alignment is clicked
			if(imgStatusLeft == 'Yes')
				{
				
					// Set the variable back to false ( no left alignment)
					imgStatusLeft = 'No';
					
					// Set the icon source to left.
					document.getElementById('leftAlign').src = "Images/justifyleft.gif";
				}
			// Check if the center alignment is clicked
			if(imgStatusCenter == 'Yes')
				{
					// Set the variable back to false( no center alignment)
					imgStatusCenter = 'No';
					
					// Set the icon source to center
					document.getElementById('centerAlign').src = "Images/justifyfull.gif";
				}
			
			// Check if the right alignment is clicked
			if(imgStatusRight == 'Yes')
			{
				// Set its variable back to false
				imgStatusRight='No';
				
				// Set the icon source to right
				img.src = imgNotRight;
			}
			else
			{
			// Set the icon source to right over.
			imgStatusRight= 'Yes'
			}
			
			// Save the iframe id
			var finalid = editorId + '_content';
			
			// Set the focus back to the text
			document.frames[finalid].focus();
			
			// Apply right alignment
			document.frames[finalid].document.execCommand('JustifyRight',false,null);
			
			// Set the focus back to the text
			document.frames[finalid].focus();
		}
		
		function ChangeFontName(editorId)
		{
				// Get the Iframe Id.
			var finalid = editorId + '_content';
			
			// Set the focus back to the Text Editor.
			document.frames[finalid].focus();
			

			var fontName = document.getElementById("FontFamilyName");
			
			// Change text font name
			document.frames[finalid].document.execCommand('FontName',false, fontName.options[fontName.selectedIndex].text);
			
			// Set the focus back to the text.
			document.frames[finalid].focus();
		}
		
		function ChangeFontColor(editorId)
		{
			// Get the Iframe Id.
			var finalid = editorId + '_content';
			
			// Set the focus back to the Text Editor.
			document.frames[finalid].focus();
			
			var fontColor = document.getElementById("Color");
			
			// Change text color
			document.frames[finalid].document.execCommand('ForeColor',false,fontColor.options[fontColor.selectedIndex].text);
			
			// Set the focus back to the text.
			document.frames[finalid].focus();
		}
		
		function MakeBold(boldover, bold,editorId)
		{
				
			// get the frame id
			var finalid = editorId + '_content';
			
			// Set the focus to the text.
			document.frames[finalid].focus();
			
			// Apply bold transformation
			document.frames[finalid].document.execCommand('bold',false,null);
			
			// Set the focus to the text.
			document.frames[finalid].focus();
			
		}
		
		function MakeItalic(italicover, italic,editorId)
		{
			// Save the iframe id
			var finalid = editorId + '_content';
			
			// Set the focus back to the text.
			document.frames[finalid].focus();
			
			// Apply italic transformation
			document.frames[finalid].document.execCommand('italic',false,null);
			
			// Set the focus back to the text.
			document.frames[finalid].focus();
		}
		
		function MakeUnderLine(underlineover, underline,editorId)
		{
			// Save the iframe id in a variable
			var finalid = editorId + '_content';
			
			// Set the focus to the text.
			document.frames[finalid].focus();
			
			// Apply the Underline transformation
			document.frames[finalid].document.execCommand('underline',false,null);
			// Set the focus to the text.
			document.frames[finalid].focus();
		}
		
		function TransformtoHtml(editorId,e)
		{
			
			var height = e.clientY - parseInt('5');
			var offsetHeight = parseInt(e.offsetY);
			height = height - offsetHeight;
			
			var width = e.clientX
			var offsetWidth = parseInt(e.offsetX);
			width = width - offsetWidth - parseInt('1.5');
			
			// Save the iframe id
			var finalDivId = editorId + '_content';
			
			// Save the Html div id
			//var finalDiv2Id = editorId + '_Div2';
			var finalDiv2Id=editorId + '_Div2';
			
			var premiumdiv = document.getElementById(finalDivId);
			var divHeight = premiumdiv.style.pixelHeight;
			
			var div = document.getElementById(finalDiv2Id);
			div.style.position = 'absolute';
			div.style.left = parseInt('299');//width;
			div.style.top = parseInt('300');//height - parseInt(divHeight) - parseInt('4')
			
			// Show the html div 
			div.style.display = 'block';
//			 document.getElementById(finalDivId).style.display = "none";
//             document.getElementById(finalDiv2Id).style.display = "block";
			//div.focus();
			
			// Get the HTML code from the iframe id to the html div id
			div.innerText = document.frames[finalDivId].document.body.outerHTML;
		}
		
		function TransformToText(editorId)
		{
			// Save the HTML div id
			var finalDiv2Id = editorId + '_Div2';
			
			// Save the IFrame id 
			var finalDivId = editorId + '_content';
			
			// Set the focus back to the text
			document.frames[finalDivId].focus();
			
			// Hide the HTML div id
			document.getElementById(finalDiv2Id).style.display = 'none';
//				 document.getElementById(finalDivId).style.display = "block";
//             document.getElementById(finalDiv2Id).style.display = "none";
		}
		
		function ChangeImg(id, imgsrc,ID)
		{
		var imgSrc = "Images/" + imgsrc;
		document.getElementById(id).src = imgSrc;
		}
		
		function ReturnImg(id, imgsrc, ownVar)
		{
		 // Check if the on mouse over of an icon was clicked or not
		if(ownVar == 'No')
		{
		
		// Assign the icon to the normal one
		var imgSrc = "Images/" + imgsrc;
		
		// Set the icon source to the variable
		document.getElementById(id).src = imgSrc;
		}
		}	
			
		function WordCount(wordover,word,editorId)
		{
			// Save the Text box id into a variable
			var finalTextCountId = editorId + '_TxtCount';
			
			// Save the IFrame id 
			var finalDivId = editorId + '_content';
			
			// Save the text entered by the user in a variable
			var wordCount = document.frames[finalDivId].document.body.innerText;
			
			// Set this variable to zero
			var count = 0;
			
			// Replace the \n by an empty string
			countWithSpace = wordCount.replace('\n', '');
			
			// Split the string by the empty space
			countWithoutSpaces = countWithSpace.split(' ');
			
			// loop through the variable, check if each length > 0, and increment the count variable
			for(i=0;i<countWithoutSpaces.length;i++)
			{
				if(countWithoutSpaces[i].length>0)
				{
					count +=1;
					
				}
				
				// set the text Box's value to the count variable
				window.parent.document.getElementById(finalTextCountId).value = count;
			}
			
			}
			
			function Formats(style,editorId)
			{
			// Save the Iframe id
			var finalDivId = editorId + '_content';
			
			// Set the focus back to the text
			document.frames[finalDivId].focus();
			
			// Apply the new style
			document.frames[finalDivId].document.execCommand(style);
			
			// Set the focus back to the text
			document.frames[finalDivId].focus();
			}
			
			function ShowDiv(images,e,editorId)
			{
			// Get the click location
			var height = e.clientY + parseInt('5');
			// Get the height inside the clicked image
			var offsetHeight = parseInt(e.offsetY);
			height = height - offsetHeight;
			
			// Get the click location(width)
			var width = e.clientX
			// Get the width inside the clicked image
			var offsetWidth = parseInt(e.offsetX);
			width = width - offsetWidth;
			
			var div = document.getElementById(images);
			// Set the icons div position, left, and top	
			div.style.position = 'absolute';
			div.style.left = width;
			div.style.top = height + parseInt("20");
						
			// Check if the div containing the emoticons is shown
			if(div.style.display == 'block')
			{
			// Set it to Hidden
			div.style.display = 'none';
			}
			else
			// Show the specified div
			div.style.display = 'block';
			}
			
			function insertImages(style,url,images,editorId)
			{
			// Save the iframe Id
			var finalDivId = editorId + '_content';
			// Save the HTML div id
			var finalDiv2Id = editorId + '_Div2';
			document.getElementById(finalDiv2Id).style.display = 'none'
			// Hide the div containing emoticons 
			document.getElementById(images).style.display = 'none'
			// Set the focus back to the text
			document.frames[finalDivId].focus();
			// Apply changes
			document.frames[finalDivId].document.execCommand(style,'',url);
			// Set the focus back to the text
			document.frames[finalDivId].focus();
			}
	
			function CloneText(editorId)
			{
				// Save the iframe id
				var finalDivId = editorId + '_content';
				// Save the Hidden field Id
				var finalContentTxtId = editorId + '_ContentTxt';
				// Save the Hidden field id
				var finalContentHtmlId = editorId + '_ContentHtml';
				if(document.frames[finalDivId].document.body!=null)
				{
				// Copy the text into the first hidden field
				document.getElementById(finalContentTxtId).innerText = document.frames[finalDivId].document.body.innerText;
				
				// Copy the html into the other hidden field
				document.getElementById(finalContentHtmlId).value= document.frames[finalDivId].document.body.innerHTML;
				}
			}
			
			function setFocus(editorId)
			{
				// Sets focus to the editor directly after loading
				var finalDivId = editorId + '_content';
				document.frames[finalDivId].document.designMode = 'on';
				document.frames[finalDivId].focus();
			}
			
			function SetBorders(id)
			{
				// set the borders to the emoticons icons onmouseover
				var imgBorder = document.getElementById(id);
				imgBorder.style.borderStyle = "solid";
				imgBorder.style.borderWidth = "thin";
				imgBorder.style.borderColor = "#688B9A";
			}
			
			function ClearBorders(id)
			{
				// Clear the borders of the emoticons icons onmouseout event
				var imgBorder = document.getElementById(id);
				imgBorder.style.borderStyle = "solid";
				imgBorder.style.borderWidth = "thin";
				imgBorder.style.borderColor = "white";
			}
			
			function SetImage(editorId,path,e)
			{
				//get checkboxes values
			//	var pmachkbox=document.getElementById('PMAcheckbox1').value;
				//var cepmchkbox=eval(document.getElementById('CEPMcheckbox1'));
				//var pmguruchkbox=eval(document.getElementById('pmgurucheckbox1'));
			//	alert(pmachkbox);
				//alert(cepmchkbox);
				//alert(pmguruchkbox);
				
				// Get the click location
				var height = e.clientY + parseInt('5');
				// Get the height inside the clicked image
				var offsetHeight = parseInt(e.offsetY);
				height = height - offsetHeight;
			
				// Get the click location(width)
				var width = e.clientX
				// Get the width inside the clicked image
				var offsetWidth = parseInt(e.offsetX);
				width = width - offsetWidth;
			
			    // Save the iframe id
				var finalDivId = editorId + '_content';
				
				path = unescape(path);
				
				// Insert an image from the users Computers.
		    	window.open('UploadImages.aspx?path=' + path + '&f=' + finalDivId,null,'height=200,width=500,titlebar=no,menubar=no,statusbar=no,toolbar=no,top=' + height + 'left=' + width );			
				
			}
			
////			function insertsImage(imageurl,editorId,height,width)
////			{
////				opener.document.frames[editorId].focus();
////		    alert("outside if");
////				if(imageurl != "" | editorId!= "")
////				{
////				alert(imageurl);
////				alert(editorID);
////				imageurl = unescape(imageurl);
////				var imageurl = imageurl + '"'  + "width=" + width + "px" + " " + "height="+ height + "px";
////				  // Save the iframe id
////				opener.document.frames[editorId].document.execCommand('InsertImage',false,imageurl);
////				}
////				alert("Not inserted");
////				opener.document.frames[editorId].focus();
////			}
