﻿KaPrGraphSystem = function () { };


KaPrGraphSystem.prototype.RenderDataOnAtachChangeMas = true;

// nastaveni dat
KaPrGraphSystem.prototype.MasID = 0;
KaPrGraphSystem.prototype.RegionID = 0;
KaPrGraphSystem.prototype.ICOB = "";
KaPrGraphSystem.prototype.KartogramType = 0;

// nazvy nastavenych dat dat
KaPrGraphSystem.prototype.ICOBName = "";
KaPrGraphSystem.prototype.RegionName = "";
KaPrGraphSystem.prototype.MasName = "";

// divy pro rendering
KaPrGraphSystem.prototype.CityDivID = null;//  "city"; // ID DIVU obsahujici select s mesty zde je select s mesty
KaPrGraphSystem.prototype.CityInRegionDivID = null;// "regionCities"; // zde je select s mesty
KaPrGraphSystem.prototype.RegionDivID = null;//  "region"; // zde jsou radia s regiony
KaPrGraphSystem.prototype.MasDivID = null;//"mas";

// selecty nebo inputy s hodnotou
KaPrGraphSystem.prototype.CitySelectID = null; // "KaPrCity"; //ID selectu s mesty
KaPrGraphSystem.prototype.RegionInputName = null; //  "KaPrRegion"; //name inputu s regiony
KaPrGraphSystem.prototype.CityInRegionInputName = null;//  "KaPrCityInRegion"; //name inputu s mesty v regionu
KaPrGraphSystem.prototype.MasInputName = null;//   "KaPrMas"; // name inputu s MAS

// vlastni render funkce
KaPrGraphSystem.prototype.ClientRenderJs = null;
KaPrGraphSystem.prototype.ClientConfigJs = null;

// interni variables
KaPrGraphSystem.prototype.graphList = null;
KaPrGraphSystem.prototype.graphCount = 0;
KaPrGraphSystem.prototype.serverName = "www.katalogprojektu.eu";
KaPrGraphSystem.prototype.graphUrlList = new Array("ChartData/dleStavu.aspx", "ChartData/dlePrijemce.aspx", "ChartData/dleStavuLeader.aspx", "ChartData/dlePrijemceLeader.aspx", "projectList.aspx", "projectListLeader.aspx", "ChartData/dleUspesnosti.aspx", "../Mapy/kartogramSLD.aspx", "monitoring.aspx", "monitoringSPL.aspx", "Statistics/type1.aspx", "Statistics/type2.aspx");

// ClientConfig pripravi pole KaPrOneGraph objektu a ten pak posle sem
KaPrGraphSystem.prototype.SetupGraphs = function (_graphList) {
    if (_graphList == undefined) { alert("Chyba volani SetupGraphs - prazdny _graphList"); }
    else {
        this.graphList = _graphList;
        this.graphCount = _graphList.length;
    }
}

// dotahne potrebne js a css a pote zavola ClientConfig
KaPrGraphSystem.prototype.Init = function () {
    var localObject = this;
    if (localObject.ClientRenderJs == null) { localObject.ClientRenderJs = "http://" + localObject.serverName + "/js/JSON/ClientRender.js"; }
    if (localObject.ClientConfigJs == null) { localObject.ClientConfigJs = "http://" + localObject.serverName + "/js/JSON/ClientConfig.js"; }
    $.getScript(localObject.ClientConfigJs, function () {
        $.getScript(localObject.ClientRenderJs, function () {
            $.getScript("http://" + localObject.serverName + "/js/JSON/KaPrOneGraph.js", function () {
                $.getScript("http://" + localObject.serverName + "/js/jquery.formatCurrency-1.4.0/jquery.formatCurrency-1.4.0.min.js", function () {
                    $.getScript("http://" + localObject.serverName + "/js/jquery.formatCurrency-1.4.0/jquery.formatCurrency.cs-CZ.js", function () {
                        $('head').append('<link rel="stylesheet" href="http://' + localObject.serverName + '/styles/ChartData/pieChart.css" type="text/css" />');
                        try { ClientConfig(localObject); }
                        catch (err) { alert("Error description for ClientConfig: " + err.description + "\n\n"); }
                    });
                });
            });
        });
    });
}

