var myeditor; 

window.onload = function() 
{ 
 myeditor = document.getElementById('rte').contentWindow.document; 
 myeditor.designMode = "on";
 
}


function doCheck(obj) {

document.getElementById(obj).value = myeditor.body.innerHTML;
alert(myeditor.body.innerHTML);
}

function Start(obj,width,height) {

	document.write("<img src=\"bold.gif\" name=\"btnBold\" onClick=\"doClick('bold')\">"); 
    document.write("<img src=\"italic.gif\" name=\"btnItalic\" onClick=\"doClick('italic')\">");
	document.write("<img src=\"underline.gif\" name=\"btnUnderline\" onClick=\"doClick('underline')\">");
	document.write("<img src=\"link.gif\" name=\"btnLink\" onClick=\"doLink()\">");
	document.write("<img src=\"unlink.gif\" name=\"btnUnlink\" onClick=\"doClick('unlink')\">");
	document.write("<img src=\"picture.gif\" name=\"btnPicture\" onClick=\"doImage()\">");
	document.write("<br>");

	document.write("<iframe id=\"rte\" width=\"" + width + "\" height=\"" + height + "\" style=\"border:1px solid grey\" src=\"source.php\"></iframe>");
    document.write("<input type=\"hidden\" id=\"" + obj + "\"  name=\"" + obj + "\">");

		}



function doClick(command) {
document.getElementById("rte").contentWindow.document.execCommand(command, false, null); 
}

function doLink() {
 var mylink = prompt("Enter a URL:", "http://");
    if ((mylink != null) && (mylink != "")) {
      document.getElementById('rte').contentWindow.document.execCommand("CreateLink",false,mylink);
  }
}
 function doImage() {
 myimg = prompt('Enter Image URL:', 'http://');
 document.getElementById('rte').contentWindow.document.execCommand('InsertImage', false, myimg);
 }