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

    File:               get_bez_info_ajax.asp
    Description:        Ophalen van allerlei info om client-side data te hebben
    Parameters:         req_info:   "bez_freeprk"    --> requires "loc_key", "date_from" en "date_to"

    Context:
    Note:
    Sample:             appl/ALG/get_bez_info_ajax.asp?req_info=bez_freeprk&loc_key=1&date_from=1300168800000&date_to=57600000

*/ %>

<%
var JSON_Result = true;
%>

<!-- #include file="../Shared/common.inc"-->
<!-- #include file="./bez.inc" -->
<!-- #include file="../fac/faq.inc" -->

<%
var req_info = getQParam("req_info");
var result = {};
switch (req_info)
{
    case "bez_freeprk":
    {
        var loc_key = getQParamInt("loc_key");
        var date_from = getQParamDate("date_from");
        var date_to = getQParamDate("date_to");
        result = bez.bez_prkinfo(loc_key, date_from, date_to);
        result.init = getQParamInt("init", 0);
        break;
    }
    case "bez_fields":
    {
        var params = {};
        params.loc_key = getQParamInt("loc_key", -1);
        params.geb_key = getQParamInt("geb_key", -1);
        result = bez.bez_fields(params);
        break;
    }
    case "bez_nr_periods":
    {
        var params = { urole:     getQParam("urole"),
                       np:        getQParamInt("np"),
                       nextDate:  getQParamInt("nextDate"),
                       lastDate:  getQParamInt("lastDate"),
                       bits:      getQParamInt("bits")
                     }
        result = bez.bez_getnrperiods(params);
        break;
    }
    case "bez_new_dates":
    {
        var params = { urole:     getQParam("urole"),
                       np:        getQParamInt("np"),
                       nextDate:  getQParamInt("nextDate"),
                       bits:      getQParamInt("bits")
                     }
        result = bez.bez_getnewdates(params);
        break;
    }
    case "actiegroep":
    {
        var loc_arr = getQParamKeyArray("locatie_key", []);
        var bld_arr = getQParamKeyArray("gebouw_key", []);
        result = bez.bez_getacties(loc_arr, bld_arr, true).data;
        break;
    }
    case "faq_info":
    {
        var loc_key = getQParamInt("loc_key", -1);
        var alg_key_arr = getQParamIntArray("alg_key_arr", []);
        var changed = getQParamInt("changed", 2);
        var result = bez.faq_info(loc_key, alg_key_arr, changed);

        for (i in result.fixed_faq)
        {
            result.fixed_faq[i].safe_answer = safe.fclthtml(result.fixed_faq[i].answer, {"faqlink": true});
            result.fixed_faq[i].safe_answer2 = safe.fclthtml(result.fixed_faq[i].answer2, {"faqlink": true});
        }
        result.loc_key      = loc_key;
        result.alg_key_arr  = alg_key_arr;
        result.changed      = changed;
        break;
    }
    case "alg_algfaq_info":
    {
        var alg_key = getQParamInt("alg_key", -1);
        var loc_key = getQParamInt("loc_key", -1);
        var result = faq.alg_algfaq_info(loc_key, alg_key);
        break;
    }

}

Response.Write(JSON.stringify(result));
%>
<% ASPPAGE_END(); %>