// Url dat legendy daneho grafu - tabulky pod nim
KaPrGraphSystem.prototype.LegendUrl = function (_graphID) {
    var localObject = this;
    var ret = "";




    if (_graphID == 8) {
        ret += "http://" + localObject.serverName + "/Ajax/Mapy/kartogramSld.aspx?showSLD=0&KartogramType=" + localObject.KartogramType + "&";
    }
    else {
        if (_graphID >= 11 && _graphID <= 12) /* statistiky */{
            ret += "http://" + localObject.serverName + "/Ajax/JSON/" + localObject.graphUrlList[_graphID - 1] + "?show=legend" + "&"; ;
        }
        else {
            ret += "http://" + localObject.serverName + "/Ajax/JSON/" + localObject.graphUrlList[_graphID - 1] + "?";
        }
    }
    ret += "masID=" + localObject.MasID;
    if (localObject.RegionID > 0) {
        ret += "&regionID=" + localObject.RegionID;
    }
    if (localObject.ICOB != "" && localObject.ICOB != undefined) {
        ret += "&ICOB=" + localObject.ICOB;
    }

    if (_graphID == 5 || _graphID == 6) {//seznam projektu
        ret += localObject.getFilterParameters(_graphID);
    }
    if (_graphID == 8) {//kartogramy
        ret += localObject.getFilterParameters(_graphID);
    }

    if (_graphID == 9 || _graphID == 10) {//monitoring
        ret += localObject.getFilterParameters(_graphID);
    }

    if (_graphID == 11) {//statistiky
        ret += localObject.getFilterParameters(_graphID);
    }

    return ret;
}

// zkusime ze stranky nacist dalsi parametry hledani
KaPrGraphSystem.prototype.getFilterParameters = function (_graphID) {
    var name = "";
    var input = "";
    var ret = "";
    name = "kaPrProjectID"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "kaPrProjectName"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "kaPrProjectUserCompany"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "kaPrProjectUserICO"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "kaPrRealisationDateFrom"; input = $('input[name="' + name + '"]').val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "kaPrRealisationDateTo"; input = $('input[name="' + name + '"]').val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "kaPrProjectRealisationFinishDateFrom"; input = $('input[name="' + name + '"]').val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "kaPrProjectRealisationFinishDateTo"; input = $('input[name="' + name + '"]').val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "kaPrSupplicationDateTimeFrom"; input = $('input[name="' + name + '"]').val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "kaPrSupplicationDateTimeTo"; input = $('input[name="' + name + '"]').val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "KaPrReadness"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "KaPrChallenge"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "KaPrChallengeMas"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "KaPrFiche"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "KaPrSpl"; input = $('input[name="' + name + '"]:checked').val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "KaPrProjectType"; input = $('input[name="' + name + '"]:checked').val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "KaPrRequestType"; input = $('input[name="' + name + '"]:checked').val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "KaPrLegalForm"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    name = "KaPrProgramProvider";
    if ($('select[name="' + name + '"]')) {
        input = $('select[name="' + name + '"]').val();
        if (input != undefined && input != "") {
            var input2 = input.split(/[_]+/);
            if (input2.length == 2)
            { ret += "&KaPrProvider=" + escape(input2[0]) + "&KaPrProgram=" + escape(input2[1]); }
        }
    }
    name = "KaPrProvider"; input = $("#" + name).val(); if (input != undefined && input != "") { ret += "&" + name + "=" + escape(input); }
    return ret;
}

