
   // rich text editor

   var command = "";
   var msie = false;

   function editBtnClick(cmd)
   {
      document.getElementById('edit').contentWindow.document.execCommand(cmd, false, null);
      document.getElementById("edit").contentWindow.focus();
   }

   function editLink()
   {
      var linkURL = prompt("Enter the URL you wish to link to:", "http://");
      if (linkURL && linkURL.length > 8)
      {
         document.getElementById('edit').contentWindow.document.execCommand("CreateLink",false,linkURL);
      }
      document.getElementById("edit").contentWindow.focus();
   }

   // initialize editor

   function initEditor() 
   {
      // attempt to initialize editor

      try
      {
         document.getElementById('edit').contentWindow.document.designMode = "on";
		 if (document.getElementById('edit2')) document.getElementById('edit2').contentWindow.document.designMode = "on";
		 if (document.getElementById('edit3')) document.getElementById('edit3').contentWindow.document.designMode = "on";
		 if (document.getElementById('edit4')) document.getElementById('edit4').contentWindow.document.designMode = "on";
		 if (document.getElementById('edit5')) document.getElementById('edit5').contentWindow.document.designMode = "on";
      }
      catch (e)
      {
         return(false);
      }

      try 
      {
         document.getElementById('edit').contentWindow.document.execCommand("undo", false, null);
 		 if(document.getElementById('edit2')) document.getElementById('edit2').contentWindow.document.execCommand("undo", false, null);
		 if(document.getElementById('edit3')) document.getElementById('edit3').contentWindow.document.execCommand("undo", false, null);
		 if(document.getElementById('edit4')) document.getElementById('edit4').contentWindow.document.execCommand("undo", false, null);
		 if(document.getElementById('edit5')) document.getElementById('edit5').contentWindow.document.execCommand("undo", false, null);
      }  
      catch (e) 
      {
         // alert("This editor is not supported on your web browser.");
      }

      // simple HTML tags -- Mozilla defaults to verbose CSS markup
      try 
      {
         document.getElementById('edit').contentWindow.document.execCommand("useCSS", false, true)
		 ;
		 if (document.getElementById('edit2')) {
			 document.getElementById('edit2').contentWindow.document.execCommand("useCSS", false, true)
		 ;
		 }
		 if (document.getElementById('edit3')) {
			 document.getElementById('edit3').contentWindow.document.execCommand("useCSS", false, true)
		 ;
		 }
		 if (document.getElementById('edit4')) {
			 document.getElementById('edit4').contentWindow.document.execCommand("useCSS", false, true)
		 ;
		 }
		 if (document.getElementById('edit5')) {
			 document.getElementById('edit5').contentWindow.document.execCommand("useCSS", false, true)
		 ;
		 }
      }
      catch (e)
      {
         // no need to set non-CSS mode for MSIE
         msie = true;
      }

      document.getElementById('edit').contentWindow.document.write(document.pageForm.description.value);
      document.getElementById('edit').contentWindow.document.close();
	  if (document.getElementById('edit2')) {
			document.getElementById('edit2').contentWindow.document.write(document.pageForm.description2.value);
      		document.getElementById('edit2').contentWindow.document.close();
	  }
	  if (document.getElementById('edit3')) {
			document.getElementById('edit3').contentWindow.document.write(document.pageForm.description3.value);
      		document.getElementById('edit3').contentWindow.document.close();
	  }
	  if (document.getElementById('edit4')) {
			document.getElementById('edit4').contentWindow.document.write(document.pageForm.description4.value);
      		document.getElementById('edit4').contentWindow.document.close();
	  }
	  if (document.getElementById('edit5')) {
			document.getElementById('edit5').contentWindow.document.write(document.pageForm.description5.value);
      		document.getElementById('edit5').contentWindow.document.close();
	  }
   }

   function initStyle()
   {
      document.getElementById('edit').contentWindow.document.write(document.pageForm.description.value);
      document.getElementById('edit').contentWindow.document.close();
	  
	  if (document.getElementById('edit2')) {
		document.getElementById('edit2').contentWindow.document.write(document.pageForm.description2.value);
      	document.getElementById('edit2').contentWindow.document.close();  
	  }
	  if (document.getElementById('edit3')) {
		document.getElementById('edit3').contentWindow.document.write(document.pageForm.description3.value);
      	document.getElementById('edit3').contentWindow.document.close();  
	  }
	  if (document.getElementById('edit4')) {
		document.getElementById('edit4').contentWindow.document.write(document.pageForm.description4.value);
      	document.getElementById('edit4').contentWindow.document.close();  
	  }
	  if (document.getElementById('edit5')) {
		document.getElementById('edit5').contentWindow.document.write(document.pageForm.description5.value);
      	document.getElementById('edit5').contentWindow.document.close();  
	  }
   }

   function processPage()
   {
      // Assign the HTML code to a hidden form variable 

      var htmlCode = document.getElementById('edit').contentWindow.document.body.innerHTML;
      document.pageForm.description.value = htmlCode;
	  
	  if (document.getElementById('edit2')) {
		    htmlCode = document.getElementById('edit2').contentWindow.document.body.innerHTML;
      		document.pageForm.description2.value = htmlCode;
	  }
	  
	  if (document.getElementById('edit3')) {
		    htmlCode = document.getElementById('edit3').contentWindow.document.body.innerHTML;
      		document.pageForm.description3.value = htmlCode;
	  }
	  
	  if (document.getElementById('edit4')) {
		    htmlCode = document.getElementById('edit4').contentWindow.document.body.innerHTML;
      		document.pageForm.description4.value = htmlCode;
	  }
	  
	  if (document.getElementById('edit5')) {
		    htmlCode = document.getElementById('edit5').contentWindow.document.body.innerHTML;
      		document.pageForm.description5.value = htmlCode;
	  }
	  
	  
      return true;
   } 


