// 
// Saibre - Tecnologia da Informação Ltda
// Rich Editor Rendering - using YUI 2 
// Author: Ronaldo F. Lima
// (C) 2009 - Saibre Tecnologia da Informação - All Rights Reserved
//
function setupEditor (controlId, submitId) {
    var editor = new YAHOO.widget.Editor(controlId, {
	height: '300px',
	width: '600px',
	dompath: false, 
	toolbar: {
            titlebar: false,
            buttons: [
		{ group: 'textstyle', label: 'Estilo da Fonte',
		  buttons: [
                      { type: 'push', label: 'Negrito', value: 'bold' },
                      { type: 'push', label: 'Itálico', value: 'italic' },
                      { type: 'push', label: 'Sublinhado', value: 'underline' },
                      { type: 'separator' },
                      { type: 'select', label: 'Arial', value: 'fontname', disabled: true,
			menu: [
                            { text: 'Arial', checked: true },
                            { text: 'Arial Black' },
                            { text: 'Comic Sans MS' },
                            { text: 'Courier New' },
                            { text: 'Lucida Console' },
                            { text: 'Tahoma' },
                            { text: 'Times New Roman' },
                            { text: 'Trebuchet MS' },
                            { text: 'Verdana' }
			]
                      },
                      { type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true },
                      { type: 'separator' },
                      { type: 'color', label: 'Cor', value: 'forecolor', disabled: true },
                      { type: 'color', label: 'Cor de fundo', value: 'backcolor', disabled: true }
		  ]
		},
		{ type: 'separator' }, 
		{ group: 'alignment', label: 'Alinhamento', 
		  buttons: [ 
	              { type: 'push', label: 'Alinhar à esquerda CTRL + SHIFT + [', value: 'justifyleft' }, 
	              { type: 'push', label: 'Centralizar CTRL + SHIFT + |', value: 'justifycenter' }, 
	              { type: 'push', label: 'Alinhar à direita CTRL + SHIFT + ]', value: 'justifyright' }, 
	              { type: 'push', label: 'Justificar', value: 'justifyfull' } 
		  ] 
		}, 
		{ type: 'separator' }, 
		{ group: 'parastyle', label: 'Estilo do parágrafo', 
		  buttons: [ 
	              { type: 'select', label: 'Normal', value: 'heading', disabled: true, 
			menu: [ 
	                    { text: 'Normal', value: 'none', checked: true }, 
	                    { text: 'Header 1', value: 'h1' }, 
	                    { text: 'Header 2', value: 'h2' }, 
	                    { text: 'Header 3', value: 'h3' }, 
	                    { text: 'Header 4', value: 'h4' }, 
	                    { text: 'Header 5', value: 'h5' }, 
			    { text: 'Header 6', value: 'h6' } 
			] 
		      } 
		  ] 
		}, 
		{ type: 'separator' },
		{ group: 'indentlist', label: 'Recuo e Listas',
		  buttons: [
		      { type: 'push', label: '+ Recuo', value: 'indent', disabled: true },
		      { type: 'push', label: '- Recuo', value: 'outdent', disabled: true },
		      { type: 'push', label: 'List desordenada', value: 'insertunorderedlist' },
		      { type: 'push', label: 'Lista ordenada', value: 'insertorderedlist' }
		  ]
		},
		{ group: 'insertitem', label: 'Inserir',
		  buttons: [
		      { type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink', disabled: true },
		      { type: 'push', label: 'Imagem', value: 'insertimage' }
		  ]
		}
            ]
	}
    });
    editor.render();

    //Inside an event handler after the Editor is rendered 
    YAHOO.util.Event.on (submitId, 'click', function() { 
	//Put the HTML back into the text area 
	editor.saveHTML(); 
	
	//The var html will now have the contents of the textarea 
	var html = editor.get('element').value; 
    }); 
    return editor;
}

function setupSimpleEditor (controlId, submitId) {
    var editor = new YAHOO.widget.SimpleEditor (controlId, {
	height: '300px',
	width: '600px',
	dompath: false, 
	toolbar: {
            titlebar: false,
            buttons: [
		{ group: 'textstyle', label: 'Estilo da Fonte',
		  buttons: [
                      { type: 'push', label: 'Negrito', value: 'bold' },
                      { type: 'push', label: 'Itálico', value: 'italic' },
                      { type: 'push', label: 'Sublinhado', value: 'underline' },
                      { type: 'separator' },
                      { type: 'select', label: 'Arial', value: 'fontname', disabled: true,
			menu: [
                            { text: 'Arial', checked: true },
                            { text: 'Arial Black' },
                            { text: 'Comic Sans MS' },
                            { text: 'Courier New' },
                            { text: 'Lucida Console' },
                            { text: 'Tahoma' },
                            { text: 'Times New Roman' },
                            { text: 'Trebuchet MS' },
                            { text: 'Verdana' }
			]
                      },
                      { type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true }
		  ]
		},
		{ type: 'separator' }, 
		{ group: 'alignment', label: 'Alinhamento', 
		  buttons: [ 
	              { type: 'push', label: 'Alinhar à esquerda CTRL + SHIFT + [', value: 'justifyleft' }, 
	              { type: 'push', label: 'Centralizar CTRL + SHIFT + |', value: 'justifycenter' }, 
	              { type: 'push', label: 'Alinhar à direita CTRL + SHIFT + ]', value: 'justifyright' }, 
	              { type: 'push', label: 'Justificar', value: 'justifyfull' } 
		  ] 
		}
            ]
	}
    });
    editor.render();

    //Inside an event handler after the Editor is rendered 
    YAHOO.util.Event.on (submitId, 'click', function() { 
	//Put the HTML back into the text area 
	editor.saveHTML(); 
	
	//The var html will now have the contents of the textarea 
	var html = editor.get('element').value; 
    }); 
    return editor;
}