
function jsAsk(msg, title, type)
{
    var WSHShell = WScript.CreateObject("WScript.Shell");
    return WSHShell.Popup(msg, 10000, title, type);
}

function loadMacroString(stringName)
{
    var macroAppGUID = "{85868504-1923-45c3-9ABD-3C03678278E9}";
    var objCAAutomation = new ActiveXObject("CyberArticle.CAAutomationApp");
    //
    return objCAAutomation.LoadMacroString(macroAppGUID, stringName);
}

function formatString0(msg)
{
    return loadMacroString(msg);
}
function formatString1(msg, param1)
{
    msg = formatString0(msg);
    msg = msg.replace("%1", param1);
    return msg;
}
function formatString2(msg, param1, param2)
{
    msg = formatString0(msg);
    msg = msg.replace("%1", param1);
    msg = msg.replace("%2", param2);
    return msg;
}

var objBookCollection = new ActiveXObject("CyberArticleBook.CABookCollection");

for (var i = objBookCollection.Count - 1; i >= 0; i--)
{
    var objBook = new ActiveXObject("CyberArticleBook.CABook");
    var guidBook = objBookCollection.GUID(i);
    try
    {
        objBook.Open(guidBook);
    }
    catch (e)
    {
        var bookname = objBookCollection.BookName(i);
        var msg = formatString1("PromptRemoveBook", bookname);
        //
        if (6 == jsAsk(msg, "CyberArticle", 4 + 32))
        {
            objBookCollection.Remove(i);
        }
    }
}

