var viewMode = 1; 


  function Init(formx,fieldx,editorx)
  {
  	
    var initialValue = docForm.initialValue.value;
	//eval(editorx).document.write("<html><head><style>body {font-family:verdana; font-size:11px;}; p {margin:0; padding:0};</style></head><body>" + initialValue + "</body></html>");
	eval(editorx).document.designMode = 'On';
	eval(editorx).focus();
  }
  
  function synchField(formx,fieldx)
  {
	var docFormField = eval("document." + formx + "." + fieldx);
  	var editorValue = document.getElementById("EDT" + fieldx).innerHTML;
	docFormField.value = editorValue;
  }

  function selOn(ctrl)
  {
	ctrl.style.borderColor = '#cccccc';
	ctrl.style.backgroundColor = '#FCFCFC';
	ctrl.style.cursor = 'hand';	
  }
  
  function selOff(ctrl)
  {
	ctrl.style.borderColor = '#EFEFEF';  
	ctrl.style.backgroundColor = '#EFEFEF';
  }
  
   function selOntd(ctrl)
  {
	ctrl.style.backgroundColor = '#EFEFEF';
	ctrl.style.cursor = 'hand';	
  }
  
  function selOfftd(ctrl)
  { 
	ctrl.style.backgroundColor = '#FFFFFF';
  }
  

  function doBold(formx,fieldx)
  {
	document.getElementById("EDT" + fieldx).document.execCommand('bold', false, null);
	  synchField(formx,fieldx);
  }

  function doItalic(formx,fieldx)
  {
	document.getElementById("EDT" + fieldx).document.execCommand('italic', false, null);
	  synchField(formx,fieldx);
  }

  function doUnderline(formx,fieldx)
  {
	document.getElementById("EDT" + fieldx).document.execCommand('underline', false, null);
	  synchField(formx,fieldx);
  }
  
  function doLeft(formx,fieldx)
  {
    document.getElementById("EDT" + fieldx).document.execCommand('justifyleft', false, null);
	  synchField(formx,fieldx);
  }

  function doCenter(formx,fieldx)
  {
    document.getElementById("EDT" + fieldx).document.execCommand('justifycenter', false, null);
	  synchField(formx,fieldx);
  }

  function doRight(formx,fieldx)
  {
    document.getElementById("EDT" + fieldx).document.execCommand('justifyright', false, null);
	  synchField(formx,fieldx);
  }

  function doOrdList(formx,fieldx)
  {
    document.getElementById("EDT" + fieldx).document.execCommand('insertorderedlist', false, null);
	  synchField(formx,fieldx);
  }

  function doBulList(formx,fieldx)
  {
    document.getElementById("EDT" + fieldx).document.execCommand('insertunorderedlist', false, null);
	  synchField(formx,fieldx);
  }
  
  function doForeCol(fCol,formx,fieldx)
  {
      document.getElementById("EDT" + fieldx).document.execCommand('forecolor', false, fCol);
	  toggleLayer(19);
	  synchField(formx,fieldx);
  }
  
 
function toggleLayer(layerid,width,height,top,left)	{
	 layer = document.getElementById(layerid);
	 
	 if (layer.style.visibility == "visible")	{
	 	layer.style.visibility = "hidden";
		layer.style.width = "1px";
		layer.style.height = "1px";
	 }
	 
	 else	{
	 	layer.style.visibility = "visible";
		// Uncomment next lines for absolute positioning
		//layer.style.top = top ;
		//layer.style.left = left ;
		layer.style.top = event.clientY ;
		layer.style.left = event.clientX - 100 ;
		layer.style.width = width ;
		layer.style.height = height ;
	 }
}