// Url obrazku daneho grafu
KaPrGraphSystem.prototype.ImageUrl = function (_graphID) {
    var localObject = this;
    var ret = "";
    //var _bbox = ["-758905,-1114554,-684383,-1054428", "#99ccff", "-828005,-1065077,-753483,-1004952", "#0099cc", "#006699", "", ""];
    var _bbox = ["-758905,-1114554,-684383,-1054428", "NA", "-830519,-1064548,-755997,-1004422", "-885905,-1080493,-811383,-1020367", "-717701,-986690,-643179,-926564", "-661362,-1091712,-586840,-1031586", "-739732,-1079999,-665210,-1019873"];
    //-830519, -1064548, -755997, -1004422

    if (_graphID == 11 || _graphID == 12) {
        ret += "http://" + localObject.serverName + "/Ajax/JSON/" + localObject.graphUrlList[_graphID - 1] + "?GraphID=" + _graphID;

        if (localObject.MasID> 0) {
            ret += "&MasID=" + localObject.MasID;
        }

        if (localObject.RegionID > 0) {
            ret += "&regionID=" + localObject.RegionID;
        }
        if (localObject.ICOB != "" && localObject.ICOB != undefined) {
            ret += "&ICOB=" + localObject.ICOB;
        }
        return ret;
    }


    if (_graphID == 8) {
        ret += "http://www.bnhelp.cz/ows/posazavi?service=WMS&version=1.1.1&request=GetMap&layers=obce,lobce&SRS=EPSG:2065&width=700&height=525&format=image/gif&bbox=" + _bbox[localObject.MasID - 1] + "&sld=http://www.katalogprojektu.eu/ajax/mapy/kartogramSld.aspx?showSLD=1%26masID=" + localObject.MasID + "%26KartogramType=" + localObject.KartogramType + localObject.getFilterParameters(_graphID).replace(/&/g, "%26");
    }
    else {
        ret += "http://" + localObject.serverName + "/ajax/json/PieChart.aspx?dataUrl=http://" + localObject.serverName + "/Ajax/JSON/" + localObject.graphUrlList[_graphID - 1] + "%3FmasID=" + localObject.MasID
    }

    if (localObject.RegionID > 0) {
        ret += "%26regionID=" + localObject.RegionID;
    }
    if (localObject.ICOB != "" && localObject.ICOB != undefined) {
        ret += "%26ICOB=" + localObject.ICOB;
    }
    ret += "&SubTitle=" + localObject.GraphSubTitle();

    return ret;
}

KaPrGraphSystem.prototype.GetGraph = function () {
    var localObject = this;

    $.each(this.graphList, function (counter, _oneGraph) {
        if (_oneGraph.ImageID != null) {
            $("#" + _oneGraph.ImageID).attr("src", "http://www.posazavi.com/images/ajax-loader.gif");
            //alert("vypinam " + _oneGraph.ImageID);
            $("#" + _oneGraph.ImageID).css("margin", "50px");
            $("#" + _oneGraph.ImageID).attr("usemap", null);
        }
    });

    $.each(this.graphList, function (counter, _oneGraph) {
        var localObject2 = localObject;
        var _oneGraph2 = _oneGraph;
        if (_oneGraph2.ImageID != null) {
            //alert("zapinam " + _oneGraph2.ImageID);
            // Insert preloaded image after it finishes loading
            $('<img />').attr('src', localObject2.ImageUrl(_oneGraph2.graphID)).load(function () {
                //$('.profile').append($(this));
                //alert("loaded");
                $("#" + _oneGraph2.ImageID).attr("src", $(this).attr("src"));
                $("#" + _oneGraph.ImageID).css("margin", "0px");
                // Your other custom code
            });
            //$("#" + _oneGraph2.ImageID).attr("src", localObject2.ImageUrl(_oneGraph2.graphID));
            //$("#" + _oneGraph.ImageID).css("margin", "0px");
        }
        if (_oneGraph2.MapID != null) {
            var mapUrl = localObject2.MapUrl(_oneGraph2.graphID);
            $.getJSON(mapUrl + "&format=json&jsoncallback=?", {}, function (jsonData) {
                var localObject3 = localObject2;
                $("#" + _oneGraph2.MapID).empty();
                $("#" + _oneGraph2.MapID).append(localObject3.DecodeHtmlMap(jsonData.html));
                if (_oneGraph2.ImageID != null) {
                    $("#" + _oneGraph2.ImageID).attr("usemap", "#" + _oneGraph2.MapID);
                }
            });
        }
    });
}

