function insertEditableArea(editableAreaName, editableAreaWidth, editableAreaHeight, editableAreaLayout, editableAreaStyle, conteudo) {
	var boldButton = '<img src="icons/stock_text_bold.png" value="Negrito" alt="Negrito" class="editableAreaButton" style="width:24;cursor:pointer; height:24;" onclick="javascript:buttonOnClick(\'bold\', this);" name="' + editableAreaName + '">';

    var italicButton = '<img src="icons/stock_text_italic.png" value="Italico" alt="Italico" class="editableAreaButton" style="width:24;cursor:pointer; height:24;" onclick="javascript:buttonOnClick(\'italic\', this);" name="' + editableAreaName + '">';

    var underlinedButton = '<img src="icons/stock_text_underlined.png" value="Sublinhado" alt="Sublinhado" class="editableAreaButton" style="width:24;cursor:pointer; height:24;" onclick="javascript:buttonOnClick(\'underline\', this);" name="' + editableAreaName + '">';

    var alignLeftButton = '<img src="icons/stock_text_left.png" value="Alinhar a esquerda" alt="Alinhar a esquerda" class="editableAreaButton" style="width:24;cursor:pointer; height:24;" onclick="javascript:buttonOnClick(\'justifyleft\', this);" name="' + editableAreaName + '">';
	
	var justifyButton = '<img src="icons/stock_text_justify.png" value="Justificar" alt="Justificar" class="editableAreaButton" style="width:24;cursor:pointer; height:24;" onclick="javascript:buttonOnClick(\'justifyfull\', this);" name="' + editableAreaName + '">';

	var alignCenterButton = '<img src="icons/stock_text_center.png" value="Alinhar ao Centro" alt="Alinhar ao Centro" class="editableAreaButton" style="width:24;cursor:pointer; height:24;" onclick="javascript:buttonOnClick(\'justifycenter\', this);" name="' + editableAreaName + '">';
	
	var alignRightButton = '<img src="icons/stock_text_right.png" value="Alinhar a direita" alt="Alinhar a direita" class="editableAreaButton" style="width:24;cursor:pointer; height:24;" onclick="javascript:buttonOnClick(\'justifyright\', this);" name="' + editableAreaName + '">';
	
	var editableArea = '<iframe src="blank.html?style=' + editableAreaStyle + '&conteudo=' + conteudo + '" id="' + editableAreaName + '" style="width:' + editableAreaWidth + 'px; height:' + editableAreaHeight + 'px; border-style:inset; border-width:thin;" frameborder="0px"></iframe>'

	var editableAreaHTML = editableAreaLayout;
	editableAreaHTML = editableAreaHTML.replace("[bold]", boldButton);
	editableAreaHTML = editableAreaHTML.replace("[italic]", italicButton);
	editableAreaHTML = editableAreaHTML.replace("[underlined]", underlinedButton);
	editableAreaHTML = editableAreaHTML.replace("[align-left]", alignLeftButton);
	editableAreaHTML = editableAreaHTML.replace("[justify]", justifyButton);
	editableAreaHTML = editableAreaHTML.replace("[align-center]", alignCenterButton);
	editableAreaHTML = editableAreaHTML.replace("[align-right]", alignRightButton);
	editableAreaHTML = editableAreaHTML.replace("[edit-area]", editableArea);
	
	if (document.designMode) {
		document.write(editableAreaHTML);
		
	} else {
		// create a normal <textarea> if document.designMode does not exist
		document.write('<textarea ws=50 id="' + editableAreaName + '" style="width:' + editableAreaWidth + 'px; height:' + editableAreaHeight + 'px; ' + editableAreaStyle + '"></textarea>');
	}
	
}

function editableAreaContents(editableAreaName) {
	if (document.designMode) {
		// Explorer reformats HTML during document.write() removing quotes on element ID names
		// so we need to address Explorer elements as window[elementID]
		if (window[editableAreaName]) return window[editableAreaName].document.body.innerHTML;
		return document.getElementById(editableAreaName).contentWindow.document.body.innerHTML;
	} else {
		// return the value from the <textarea> if document.designMode does not exist
		return document.getElementById(editableAreaName).value;
	}
}

function buttonMouseOver() {
	// events for mouseOver on buttons
	// e.g. this.style.xxx = xxx
}

function buttonMouseOut() {
	// events for mouseOut on buttons
	// e.g. this.style.xxx = xxx
}


function buttonMouseUp() {
	// events for mouseUp on buttons
	// e.g. this.style.xxx = xxx
}

function buttonMouseDown(e) {
	// events for mouseDown on buttons
	// e.g. this.style.xxx = xxx

	// prevent default event (i.e. don't remove focus from text area)
	var evt = e ? e : window.event; 

	if (evt.returnValue) {
		evt.returnValue = false;
	} else if (evt.preventDefault) {
		evt.preventDefault( );
	} else {
		return false;
	}
}

function buttonOnClick(sNomeComando, obj) {
	// Explorer reformats HTML during document.write() removing quotes on element ID names
	// so we need to address Explorer elements as window[elementID]
	
	if (window[obj.name]) { window[obj.name].document.execCommand(sNomeComando, false, null); }
	else { document.getElementById(obj.name).contentWindow.document.execCommand(sNomeComando, false, null); 
	}
	
}