		var viewMode; // WYSIWYG

		function Init()
		{			
			viewMode = "1";			
			iView.document.designMode = 'On';	
			designcode.style.display = 'none';
		}
		  
		function selOn(ctrl)
		{
			ctrl.style.borderColor = '#000000';
			ctrl.style.backgroundColor = '#B5BED6';
			ctrl.style.cursor = 'hand';	
		}
		  
		function selOff(ctrl)
		{
			ctrl.style.borderColor = '#D6D3CE';  
			ctrl.style.backgroundColor = '#D6D3CE';
		}
		  
		function selDown(ctrl)
		{
			ctrl.style.backgroundColor = '#8492B5';
		}
		  
		function selUp(ctrl)
		{
			ctrl.style.backgroundColor = '#B5BED6';
		}

		function doCut()
		{
			iView.document.execCommand('Cut',false,null);
		}

		function doCopy()
		{
			iView.document.execCommand('Copy',false,null);
		}

		function doPaste()
		{
			iView.document.execCommand('Paste',false,null);
		}

		function doOutdent()
		{
			iView.document.execCommand('Outdent',false,null);
		}

		function doIndent()
		{
			iView.document.execCommand('Indent',false,null);
		}

		function doStrikeThrough()
		{
			iView.document.execCommand('StrikeThrough',false,null);
		}

		function doSuperScript()
		{
			iView.document.execCommand('SuperScript',false,null);
		}

		function doSubScript()
		{
			iView.document.execCommand('SubScript',false,null);
		}

		function doUndo()
		{
			iView.document.execCommand('Undo',false,null);
		}

		function doRedo()
		{
			iView.document.execCommand('Redo',false,null);
		}
		    
		function doBold()
		{
			iView.document.execCommand('bold', false, null);
		}

		function doItalic()
		{
			iView.document.execCommand('italic', false, null);
		}

		function doUnderline()
		{
			iView.document.execCommand('underline', false, null);
		}
		  
		function doLeft()
		{
			iView.document.execCommand('justifyleft', false, null);
		}

		function doCenter()
		{
			iView.document.execCommand('justifycenter', false, null);
		}

		function doRight()
		{
			iView.document.execCommand('justifyright', false, null);
		}

		function doOrdList()
		{
			iView.document.execCommand('insertorderedlist', false, null);
		}

		function doBulList()
		{
			iView.document.execCommand('insertunorderedlist', false, null);
		}
		  
		function doForeCol()
		{
			var fCol = prompt('Enter foreground color', '');
		    
			if(fCol != null)
			iView.document.execCommand('forecolor', false, fCol);
		}

		function doBackCol()
		{
			var bCol = prompt('Enter background color', '');
		    
			if(bCol != null)
			iView.document.execCommand('backcolor', false, bCol);
		}

		function doLink()
		{
			iView.document.execCommand('createlink');
		}
		  
		function doImage()
		{
			var imgSrc = prompt('Enter image location', '');
		    
			if(imgSrc != null)    
			iView.document.execCommand('insertimage', false, imgSrc);
		}
		  
		function doRule()
		{
			var info = new Array(1);
			info[0]=prompt("Enter the Color of the line","");
			iView.innerHTML = iView.innerHTML + "<hr color=" + info[0] + ">";
		}
		  
		function doFont(fName)
		{
			if(fName != '')
			iView.document.execCommand('fontname', false, fName);
		}
		  
		function doSize(fSize)
		{
			if(fSize != '')
			iView.document.execCommand('fontsize', false, fSize);
		}
		  
		function doHead(hType)
		{
			if(hType != '')
			{
			iView.document.execCommand('formatblock', false, hType);  
			doFont(selFont.options[selFont.selectedIndex].value);
			}
		}
		  
		function doToggleView(vMode)
		{  			
			viewMode = vMode;	
			if(viewMode == "1")
			{
				
			iHTML = iView.innerHTML;
			iView.innerText = iHTML;
			


			document.Form1.htmleditor_mode.value="2";

			//alert(document.Form1.htmleditor_mode.value);

		      
			// Hide all controls
			tblCtrls.style.display = 'none';
			htmlcode.style.display = 'none';
			designcode.style.display = 'inline';
			
			iView.focus();
			}
			else
			{

			iText = iView.innerText;
			iView.innerHTML = iText;

			document.Form1.htmleditor_mode.value="1";

			//alert(document.Form1.htmleditor_mode.value);
		      
			// Show all controls
			tblCtrls.style.display = 'inline';
			htmlcode.style.display = 'inline';
			designcode.style.display = 'none';
			
			iView.focus();
			}
		}

		function inserttable()
		{		
			var info=new Array(5);
			var c,i,j,w,h;
			info[0]=prompt("Enter No. of Rows","0");
			info[1]=prompt("Enter No. of Columns","0");
			info[2]=prompt("Enter Border Size", "1");
			info[3]=prompt("Enter Width either in percent or pixels (if by percent then have a % symbol appended to the number entered)", "100%");
			info[4]=prompt("Enter Height either in percent or pixels (if by percent then have a % symbol appended to the number entered)","100%");	
			if (info[0]!="0" && info[1]!="0") 
			{
			c = "<table width=" + info[3] + " height=" + info[4] + " border=" + info[2] + ">";
			for (i=1;i<=Number(info[0]) ; i++)
			{
				c = c + "<tr>";
				for(j=1;j<=Number(info[1]);j++)
				{
					c = c + "<td></td>";
				}
				c = c + "</tr>";
			}
			c = c + "</table>";	
			}
			iView.innerHTML = iView.innerHTML + c;
		}
