﻿
function init_wysiwyg_editors() {
    tinyMCE.init({
        mode: "textareas",
        theme: "advanced",
        relative_urls: false,
        width: 600,
        height: 400,
        theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pastetext,pasteword,hr,removeformat,sub,sup",
        theme_advanced_buttons2: "search,replace,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
        theme_advanced_buttons3: "",
        theme_advanced_buttons4: ""
    });
}

function init_wysiwyg_editor(id) {
    tinyMCE.init({
        mode: "exact",
        theme: "advanced",
        elements: id,
        relative_urls: false,
        theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pastetext,pasteword,hr,removeformat,sub,sup",
        theme_advanced_buttons2: "search,replace,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
        theme_advanced_buttons3: "",
        theme_advanced_buttons4: ""
    });
}

function ShowDialog(text) {
    var dialog = $('<p><img style="margin: 6px" src="/content/admin/images/icons/info.gif"/>' + text + '</p>');
    dialog.dialog({
        width: 500,
        draggable: false,
        resizable: false,
        modal: true,
        overlay: {
            opacity: 0.5,
            background: "black"
        },
        hide: 'blind',
        open: function() {
            var d = $(this);
            setTimeout(function(event, ui) {
                d.dialog('close');
            }, 2000);
        }
    });
}

function ShowConfirm(text, callback) {
    var dialog = $('<p>' + text + '</p>');
    dialog.dialog({
        width: 500,
        modal: true,
        overlay: {
            opacity: 0.5,
            background: "black"
        },
        hide: 'blind',
        buttons: {
            'No': function() {
                $(this).dialog('close');
            },
            'Sì': function() {
                callback();
                $(this).dialog('close');
            }
        }
    });
}
function SvuotaDropDownList(id) {
    var ddl = document.getElementById(id);
    var numberOfOptions = ddl.length;
    for (i = 0; i < numberOfOptions; i++) {
        //Note: Always remove(0) and NOT remove(i)
        ddl.remove(0);
    }
}