        /*
          Actualiza a janela de preview do menu ajuda
        */
        function updatePreview()
        {
                var ajudaHTML = document.forms['ajuda'].texto.value;
                //para se poder visualizar correctamente foram feitas algumas operações
                //substituir a mudança de linha por <br />

                var ajuda2HTML = ajudaHTML.replace(/\r/g,'<br />');
                //substituir o tab
                var ajuda3HTML = ajuda2HTML.replace(/<tab>/g,'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');

                //substituir o space
                var ajuda4HTML = ajuda3HTML.replace(/<space>/g,'&nbsp;');

                //substituir o top
                var topo = '<table cellpadding=0 cellspacing=0 border=0 width=100% height=1><tr><td align=right><a href=# class=desenvolvimento>topo</a></td></tr></table>';
                var ajuda5HTML = ajuda4HTML.replace(/<topo>/g,topo);
                //alert('teste: '+ajuda3HTML + ".");

                document.all['preview'].innerHTML=ajuda5HTML
        }

        function applyTag(tagName)
        {
                var selection = document.selection.createRange();
                if (selection.text.length > 0)
                {
                    selection.text = "<" + tagName + ">" + selection.text + "</" + tagName + ">";
                    //updatePreview();
                }
        }

        /*
          Tag especial para fonts
        */
        function applyFontColor(clipBoardName)
        {
            if (window.clipboardData.getData(clipBoardName).length == 6)
            {
                var selection = document.selection.createRange();
                if (selection.text.length > 0)
                {
                    selection.text = "<font color=\"#" + window.clipboardData.getData(clipBoardName) + "\" >" + selection.text + "</font>";
                    //updatePreview();
                }
            }
            else
            {
               alert('O código de cores em memória não é valido! Utilize o selector de cores para obter um código válido.');
            }
        }


        function applyTag2(tagName)
        {
                var selection = document.selection.createRange();
                if (selection.text.length > 0)
                {
                    selection.text = "<" + tagName + ">" + selection.text + "</" + tagName + ">";
                    updatePreview();
                }
        }


        /*
          Tag especial para fonts
        */
        function applyFontColor2(clipBoardName)
        {
            if (window.clipboardData.getData(clipBoardName).length == 6)
            {
                var selection = document.selection.createRange();
                if (selection.text.length > 0)
                {
                    selection.text = "<font color=\"#" + window.clipboardData.getData(clipBoardName) + "\" >" + selection.text + "</font>";
                    updatePreview();
                }
            }
            else
            {
               alert('O código de cores em memória não é valido! Utilize o selector de cores para obter um código válido.');
            }
        }


        function cutSeleccion()
        {
                var selection = document.selection.createRange();
                if (selection.text.length > 0)
                {
                    selection.text = "";
                }
        }

        function cutSeleccion2()
        {
                var selection = document.selection.createRange();
                if (selection.text.length > 0)
                {
                    selection.text = "";
                    updatePreview();
                }
        }


        if( document.getElementById )
        {
            getElemById = function( id )
            {
                return document.getElementById( id );
            }
        }
        else if( document.all )
        {
            getElemById = function( id )
            {
                return document.all[ id ];
            }
        }
        else if( document.layers )
        {
            getElemById = function( id )
            {
                return document.layers[ id ];
            }
        }

        //mostra ou nao um determinado elemento
        //mostra quando nao esta checado
        function showhide( el, id)
        {
            if ( el && el.style )
            {
                getElemById( id ).style.display = (el.checked)? 'none' : '';
            }
        }
        //mostra quando esta checado
        function showhideInverse( el, id)
        {
            if ( el && el.style )
            {
                getElemById( id ).style.display = (el.checked)? '' : 'none';
            }
        }

        function showhide2(id)
        {
                if(getElemById( id ).style.display == 'none')
                {
                    getElemById( id ).style.display = ''
                }
                else if(getElemById( id ).style.display == '')
                {
                    getElemById( id ).style.display = 'none'
                }
        }

        //abre tabela de cores
        function openCores()
        {
            windowList = window.open("cores/cor.php" ,  "TabelaCores", "toolbar=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=400");
        }