KaPrGraphSystem.prototype.GetKartogram = function () {
    var localObject = this;
    $.each(localObject.graphList, function (counter, _oneGraph) {
        if (_oneGraph.ImageID != null) {
            $("#" + _oneGraph.ImageID).attr("src", "http://www.posazavi.com/images/ajax-loader.gif");
            $("#" + _oneGraph.ImageID).css("display", "inline");
            $("#" + _oneGraph.ImageID).css("margin", "50px");
            $("#" + _oneGraph.ImageID).attr("usemap", null);
        }
    });

    $.each(this.graphList, function (counter, _oneGraph) {
        var _oneGraph2 = _oneGraph;
        if (_oneGraph2.ImageID != null) {
            $("#" + _oneGraph2.ImageID).attr("src", localObject.ImageUrl(_oneGraph2.graphID));
            $("#" + _oneGraph.ImageID).css("margin", "0px");
        }
    });
}

KaPrGraphSystem.prototype.GetKartogramLegend = function () {
    var localObject = this;
    $.each(this.graphList, function (counter, _oneGraph) {
        $("#" + _oneGraph.LegendID).empty();
        $("#" + _oneGraph.LegendID).html('<img src="http://www.posazavi.com/images/ajax-loader.gif">');
    });

    $.each(this.graphList, function (counter, _oneGraph) {
        $.getJSON(localObject.LegendUrl(_oneGraph.graphID) + "&format=json&jsoncallback=?", {}, function (jsonData) {
            var localObject2 = localObject;
            var _oneGraph2 = _oneGraph;
            $("#" + _oneGraph2.LegendID).empty();
            if (_oneGraph2.graphID != 5 && _oneGraph2.graphID != 6) {
                var _legendID = _oneGraph2.LegendID;
                var _data = jsonData;
                var _title = localObject2.GraphSubTitle();
                try {
                    RenderGraphLegend(_legendID, _data, _title);
                }
                catch (err) {
                    alert("chyba volani RenderGraphLegend: " + err.Description);
                }
            }
            else {
                alert("N/I");
            }
        });
    });

}


KaPrGraphSystem.prototype.GetLegend = function () {
    var localObject = this;

    $.each(this.graphList, function (counter, _oneGraph) {
        $("#" + _oneGraph.LegendID).empty();
        $("#" + _oneGraph.LegendID).html('<img src="http://www.posazavi.com/images/ajax-loader.gif">');
    });

    $.each(this.graphList, function (counter, _oneGraph) {
        var localObject2 = localObject;
        var _oneGraph2 = _oneGraph;
        var url = localObject.LegendUrl(_oneGraph.graphID);
        $.getJSON(url + "&format=json&jsoncallback=?", {}, function (jsonData) {
            $("#" + _oneGraph2.LegendID).empty();
            if (_oneGraph2.graphID != 5 && _oneGraph2.graphID != 6 && _oneGraph2.graphID != 9 && _oneGraph2.graphID != 10) {
                RenderGraphLegend(_oneGraph2.LegendID, jsonData, localObject.GraphSubTitle());
            }
            else {
                if (_oneGraph2.graphID == 9 || _oneGraph2.graphID == 10) {
                    RenderMonitoring(_oneGraph2.LegendID, jsonData);
                }
                else {
                    RenderProject(_oneGraph2.LegendID, jsonData);
                }
            }
        });
    });
}

// Url imagemapy daneho grafu
KaPrGraphSystem.prototype.MapUrl = function (graphIndex) {
    var ret = "";
    var localObject = this;

    if (graphIndex == 11 || graphIndex == 12) {
        ret += "http://" + localObject.serverName + "/Ajax/JSON/" + localObject.graphUrlList[graphIndex - 1] + "?GraphID=1";

        if (localObject.MasID > 0) {
            ret += "&MasID=" + localObject.MasID;
        }

        if (localObject.RegionID > 0) {
            ret += "&regionID=" + localObject.RegionID;
        }
        if (localObject.ICOB != "" && localObject.ICOB != undefined) {
            ret += "&ICOB=" + localObject.ICOB;
        }
        return ret;
    }


    ret += "http://" + localObject.serverName + "/Ajax/JSON/PieChart.aspx?mapName=1&dataUrl=";
    ret += "http://" + localObject.serverName + "/Ajax/JSON/" + localObject.graphUrlList[graphIndex - 1] + "%3FmasID=" + localObject.MasID
    if (localObject.RegionID > 0 && localObject.RegionID != undefined) {
        ret += "%26regionID=" + localObject.RegionID;
    }
    if (localObject.ICOB != "" && localObject.ICOB != undefined) {
        ret += "%26ICOB=" + localObject.ICOB;
    }
    return ret;
}

