/* $Id: wysiwyg.js 4 2011-01-20 10:45:27Z tigra $ */
$().ready(function() {
    
    $('textarea.tinymce').tinymce({
        // Location of TinyMCE script
        script_url : '/striped/js/tiny_mce/tiny_mce.js',
        
        language : lang,

        // General options
        relative_urls : "false",
        remove_script_host : false,
        convert_urls : false,
        verify_html : true,
        theme : "advanced",
        plugins : "fullscreen,inlinepopups,layer,tabfocus,xhtmlxtras",

        // Theme options
        theme_advanced_blockformats : "h4,h5,h6",
        theme_advanced_buttons1 : "bold,italic,strikethrough,formatselect,removeformat,|,bullist,numlist,outdent,indent,|,blockquote,|,anchor,link,unlink,|,fullscreen,code",//pagebreak,|,
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_buttons4 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : false,
        theme_advanced_resizing : false,

        // Example content CSS (should be your site CSS)
        content_css : "/striped/css/wysiwyg.css",
        
        setup : function(ed) {
            var bElm = 'P,DIV,ADDRESS,PRE,FORM,TABLE,OL,UL,CAPTION,BLOCKQUOTE,CENTER,DL,DIR,FIELDSET,NOSCRIPT,NOFRAMES,MENU,ISINDEX,SAMP';
            if (lang == 'ru') {
                var l_title = 'Разорвать страницу';
            } else if (lang == 'uk') {
                var l_title = 'Розірвати сторінку';
            } else if (lang == 'en') {
                var l_title = 'Cut page';
            }
            ed.addButton('pagebreak', {
                title : l_title,
                image : '/striped/images/smallcut-20.png',
                onclick : function() {
                    n = ed.selection.getNode();
                    n = ed.dom.getParent(n, bElm, 'BODY') || n;
                    
                    if(ed.dom.isBlock(n)){
                        r = ed.dom.create('hr');
                        p = ed.dom.getParent(r, bElm, 'BODY');
                        
                        n.parentNode.insertBefore(r, n.nextSibling);
                    }
                    ed.focus();
                }
            });
        }

    });
    
});
