function start() {
	document.getElementById('rteeditor').contentWindow.document.designMode = 'on';
	//document.getElementById('editor').contentWindow.document.execCommand('useCSS', false, true);
}

function format(command) 
{
	var editor = document.getElementById('rteeditor');
	var doc = editor.contentWindow.document;
	var param = null;

	//beberapa fungsi membutuhkan penanganan lebih lanjut
	//contohnya adalah untuk menambah hyperlink
	if (command == 'createlink') {
		//tanya URL
		param = prompt('URL', 'http://');
	}
	
	if (command == 'insertimage') {
		//tanya URL
		param = "";
		var strUrl = document.getElementById('rtetxtURL2').value;
		if (document.getElementById('rtetxtAlt2').value != "")
		{
			param += " alt='" +document.getElementById('rtetxtAlt2').value+ "'";
		}
		if (document.getElementById('rtetxtBorder2').value != "")
		{
			param += " border='" +document.getElementById('rtetxtBorder2').value+ "'";
		}
		if (document.getElementById('rtetxtHspace2').value != "")
		{
			param += " hspace='" +document.getElementById('rtetxtHspace2').value+ "'";
		}
		if (document.getElementById('rtetxtVspace2').value != "")
		{
			param += " vspace='" +document.getElementById('rtetxtVspace2').value+ "'";
		}
		if (document.getElementById('rtetxtWidth2').value != "")
		{
			param += " width='" +document.getElementById('rtetxtWidth2').value+ "'";
		}
		if (document.getElementById('rtetxtHeight2').value != "")
		{
			param += " height='" +document.getElementById('rtetxtHeight2').value+ "'";
		}
		if (document.getElementById('rtecmbAlign2').value != "")
		{
			param += " align='" +document.getElementById('rtecmbAlign2').value+ "'";
		}
		param = "<img src='" +strUrl+ "' " +param+ ">";
		//alert(param);
		command = 'inserthtml'
		//param = param + '"' + " width=40 height=40 border=1" ;
	}
	
	if (command == 'fontsize') {
		//tanya URL
		param = document.getElementById("rtefontsize").value;
	}
	
	if (command == 'fontname') {
		//tanya URL
		param = document.getElementById("rtefontname").value;
	}
	
	if (command == 'forecolor') {
		//tanya URL
		param = document.getElementById("rteforecolor").value;
	}
	
	//perintahkan dokumen pada editor untuk memasang format yang diminta
	if (command == "inserthtml")
	{
		if (document.all) 
		{		
			if (doc.selection != '')
			{
				var range = doc.selection.createRange();				
				range.pasteHTML(param);				
			}
			else
			{	

			}
			
			//$('#rteeditor').append('<p>Test</p>');
		} 
		else 
		{
			doc.execCommand('insertHTML', false, param);
		}
	}	
	else
	{
		doc.execCommand(command, false, param);
	}
}

function submitRTE() {
	var doc = document.getElementById('rteeditor').contentWindow.document;
	var body = doc.body;
	var textarea = document.getElementById('Content');

	textarea.value = body.innerHTML;
}

function cekform() {
	salin();
	return true;
}

function openChild(file,window) 
{
    childWindow=open(file,window,'resizable=0,scrollbars=1,location=0,menubar=0,width=550,height=350');
	//childWindow.focus();
    if (childWindow.opener == null) 
	{
		childWindow.opener = self;
	}
}

function rteDefaultValue(formname, caller)
{	
	setTimeout("getContent('" + formname + "','" + caller+ "')",500);
}
function getContent(formname, caller)
{
	idContent=document.getElementById('rteeditor');
	if (idContent.contentWindow.document.body) {
		idContent.contentWindow.document.body.innerHTML = eval("document." + formname + "." + caller + ".value");
	}
	idContent.contentWindow.document.designMode='On';
}