// Vola se pri zmene vyberu - MasID, RegionID, ICOB
KaPrGraphSystem.prototype.FillConfig = function () {
    this.ICOBName = "";
    this.ICOB = $("#" + this.CitySelectID + " option:selected").val();
    if (this.ICOB != "") { this.ICOBName = $("#" + this.CitySelectID + " option:selected").text(); }

    if ($("input[name='" + this.CityInRegionInputName + "']:checked").length > 0) {
        var _cityInRegion = $("input[name='" + this.CityInRegionInputName + "']:checked")[0].value;
        if (_cityInRegion != "") {
            this.ICOB = _cityInRegion;
            this.ICOBName = $("#l" + $("input[name='" + this.CityInRegionInputName + "']:checked")[0].id).text();
        }
    }

    if (this.RegionInputName != null) {
        this.RegionID = 0;
        this.RegionName = "";
        if ($("input[name='" + this.RegionInputName + "']:checked").length > 0) {
            this.RegionID = parseInt($("input[name='" + this.RegionInputName + "']:checked")[0].value);
            if (this.RegionID > 0) { this.RegionName = $("#l" + $("input[name='" + this.RegionInputName + "']:checked")[0].id).text(); }
        }
    }

    if (this.MasInputName != null) {
        if ($("input[name='" + this.MasInputName + "']:checked").length > 0) {
            this.MasID = parseInt($("input[name='" + this.MasInputName + "']:checked")[0].value);
            this.MasName = $("#l" + $("input[name='" + this.MasInputName + "']:checked")[0].id).text();
        }
        else {
            this.MasID = 0;
            this.MasName = "";
        }
    }
}


KaPrGraphSystem.prototype.GraphSubTitle = function () {
    if (this.ICOB != "" && this.ICOB != undefined) { return this.ICOBName; }
    if (this.RegionID != 0) { return this.RegionName; }
    if (this.MasID != 0) { return this.MasName; }
    return "všechny MAS";
}

KaPrGraphSystem.prototype.AttachChangeSelectCity = function () {
    var localObject = this;
    $("#" + localObject.CitySelectID).change(function () {
        var localObject2 = localObject;
        try { SelectedCity(localObject2); } catch (err) { alert("Event Chyba\n\nError description: " + err.message + "\n\n"); }
        localObject2.FillConfig();
        if (localObject2.RenderDataOnAtachChangeMas) {
            localObject2.GetGraph();
            localObject2.GetLegend();
        }
    });
}

KaPrGraphSystem.prototype.RenderCities = function () {
    if (this.CityDivID != null) {
        var localObject = this;
        if (this.MasID > 0) {
            $.getJSON("http://" + this.serverName + "/ajax/JSON/cities.aspx?masID=" + this.MasID + "&format=json&jsoncallback=?", {}, function (jsonData) {
                RenderCity(localObject.CityDivID, jsonData.KaPrCities);
                localObject.AttachChangeSelectCity();
            });
        }
        else {
            RenderCity(localObject.CityDivID, "");
        }
    }
    else {
        alert("RenderCities - neni zadano CityDivID");
    }
}

KaPrGraphSystem.prototype.RenderRegions = function () {
    if (this.RegionDivID != null) {
        var localObject = this;
        $.getJSON("http://" + this.serverName + "/ajax/JSON/microRegions.aspx?masID=" + this.MasID + "&format=json&jsoncallback=?", {}, function (jsonData) {
            try { RenderRegion(localObject.RegionDivID, jsonData.KaPrMicroRegions); }catch (err) { alert("Render Chyba\n\nError description: " + err.message + "\n\n"); }
            localObject.AttachChangeInputRegion();
        });
    }
    else {
        alert("RenderRegions - neni zadano RegionDivID");
    }
}

