<%@language = "javascript" %>
<% /*
     $Revision$
     $Id$

    File:               fac_current_tab_save.asp
    Description:        SUBMIT-form

    Parameters:
    Context:
    Note:
*/
var JSON_Result = true;
%>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/json2.js" -->
<%
var autoopenurl = getFParam("autoopenurl");
var autoopenttl = getFParam("autoopenttl");
var filters = getFParam("filters", "");
var nowarning = getFParam("nowarning",0)==1;

if (autoopenurl.indexOf("../../") == 0)
    autoopenurl = autoopenurl.substr("../../".length + 1);

if (autoopenurl.indexOf(rooturl + "/") == 0)
    autoopenurl = autoopenurl.substr(rooturl.length + 1);

// GUI_counters wissen voor gepinde tabbladen
autoopenurl = autoopenurl.replace(/\&from_menu_key=\d+/, "");
autoopenurl = autoopenurl.replace(/\?from_menu_key=\d+/, "");
autoopenurl = autoopenurl.replace(/\&from_search_key=\d+/, "");
autoopenurl = autoopenurl.replace(/\?from_search_key=\d+/, "");

var autoopen = user.options("autoopen") || [];
var i;
var removed = false;
for (var i = 0; i < autoopen.length; i++)
{
    if (autoopen[i].u == autoopenurl ||
        autoopen[i].u == "/" + autoopenurl ||
        "/" + autoopen[i].u == autoopenurl ||
        autoopen[i].u == "../../" + autoopenurl)
    {
        autoopen.splice(i, 1);
        removed = true;
    }
}
result = { success: true, toaster: L("lcl_current_tab_unsaved")};
if (!removed)
{
    var props = { u: autoopenurl, t: autoopenttl, f: filters};
    if (filters)
        props.f = filters;

    autoopen.push(props);
    result.toaster = L("lcl_current_tab_saved");
    result.saved = true;
}
user.options("autoopen", autoopen);

if (nowarning)
    result.toaster = null;

Response.Write(JSON.stringify(result));
Response.End;
%>