function editor (name, width, height, path, html)
{
	document.write ('<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc">');
	document.write ('   <tr bgcolor="#f0f0f0">');
	document.write ('      <td><img src="'+path+'/undo.gif" onclick="exe (\''+name+'\', \'undo\')"></td>');
	document.write ('      <td><img src="'+path+'/redo.gif" onclick="exe (\''+name+'\', \'redo\')"></td>');
	document.write ('      <td><img src="'+path+'/bold.gif" onclick="exe (\''+name+'\', \'bold\')"></td>');
	document.write ('      <td><img src="'+path+'/italic.gif" onclick="exe (\''+name+'\', \'italic\')"></td>');
	document.write ('      <td><img src="'+path+'/underline.gif" onclick="exe (\''+name+'\', \'underline\')"></td>');
	document.write ('      <td><img src="'+path+'/justifyleft.gif" onclick="exe (\''+name+'\', \'justifyleft\')"></td>');
	document.write ('      <td><img src="'+path+'/justifycenter.gif" onclick="exe (\''+name+'\', \'justifycenter\')"></td>');
	document.write ('      <td><img src="'+path+'/justifyright.gif" onclick="exe (\''+name+'\', \'justifyright\')"></td>');
	document.write ('      <td><img src="'+path+'/justifyfull.gif" onclick="exe (\''+name+'\', \'justifyfull\')"></td>');
	document.write ('      <td><img src="'+path+'/insertunorderedlist.gif" onclick="exe (\''+name+'\', \'insertunorderedlist\')"></td>');
	document.write ('      <td><img src="'+path+'/insertorderedlist.gif" onclick="exe (\''+name+'\', \'insertorderedlist\')"></td>');
	document.write ('      <td><img src="'+path+'/indent.gif" onclick="exe (\''+name+'\', \'indent\')"></td>');
	document.write ('      <td><img src="'+path+'/outdent.gif" onclick="exe (\''+name+'\', \'outdent\')"></td>');
	document.write ('      <td><img src="'+path+'/createlink.gif" onclick="exe (\''+name+'\', \'createlink\')"></td>');
	document.write ('      <td width="100%">');
	document.write ('         <table border="0" cellpadding="0" cellspacing="0">');
	document.write ('            <tr>');
	document.write ('               <td><input type="checkbox" id="'+name+'_source" onclick="sourcem (\''+name+'\')"></td>');
	document.write ('               <td><nobr>просмотр html-кода</nobr></td>');
	document.write ('            </tr>');
	document.write ('         </table>');
	document.write ('      </td>');
	document.write ('   </tr>');
	document.write ('</table>');
	document.write ('<input type="hidden" name="'+name+'" id="'+name+'">');
	document.write ('<iframe id="'+name+'_value" width="'+width+'" height="'+height+'" scrolling="yes"></iframe>');

	setTimeout ('mode (\''+name+'\', \''+html+'\')', 250);
}

function mode (name, html)
{
	if (document.all)
	{
		var doc=frames[name+'_value'].document;
		doc.writeln (html);
	}
	else
	{
		var doc=document.getElementById (name+'_value').contentWindow.document;
		doc.body.innerHTML=html;
	}
	doc.designMode='on';
}

function sourcem (name)
{
	if (document.all)
	{
		var doc=frames[name+'_value'].document;
	}
	else
	{
		var doc=document.getElementById (name+'_value').contentWindow.document;
	}
	if (document.getElementById (name+'_source').checked)
	{
		if (document.all)
		{
			doc.body.innerText=doc.body.innerHTML;
		}
		else
		{
			var body=doc.createTextNode (doc.body.innerHTML);
			doc.body.innerHTML=null;
			doc.body.appendChild (body);
		}
	}
	else
	{
		if (document.all)
		{
			doc.body.innerHTML=doc.body.innerText;
		}
		else
		{
			var body=doc.body.ownerDocument.createRange ();
			body.selectNodeContents (doc.body);
			doc.body.innerHTML=body;
		}
	}
}

function exe (name, command)
{
	if (document.all)
	{
		frames[name+'_value'].focus ();
		frames[name+'_value'].document.execCommand (command);
		frames[name+'_value'].focus ();
	}
	else
	{
		document.getElementById (name+'_value').contentWindow.focus ();
		document.getElementById (name+'_value').contentWindow.document.execCommand (command, false, null);
		document.getElementById (name+'_value').contentWindow.focus ();
	}
}

function send (name)
{
	if (document.all)
	{
		var doc=frames[name+'_value'].document;
	}
	else
	{
		var doc=document.getElementById (name+'_value').contentWindow.document;
	}
	document.getElementById (name).value=doc.body.innerHTML;
}