KaPrGraphSystem.prototype.RenderMases = function (preSelectOnInit) {
    var localObject = this;
    $.getJSON("http://" + this.serverName + "/ajax/JSON/MASs.aspx?format=json&jsoncallback=?", {}, function (jsonData) {

        try {
            RenderMas(localObject.MasDivID, jsonData.KaPrMas);
        }
        catch (err) {
            alert("RenderMas Chyba\n\nError description: " + err.message + "\n\n");
        }

        localObject.AttachChangeInputMas();
        if (preSelectOnInit && localObject.MasID > 0) {
            $("#KaPrMas" + localObject.MasID).attr("checked", "true");
            $("#KaPrMas" + localObject.MasID).click();
        }

    });
}

KaPrGraphSystem.prototype.AttachChangeInputMas = function () {
    var localObject = this;
    $("input[name='" + localObject.MasInputName + "']").click(function () {
        var localObject2 = localObject;
        SelectedMas(localObject2);
        localObject2.FillConfig();
        if (localObject2.RegionDivID != null) { localObject2.RenderRegions(); }
        if (localObject2.CityInRegionDivID != null) { localObject2.RenderCitiesInRegion(); }
        if (localObject2.CityDivID != null) { localObject2.RenderCities(); }
        if (localObject2.RenderDataOnAtachChangeMas) {
            localObject2.GetGraph();
            localObject2.GetLegend();
        }
    });
}


KaPrGraphSystem.prototype.RenderCitiesInRegion = function () {
    if (this.CityInRegionDivID != null) {
        var localObject = this;
        if (this.RegionID > 0) {
            $.getJSON("http://" + this.serverName + "/ajax/JSON/cities.aspx?masID=" + this.MasID + "&regionID=" + this.RegionID + "&format=json&jsoncallback=?", {}, function (jsonData) {
                var localObject2 = localObject;
                RenderCityInRegion(localObject2.CityInRegionDivID, jsonData.KaPrCities);
                if ($("#" + localObject2.CityInRegionInputName + "0").length > 0) {
                    $("#" + localObject2.CityInRegionInputName + "0").attr('checked', true);
                }
                localObject2.AttachChangeInputCityInRegion();
            });
        }
        else {
            RenderCityInRegion(this.CityInRegionDivID, "");
        }
    }
    else {
        alert("RenderCitiesInRegion - neni zadano CityInRegionDivID");
    }
}

KaPrGraphSystem.prototype.AttachChangeInputCityInRegion = function () {
    var localObject = this;
    $("input[name='" + localObject.CityInRegionInputName + "']").click(function () {
        var localObject2 = localObject;

        if (localObject2.RegionInputName != null) {
            localObject2.RegionID = 0;
        }
        if (localObject2.CitySelectID != null) {
            $("#" + localObject2.CitySelectID).val("");
            localObject2.ICOB = "";
        }

        SelectedCityInRegion(localObject2);

        localObject2.FillConfig();
        if (localObject2.RenderDataOnAtachChangeMas) {
            localObject2.GetGraph();
            localObject2.GetLegend();
        }
    });
}


KaPrGraphSystem.prototype.AttachChangeInputRegion = function () {
    var localObject = this;
    $("input[name='" + localObject.RegionInputName + "']").click(function () {
        var localObject2 = localObject;
        try { SelectedRegion(localObject2); } catch (err) { alert("Render SelectedRegion Chyba\n\nError description: " + err.message + "\n\n"); }
        localObject2.FillConfig();
        if (localObject2.CityInRegionInputName != null) { localObject2.RenderCitiesInRegion(); }
        if (localObject2.RenderDataOnAtachChangeMas) {
            localObject2.GetGraph();
            localObject2.GetLegend();
        }
    });
}


KaPrGraphSystem.prototype.DecodeHtmlMap = function (html) {
    var re = /\_/g;
    html = html.replace(re, "&");
    re = /&lt;/g;
    html = html.replace(re, "<");
    re = /&gt;/g;
    html = html.replace(re, ">");
    re = /&quot;/g;
    html = html.replace(re, "\"");
    re = /&#39;/g;
    html = html.replace(re, "'");
    return html;
}
    




