<?php
    session_start();
    if(!isset($_SESSION['user']))
    {
        header('location:index.php');
    }
    include('config.php');
    $user_name = $_SESSION['user'];
?>

<!DOCTYPE html>
<html lang="en" class="light-style customizer-hide">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
        <title>Emerald Dashboard</title>
        <meta name="description" content="" />
        <!-- Fonts -->
        <link rel="preconnect" href="https://fonts.googleapis.com" />
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
        <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
        <link href="assets/css/main.d810cf0ae7f39f28f336.css" rel="stylesheet">
        <link href="assets/css/animate.css" rel="stylesheet">
        <link href="assets/css/animate.min.css" rel="stylesheet">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/fontawesome.min.css" integrity="sha512-d0olNN35C6VLiulAobxYHZiXJmq+vl+BGIgAxQtD5+kqudro/xNMvv2yIHAciGHpExsIbKX3iLg+0B6d0k4+ZA==" crossorigin="anonymous" referrerpolicy="no-referrer" /> -->
        <link rel="stylesheet" href="assets/select2/select2.min.css">
        <link rel="stylesheet" href="https://cdn.datatables.net/2.0.3/css/dataTables.dataTables.css" />
        <script type="text/javascript" src="assets/scripts/jquery.min.js"></script>
        <link rel="stylesheet" href="assets/css/styleX.css">

        <style>
            .top_col
            {
                max-width:100px !important;
            }
            .offscreen {
            position: absolute;
            top: -10000px;
            left: -10000px;
            visibility: hidden;
        }
        #ppt_frame
        {
            position: absolute;
            top: 0px;
            /* z-index: 999999; */
            width: 100%;
            height: 100%;
            display:none;
        }
        iframe
        {
            width: 100%;
            height: 100%;
        }
        .left-section, .right-section {
            max-height: 430px; /* Adjust height as needed */
            overflow-y: auto;
        }

        /* .pr2, .pr4 {
            padding-right: 15px;
        } */

        .cardBg {
            background-color: #FFFFFF; /* Adjust to match your theme */
            border: 1px solid #ddd;
            border-radius: 5px;
            padding: 5px;
        }
        .card-header>.nav {
            margin-left: 0rem !important;
            height: 100%;
            width: 100%;
        }
        .card-header {
            height: 2.5rem;
        }
        .nav-link {
            display: block;
            padding: .2rem 1rem;
        }
        .female_selected_shadow
        {
            filter: drop-shadow(0px 10px 7px #FF94D4);
        }
        .male_selected_shadow
        {
            filter: drop-shadow(0px 10px 7px #8BCAFF);
        }
        </style>
    </head>

    <body>
        <div class="app-container app-theme-white body-tN-shadow fixed-sidebar fixed-header" id="app-containerX">
            <div class="app-header header-shadow" style="height:30px">
                <div class="app-header__logo" style="background-color:white">
                    <button class="openbtn" id="openbtn" data-status="1" onclick="tabSidebar()"><i class="fa fa-bars" aria-hidden="true"></i></button>
                    <!-- <button class="openbtn" id="filterbtn" onclick="filterS(this)" data-value="1"><i class="fa fa-filter" aria-hidden="true"></i></button> -->
                    <div class="logo-src ml-2">
                        <img src="assets/images/nlogo2.png" style="width:80%;margin-top:3%">
                    </div>
                    
                </div>
                <div class="app-header__mobile-menu">
                    <div>
                        <button type="button" class="hamburger hamburger--elastic mobile-toggle-nav">
                        <span class="hamburger-box">
                        <span class="hamburger-inner"></span>
                        </span>
                        </button>
                    </div>
                </div><!-- app-header mobile menu div-->
                <div class="app-header__menu">
                    <span>
                        <button type="button" class="btn-icon btn-icon-only btn btn-primary btn-sm mobile-toggle-header-nav">
                        <span class="btn-icon-wrapper">
                        <i class="fa fa-ellipsis-v fa-w-6"></i>
                        </span>
                        </button>
                    </span>
                </div><!-- app-header menu div-->
                <div class="app-header__content" style="background-color:white">
                    <div class="app-header-left"></div>
                    <div class="app-header-right">
                        <?php
                            // foreach($airportFF as $key => $value)
                            // {
                            //     echo '
                            //         <button type="button" class="btn-transition btn btn-outline-primary btn-sm vocnot mr-1 mt-3"
                            //             onclick="exportExcelFlag();" data-toggle="tooltip" data-placement="bottom" title=""
                            //             data-original-title="Export Excel" style="height:35px">
                            //             '.$value.'
                            //         </button>
                            //     ';
                            // }
                        ?>
                        <!--<div class="popup-btn mr-1 mt-3" style="margin-top:10px">-->
                        <!--    <a href="javascript:void(0)" onclick="openF()" id="filter_div" >-->
                        <!--        FILTERS-->
                        <!--    </a>-->
                        <!--</div>-->
                        <!--<button type="button" class="btn-transition btn btn-outline-primary btn-sm btn-brand mr-1 mt-3" data-value="Tbl" onclick="swapTable(this);" style="height:35px;cursor:pointer;margin-right:10px;display:none" id="swap_tbl_btn">-->
                        <!--    Show Table-->
                        <!--</button>-->
                        <!--<button type="button" class="btn-transition btn btn-outline-primary btn-sm vocnot mr-1 mt-3"-->
                        <!--    onclick="exportExcelFlag();" data-toggle="tooltip" data-placement="bottom" title=""-->
                        <!--    data-original-title="Export Excel" style="height:35px;width:35px">-->
                        <!--    <img src="assets/images/excel.png" height="25" width="20" />-->
                        <!--</button>-->
                        <button type="button" class="btn-transition btn btn-outline-primary btn-sm logout_btns mt-3" onclick="logout();"
                            data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Logout"
                            style="height:35px;width:35px">
                            <img src="assets/images/logout.png" height="20" width="20" />
                        </button>
                    </div>
                </div><!-- app-header content-->
            </div><!-- app-header div-->
            <div id="mySidebar" class="sidebar">
                <?php include("tabs.php"); ?>
            </div>
            <div class="app-main" id="main">
                <div class="splash">
                    <div class="splash-title">
                        <div class="spinner">

                        </div>
                    </div>
                </div>
                <div class="app-main__outer" style="background-color: #E4ECF3;" onclick="closeF()">

                    <div class="app-main__inner" style="padding: 0px;padding-right:15px">
                        <div class="tab-content">
                            <div class="card cardXX pr3" style="background-color:#FFFFFF;">
                                <div class="row">
                                    <div class="col-md-4">
                                        <h6 class="ml-2 mt-2"><b style="font-weight: 500;color:#000000" id="activetabname">Profiling | Overall Level Base</b></h6>
                                    </div>
                                    <div class="col-md-5" style="text-align:end">
                                    </div>
                                    <div class="col-md-3" id="overallBase" style="text-align:right;margin-left:-9px">
                                    </div>
                                </div>
                            </div>
                            <div class="card cardXX mt-2 pr3" style="background-color:#FFFFFF;" id="filterdefination_div">
                                <div class="row" id="filterdefination_overall_div">
                                    <div class="col-md-12">
                                        <textarea class="paraX" style="height:auto;max-width:200px;word-wrap:break-word;display:none">Filters:All Selected</textarea>
                                        <h6 class="ml-2 mt-2 paraY" style="height:auto;color:#000000;font-size:0.9rem">Filters:All Selected</h6>
                                    </div>
                                </div>
                                <div class="row" id="filterdefination_trend_div" style="display:none">
                                    <div class="col-md-12">
                                        <p class="ml-2 mt-3 paraYT" style="height:auto;color:#000000">Filters:All Selected</p>
                                    </div>
                                </div>
                            </div>

<!----------------------------------------------------- OUTER TAB START ------------------------------------------------------------------>

<!----------------------------------------------------- OUTER TAB 1 INNER TAB 1 START ---------------------------------------------------->

<div class="tab-pane active custom-tab-pane1" id="tab-eg7-0-0" role="tabpanel" data-status="active">
    <?php include "tab1.php"; ?>
    <div class="footerX mt-2"></div>
</div>

<!----------------------------------------------------- OUTER TAB 1 INNER TAB 1 END ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 1 START ---------------------------------------------------->

<div class="tab-pane custom-tab-pane2" id="tab-eg7-1-0" role="tabpanel" data-status="inactive">
    <div class="tab-content">
        <div class="row mt-2">
            <div class="col-lg-9"></div>
            <div class="col-lg-3">
                <div class="card cardXX d-flex position-relative flex-column cardBg pr3" style="margin-right:4%">
                    <ul class="nav nav-justified subtabs">
                        <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-0" class="nav-link active">Shopper</a></li>
                        <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-1" class="nav-link">Non-Shopper</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="tab-pane active" id="tab-eg9-0" role="tabpanel">
            <?php include "dutyfree_s.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-1" role="tabpanel">
            <?php include "dutyfree_ns.php"; ?>
        </div>
        <div class="footerX mt-2"></div>
    </div>
</div>

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 1 END ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 2 START ---------------------------------------------------->

<div class="tab-pane custom-tab-pane2" id="tab-eg7-1-1" role="tabpanel" data-status="inactive">
    <div class="card-header cardXX cardBg pr3 mt-2">
        <ul class="nav nav-justified">
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-2" class="nav-link active">Shopper</a></li>
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-3" class="nav-link">Non-Shopper</a></li>
        </ul>
    </div>
    <div class="tab-content">
        <div class="tab-pane active" id="tab-eg9-2" role="tabpanel">
            <?php include "fnb_s.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-3" role="tabpanel">
            <?php include "fnb_ns.php"; ?>
        </div>
        <div class="footerX mt-2"></div>
    </div>
</div>

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 2 END ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 3 START ---------------------------------------------------->

<div class="tab-pane custom-tab-pane2" id="tab-eg7-1-2" role="tabpanel" data-status="inactive">
    <div class="card-header cardXX cardBg pr3 mt-2">
        <ul class="nav nav-justified">
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-4" class="nav-link active">Shopper</a></li>
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-5" class="nav-link">Non-Shopper</a></li>
        </ul>
    </div>
    <div class="tab-content">
        <div class="tab-pane active" id="tab-eg9-4" role="tabpanel">
            <?php include "retail_s.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-5" role="tabpanel">
            <?php include "retail_ns.php"; ?>
        </div>
        <div class="footerX mt-2"></div>
    </div>
</div>

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 3 END ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 4 START ---------------------------------------------------->

<div class="tab-pane custom-tab-pane2" id="tab-eg7-1-3" role="tabpanel" data-status="inactive">
    <div class="card-header cardXX cardBg pr3 mt-2">
        <ul class="nav nav-justified">
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-6" class="nav-link active">Shopper</a></li>
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-7" class="nav-link">Non-Shopper</a></li>
        </ul>
    </div>
    <div class="tab-content">
        <div class="tab-pane active" id="tab-eg9-6" role="tabpanel">
            <?php include "pranaam_s.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-7" role="tabpanel">
            <?php include "pranaam_ns.php"; ?>
        </div>
        <div class="footerX mt-2"></div>
    </div>
</div>

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 4 END ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 5 START ---------------------------------------------------->

<div class="tab-pane custom-tab-pane2" id="tab-eg7-1-4" role="tabpanel" data-status="inactive">
    <div class="card-header cardXX cardBg pr3 mt-2">
        <ul class="nav nav-justified">
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-8" class="nav-link active">Shopper</a></li>
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-9" class="nav-link">Non-Shopper</a></li>
        </ul>
    </div>
    <div class="tab-content">
        <div class="tab-pane active" id="tab-eg9-8" role="tabpanel">
            <?php //include "gtb_s.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-9" role="tabpanel">
            <?php //include "gtb_ns.php"; ?>
        </div>
    </div>
</div>

<!----------------------------------------------------- OUTER TAB 2 INNER TAB 5 END ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 3 INNER TAB 1 START ---------------------------------------------------->

<div class="tab-pane custom-tab-pane3" id="tab-eg7-2-0" role="tabpanel" data-status="inactive">
    <div class="card-header cardXX cardBg pr3 mt-2">
        <ul class="nav nav-justified">
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-10" class="nav-link active">F&B</a></li>
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-11" class="nav-link">Retail</a></li>
        </ul>
    </div>
    <div class="tab-content">
        <div class="tab-pane active" id="tab-eg9-10" role="tabpanel">
            <?php include "meeter_greeter_s_fb.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-11" role="tabpanel">
            <?php include "meeter_greeter_s_r.php"; ?>
        </div>
    </div>
</div>

<!----------------------------------------------------- OUTER TAB 3 INNER TAB 1 START ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 3 INNER TAB 2 START ---------------------------------------------------->

<div class="tab-pane custom-tab-pane3" id="tab-eg7-2-1" role="tabpanel" data-status="inactive">
    <div class="card-header cardXX cardBg pr3 mt-2">
        <ul class="nav nav-justified">
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-12" class="nav-link active">F&B</a></li>
            <li class="nav-item"><a data-toggle="tab" href="#tab-eg9-13" class="nav-link">Retail</a></li>
        </ul>
    </div>
    <div class="tab-content">
        <div class="tab-pane active" id="tab-eg9-12" role="tabpanel">
            <?php include "meeter_greeter_ns_fb.php"; ?>
        </div>
        <div class="tab-pane" id="tab-eg9-13" role="tabpanel">
            <?php include "meeter_greeter_ns_r.php"; ?>
        </div>
    </div>
</div>

<!----------------------------------------------------- OUTER TAB 3 INNER TAB 2 START ---------------------------------------------------->

<!----------------------------------------------------- OUTER TAB 4 INNER TAB 1 START ---------------------------------------------------->

<div class="tab-pane custom-tab-pane4" id="tab-eg7-3-0" role="tabpanel" data-status="inactive">
    <?php include "media_habit.php"; ?>
</div>


<!----------------------------------------------------- OUTER TAB 4 INNER TAB 1 START ---------------------------------------------------->


<!----------------------------------------------------- OUTER TAB END -------------------------------------------------------------------->
                        </div> <!-- tab-content -->
                    </div><!-- app-main inner-->
                </div><!-- app-main outer-->
            </div><!-- app-main div-->
        </div><!-- app-container div-->
        

        <div class="card animate__animated animate__fadeInDown" id="alert_div" style="display:none">
            <h6>Excel export is getting downloaded !!</h6>
        </div>
        <div class="card animate__animated animate__fadeInDown" id="alert_div2" style="display:none">
            <h6>Excel export is downloaded successfully !!</h6>
        </div>

        <div class="card animate__animated animate__fadeInDown" id="alert_div3" style="display:none">
            <h6>PPT export is getting downloaded !!</h6>
        </div>
        <div class="card animate__animated animate__fadeInDown" id="alert_div4" style="display:none">
            <h6>PPT export is downloaded successfully !!</h6>
        </div>

        <!-- <div class="popup-btn trends" onclick="trends(1)" id="trends_open_div">
            <a href="javascript:void(0)">
                TRENDS
            </a>
        </div>
        <div class="popup-btn trends" onclick="trends(2)" id="trends_close_div" style="display:none">
            <a href="javascript:void(0)">
                GO BACK
            </a>
        </div> -->
        <div id="mySidebar2" class="sidebar2">
            <a href="javascript:void(0)" class="closebtn" onclick="closeF()">×</a>
            <ul class="vertical-nav-menu mb-5" style="padding:0px 20px 20px 20px !important;font-family: 'Roboto', sans-serif" id="filterX">
                <?php include('filter.php');?>
            </ul>
        </div>

        <div id="ppt_frame">
            
        </div>
        
        <script type="text/javascript" src="assets/scripts/main.d810cf0ae7f39f28f336.js"></script>
        <script type="text/javascript" src="assets/select2/select2.min.js"></script>
        <script async defer src="https://buttons.github.io/buttons.js"></script>
        <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
	    <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
        <script src="https://cdn.datatables.net/2.0.3/js/dataTables.js"></script>
        <script src="assets/wizard/js/jquery.steps.js"></script>
	    <script src="assets/wizard/js/main.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.js"></script>
        <!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.min.js.map"></script> -->
        <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/modules/variable-pie.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/highcharts-more.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/modules/exporting.js"></script>
        <script type="text/javascript" src="https://code.highcharts.com/modules/offline-exporting.js"></script>
        <!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/linways/table-to-excel@v1.0.4/dist/tableToExcel.js"></script> -->
        <script lang="javascript" src="https://cdn.sheetjs.com/xlsx-0.20.1/package/dist/xlsx.full.min.js"></script>
        <script type="text/javascript" src="https://keresearch.in/demoDash/assets/code/modules/heatmap.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/pptxgenjs@3.3.1/dist/pptxgen.bundle.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/pptxgenjs/3.8.0/pptxgen.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
        <script src="https://code.highcharts.com/highcharts-more.js"></script>
        <script src="https://code.highcharts.com/maps/modules/map.js"></script>
        <script src="https://code.highcharts.com/maps/modules/exporting.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/pptxgenjs@3.3.1/dist/pptxgen.bundle.js"></script>

        <script>

            var condX = ``;
            var trendcondX = ``;
            var conX = ``;
            var filtercondX = ``;
            var trendsfiltercondX = ``;
            var tabsName = `Profiling`;
            var subtabsName = ``;
            var subtabsSerial = ``;
            var overallBase = ``;
            var statusArr = [[],[],[],[]];
            
            var monthTxt = [];
            var dayTxt = [];
            var dayTypeTxt = [];
            var cityTxt = [];
            var genderTxt = [];
            var ageTxt = [];
            var terminalTxt = [];
            var travellerTxt = [];
            var incomeTxt = [];
            var domestictripTxt = [];
            var internationaltripTxt = [];
            var rotTxt = [];
            var segmentTxt = [];

            var typesTxt = [];
            var dwellDTxt = [];
            var dwellATxt = [];
            var travellingTxt = [];

            var functionFlag = [
                [false],
                [false,false,false,false],
                [false,false],
                [false]
            ];

            var functionFlagT = [
                [],
                [false, false, false, false, false, false, false, false, false, false],
                [false, false, false, false, false, false, false, false, false, false, false, false],
                [false, false, false, false, false, false]
            ];

            var excelStatus = false;
            var trendStatus = false;
            var tableStatus = false;
            var zeroStatus = false;

            var dataOuter = '0';
            var dataInner = '0';
            var outerText = 'Profiling';
            var innerText = 'Overall Level Base';


            var allAjax = [[profileAjax],[firstAjax,secondAjax,thirdAjax,forthAjax],[fifthAjax,sixthAjax],[seventhAjax]];
           

            var meantopColor = ["#0066CC","#3399FF","#80bfff"];
            var airportName = ["Ahmedabad","Lucknow","Mangaluru","Jaipur","Guwahati","Thiruvananthapuram","Mumbai"];

            var outerTab = <?php echo json_encode($tabs); ?>;
            var innerTab = <?php echo json_encode($subtabs); ?>;

            var innerTabE = ["Profiling | Overall Base","Profiling | Respondent Base","Arrivals | Overall", "Arrivals | Arrivals Process","Arrivals | Terminal Building","Arrivals | Service Provided","Arrivals | Food and Beverage","Arrivals | Retails Outlet","Arrivals | Duty Free Outlet","Arrivals | Transport Access","Arrivals | Pranaam","Arrivals | NPS","Departure | Overall","Departure | Airport Access","Departure | Check-In","Departure | Security Check","Departure | Terminal Building","Departure | Services provided","Departure | Gate area","Departure | Food & Beverage","Departure | Retail Outlets","Departure | Duty Free Outlets","Departure | Pranaam","Departure | NPS","Greeter | Overall" , "Greeter | Airport Access","Greeter | Meet & Greet Area","Greeter | Food & Beverage","Greeter | Retail Outlets","Greeter | NPS"];
            var classArr = [];

            const npsLabel = ['Promoters','Passive','Detractors','NPS'];
            const npsColor = ['#12239E','#77C3FE','#E66C37','#333333'];
            var yesnoLabel = ["% of Yes","% of No"];
            const yesnoColor = ['#77C3FE','#ffa31a'];  
            
            
            var customColor = ['#03045E','#035B8A','#0470B0','#3690BF','#74A9CE','#A6BCDB','#D0D0E7'];
            
            var ajaxFlag = [false, false, false, false, false, false, false, false];

            //var targetedHighchartContainer = $(`#tab-eg7-0-0 .chart_div .card div`);
            //var targetedHighchartContainerT = $(`#tab-eg7-1-0 .chart_divT .card div`);
            
            var Q101L = ["Liquor","Destination goods, Souvenirs, Gifts, etc.","Tobacco","Perfumes & Cosmetics","Confectionary & Supermarket products","Electronics","Fashion","Toys, Health & Supplements","Jewellery"];
            var Q103L = ["Quality of products","Variety of products/trendy brands","Lower prices compared to city shops","Lower prices compared to other airport duty free shops","Loyalty rewards","Trusted/Known/Famous brands ","Duty Free Exclusive & Unique collection","Well trained store staff and good customer service","Discounts/Offers/Schemes on purchase","Premium & Luxury collection","Value for money","Pleasurable Experience","Had free time","Suitable as a gift/souvenir","Cheaper than stores outside airport"];
            var Q109L = ["Loyalty programs","Gift wrapping service","Shop at Departure & Collect at Arrivals/</br>Shop at Arrival & Collect at Departure","Online ordering facility","Personal shopping assistant","Cross-service rewards/offers"];
            
            var Q202L = ["Prices higher than city/ malls/ high streets","Prices higher than other Duty Free shops","Product variety and selection not attractive","To avoid additional charges that I may have </br>  to pay as against permitted per passenger ","Lack of additional services","Store staff not trained to assist as per my needs","Preferred brands not present/ Nothing appealing","No unique/ exclusive/ signature offerings","Discounts/ Offers/ Schemes/ Promos are not attractive","Lack of time","Unsure about customs regulations for duty free offerings","Shopping atmosphere and ambience not good/ too crowded","Hassle of carrying extra luggage","I have already shopped at duty free of other airport","No need/ No intention to buy"];
            
            var Q301aL = ["Better quality of food","More food options available","Trusted and known brand(s)","Quicker check out","Local delicacies available","Discounts/Offers/Schemes on purchase","The food item is only available at the airport","Proximity to boarding/arrival gates","Provide delivery at the seat","Prices better than in-flight food options","Had pre-ordered with pickup at airport outlet","I was hungry","Outlets served food with healthy options","The aromas were tantalizing ","Gourmet/unique offerings available","Loyalty Rewards example frequent flyer programs etc.","Had economical options"];
            var Q303aL = ["Quick bite/Snack/Finger Food","1 Food item + 1 Beverage","Thali/Full meal","Desserts"];
            var Q308aL = ["Every time I Travel</br>(5 of 5 times)","Mostly</br>(3 to 5 times)","Rarely</br>(1 to 2 times)","Never"];
            
            var Q401aL = ["Expensive/Overpriced","Limited availability of products/nothing original or new","Long distance from boarding gates","No or Lower discounts/Schemes/Offers","Lack of my preferred food options ex: salads, diet specific food","Store staff not well trained/service not good enough","Food items of my choice were not present","Brand that I wanted to buy is not present","Concern over freshness of food","Concerned about hygiene","Long serving time","Long queue","Crowded/atmosphere not pleasant or quiet","Lack of time – rushing towards/hurrying for boarding ","Lack of time – occupied with work while waiting","No need/was not feeling hungry","Have already paid for in-flight options","Lack of local delicacies"];

            var Q301bL = ["Self-use/Self-indulgence","Friends/colleague asked to pick it up","Family/spouse/kids asked to pick it up","Gifting to friends/colleagues","Gifting to Family/spouse/kids","Souvenir for self/others"];
            var Q302bL = ["Quality of products","Variety of products","Trendy products","Trusted/Known/Famous brands","Exclusivity - Unique collection","Well trained store staff and good customer service","Quicker check out","Discounts/ Offers / Schemes on purchase","Premium/Luxury collection","Proximity to boarding/ arrival gates","Pleasurable Experience","Value for money","Had economical options","Better organized store","Loyalty Rewards example frequent flyer programs etc."];
            var Q304bL = ["Apparel Formal (Office formal shirts, pants, Blazers, tie etc.)","Apparel Casual (Jeans, T-shirts etc.) ","Apparel Traditional","Jewelry","Luggage and Bag packs","Footwear, Athleisure, Sportswear, Activewear","Electronics & accessories ","Perfumes & Cosmetics/Beauty","Health & Wellness","Magazines / Books /Stationary/ Newspaper","Alcohol/ Liquor","Chocolates & Confectionaries","Cigarettes & Tobacco","Local Delicacies, Packed, or Gourmet Food","Souvenirs/Gifting","Handicrafts","Fashion accessories – belts, wallets, purses","Sunglasses & Eyewear","Watches","Toys","Travel accessories","Pet products & accessories","Home Décor"]
            var Q306bL = ["Every time I Travel (5 of 5 times)","Sometimes (2 to 4 times)","Rarely (1 time)","Never"];
            
            var Q401bL = ["Expensive/Overpriced","Limited availability of products ","Long distance from boarding/arrival gates","To avoid excess baggage/additional charges </br> that I may have to pay as against permitted per passenger","Store staff not trained to assist as per my needs","Brand that I wanted to buy is not present","No unique/exclusive collection","No or Lower discounts/Schemes/Offers","Don’t like shopping while carrying cabin baggage","Crowded/atmosphere not pleasant or quiet","After sale service/returns/refunds is limited at airports    ","Quality of products is better in stores outside the airport","Lack of time","No need"];

            // var tblHead_1 = ["Airport","Prices higher than city/ malls/ high streets","Prices higher than other Duty Free shops","Product variety and selection not attractive","To avoid additional charges that I may have to pay as against permitted per passenger ","Lack of additional services","Store staff not trained to assist as per my needs","Preferred brands not present/ Nothing appealing","No unique/ exclusive/ signature offerings","Discounts/ Offers/ Schemes/ Promos are not attractive","Lack of time","Unsure about customs regulations for duty free offerings","Shopping atmosphere and ambience not good/ too crowded","Hassle of carrying extra luggage","I have already shopped at duty free of other airport","No need/ No intention to buy"];
            
            // Q501: SOURCE OF AWARENESS
            const Q501L = [
            "Adani One app", 
            "Airport Website", 
            "Airport advertising", 
            "Online Travel aggregator (Easemytrip, Dreamfolks, Topflight, Aspire Lifestyle, etc.)", 
            "From airport desk", 
            "Word of mouth – family members, friends, neighbors, colleagues, etc.", 
            "Travel Agents/agencies", 
            "Corporate tie-ups", 
            "Availed meet & greet service at other Indian/abroad airports", 
            "PR Events", 
            ];

            // Q502: TYPE OF PRANAAM SERVICES AVAILED
            const Q502L = ["Platinum", "Rapid", "Elite", "Elite plus", "Founder plan"];

            // Q503: SOURCE OF BOOKING PRANAAM SERVICES
            const Q503L = [
            "Through Adani One App", 
            "Through email", 
            "By calling customer support", 
            "At the airport desk", 
            "Through travel agents/agencies", 
            "Company booked it for me", 
            "Concierge services of banks/Credit card companies"
            ];

            // Q504: PRANAAM BOOKING
            const Q504L = [
            "Self", 
            "Spouse", 
            "My children", 
            "Relatives/parents", 
            "Friends/colleagues", 
            "Travel agents/Company/Office"
            ];

            // Q504a: MODE OF PAYMENT
            const Q504aL = [
            "Cash", 
            "Credit/debit cards", 
            "Digital payments through UPI", 
            "Mobile/Digital/e-wallets", 
            "Net Banking"
            ];

            // Q505: CHALLENGES WITH DIGITAL PAYMENT
            const Q505L = [
            "Slow connection with payment gateway", 
            "Amount was deducted but did not reflect on the Pranaam service portal", 
            "Multiple failed attempts at payment", 
            "No last-minute modifications/customization to booking", 
            "Limited Rescheduling", 
            "Technical glitches during peak/rush hours at the airport", 
            "Pranaam team could not guide me with my digital payment", 
            "I do not use any digital payment methods"
            ];

            // Q506: FREQUENCY OF AVAILING PRANAAM
            const Q506L = [
            "Never tried before – This is the first time", 
            "1 – 2 times", 
            "3 – 5 times", 
            "More than 5 times", 
            "Always"
            ];

            // Q507: REASONS FOR AVAILING PRANAAM
            const Q507L = [
            "Seamless one stop solution – Lounge, Meet & Greet, Fast-track", 
            "Had too much baggage", 
            "Had kids/elderly people with me", 
            "Services give value for money", 
            "Not familiar with wayfinding and airport procedures", 
            "Convenience", 
            "Fast and reliable", 
            "Recommended by friends/family/colleagues"
            ];

            // Q508: REASONS FOR DISLIKING PRANAAM SERVICES
            const Q508L = [
            "Poor assistance, guidance, and communication from team", 
            "Poor customer support post service completion", 
            "Poor refund/cancellation policy", 
            "Rude/unfriendly behavior from staff", 
            "Staff was not well trained to meet/understand my needs", 
            "Not value for money", 
            "Insufficient staff and buggy", 
            "Lounge experience was bad", 
            "Ill-groomed staff", 
            "Service offerings were not clear", 
            "Cross-service offers/discounts/promos are not available", 
            "Poor booking and payment experience", 
            "Customization/modifications of service packages not possible", 
            "No proper process/channel for providing feedback"
            ];

            // Q509: DISSATISFACTION WITH LOUNGE
            const Q509L = [
            "Over-Crowded", 
            "No private space available", 
            "Furniture and seating are not comfortable", 
            "Food quality is bad", 
            "Food & Drink selection is poor", 
            "Inadequate staff", 
            "Lighting is dim", 
            "AC does not work properly", 
            "Insufficient space/ Not enough space at the lounge", 
            "Unclean/ unhygienic seating area", 
            "Unclean washrooms", 
            "Smoking area is unavailable", 
            "Wi-Fi speed is bad/poor", 
            "Charging points are not available or not working", 
            "Working desks not available"
            ];

            // Q510: CHALLENGES FACED WHILE BOOKING PRANAAM
            const Q510L = [
            "My preferred slots were not available", 
            "Staff was not well trained to answer my queries", 
            "Had to contact multiple times", 
            "No response to calls made/emails sent regarding the services", 
            "Technical issues in the app/website while booking", 
            "Lack of flexibility/customization in choosing options", 
            "Longer response time", 
            "Too many details asked while booking", 
            "Unprofessional behavior from staff while handling queries", 
            "Time taken to resolve the query was longer"
            ];

            // Q511: ADDITIONAL SERVICES
            const Q511L = [
            "Access to a private smoking area", 
            "No disturbance zones for focused personal time", 
            "Dedicated space - Baby care/ Workstations/ Sleepers", 
            "Lounge access", 
            "Wi-Fi access", 
            "Discounts/Offers/rewards for shopping/eating at Retail, Duty Free, F&B", 
            "Membership/ Subscription program", 
            "Home check-in/ Baggage pickup/drop at home", 
            "Common benefits across airports", 
            "Car parking/ Car wash/ Valet facility", 
            "Transport (home to airport transfers, full day inter-terminal transfers, airport to nearby city transfers)", 
            "Buggy/ Tarmac transfer – vehicle transport between the flight and the boarding/arrival gate", 
            "Baggage wrap", 
            "Floral service", 
            "Access to transit hotel"
            ];

            // Q512: TIPPING THE PORTER OF PRANAAM SERVICE
            const Q512L = ["YES", "NO"];

            // Q513: REASONS FOR TIPPING THE PORTER OF PRANAAM SERVICE
            const Q513L = [
            "I was impressed by the porter’s service/ behavior (Reward for doing a good job)", 
            "The porter requested me to tip him/her", 
            "It is a social norm/ courtesy", 
            "I always tip the porters of such services (Generous tipper)"
            ];

            const Q601L = [
                "Adani One app",
                "Airport Website",
                "Airport advertising",
                "Online Travel aggregator",
                "From airport desk",
                "Word of mouth – family members, friends, neighbors, colleagues, etc.",
                "Travel Agents/agencies",
                "Corporate tie-ups",
                "Availed meet & greet service at other Indian/abroad airports",
                "PR Events",
            ];

            const Q602L = [
                "Yes",
                "No"
            ];

            const Q602aL = [
                "At the same airport",
                "At another airport"
            ];

            const Q603L = [
                "Home check-in (departure)",
                "Luggage wrap",
                "Baggage delivery at airport (departure)",
                "Baggage collection from belt (arrival)",
                "Baggage delivery (arrival)",
                "Discounts at F&B, Travel Retail, Duty Free",
                "Assured cabs for pickup/drop from/to airport",
                "Transport",
                "Tarmac transfer",
                "Buy online, deliver from store",
                "Valet and car parking",
                "Escort to flight via private vehicle",
                "Access to transit hotels",
                "Early access to airport exclusives products",
                "Lounge access with curated menu",
                "Dedicated butler and concierge services in Lounge",
                "I have not availed Meet & Greet services at other airports",
            ];

            const Q604L = [
                "Service was expensive",
                "It has bad reviews",
                "My friends/relatives/family/colleagues do not recommend taking the service",
                "I don’t have big baggage/luggage",
                "I don’t have dependents travelling with me",
                "Poor Cancelation and refund/policy",
                "Poor customer care support and feedback redressal",
                "Not value for money",
                "Slots not available at the required timings",
                "Thought it was only for senior citizens",
                "Thought it was only for business class passengers",
                "Customization is not available",
                "Too lengthy and complex booking process",
                "Lounge experience will not be good",
                "Pranaam is not as good as other famous Meet & Greet services",
                "Airport is too small and easy to navigate/ way find",
            ];

            const Q605L = [
                "Access to a private smoking area",
                "No disturbance zones for focused personal time",
                "Work-stations",
                "Sleepers",
                "Dedicated space for baby care",
                "Buggy",
                "Lounge access",
                "Wi-Fi access",
                "Discounts/Offers/rewards for shopping/eating at Retail, Duty Free, F&B",
                "Membership/Subscription program",
                "Home check-in/Baggage pickup/drop at home",
                "Common benefits across airports",
                "Car parking and Valet facility",
                "Car wash facility",
                "Transport",
                "Chauffeur/Cab service for pickup and drop",
                "Baggage wrap",
                "Floral service",
                "Access to transit hotel",
            ];

            const Q606L = [
                "Affordable pricing",
                "Availability of more slots according to my convenience",
                "Booking convenience - customer friendly booking",
                "Availability of services across other airports",
                "Quick response to queries",
                "Option to customize packages/services",
                "Provide more packages/services based on my need",
                "Availability of wheelchair/buggy",
                "Provide/assist with medical care",
                "Personal shopper",
                "Access to VIP Parking",
                "Cross-service rewards/offers/promos",
                "Dedicated gates for entry and security check",
            ];

            const Q1101L = ["Banners & Posters","OOH i.e. Out of Home Media screens","Standee","Bulletins or Billboards","Wall-scapes","Tent cards"];
            const Q1102L = ["Yes","No"];
            const Q1106L = ["Search about the product/brand/service online","Make an enquiry about product/brand/service","Visit the product/brand/service website","Visit the product/brand/service store","Engage in the Call-to-action mention in the advertisement","Download the product/brand/service app","Purchase the product/brand/ service"];

            var Q901aL = ["Better quality of food","More food options available","Trusted and known brand(s)","Quicker check out","Local delicacies available","Discounts/ Offers / Schemes on purchase","The food item is only available at the airport","I was hungry","Outlets served food with healthy options – Example vegan, keto, salads, etc.","The aromas were tantalizing ","Gourmet/ unique offerings available","Loyalty points/rewards ","Had economical options","As a farewell treat"];
            var Q902bL = ["Quality of products","Variety of products","Loyalty points/Rewards ","Trusted/ Known/ Famous brands","Exclusivity - Unique collection","Well trained store staff and good customer service","Better organized store","Discounts/ Offers / Schemes on purchase","Premium/Luxury collection","Had economical options","As a farewell treat","Trendy products"];
            var Q1001aL = ["Expensive/Overpriced","Limited availability of products/ nothing original or new","Long distance from entrance gates","No or Lower discounts/ Schemes/ Offers","Lack of my preferred food options ex: salads, diet specific food","Store staff not well trained/ service not good enough","Food items of my choice were not present","Brand that I wanted to buy is not present","Concern over freshness of food","Concerned about hygiene","Long serving time","Long queue","Crowded/ atmosphere not pleasant or quiet","Lack of time – rushing towards/ hurrying for boarding ","Lack of time – occupied with work while waiting","No need/ was not feeling hungry"];
            var Q1002bL = ["Expensive/Overpriced","Limited availability of products ","Long distance from entrance gates","To avoid excess baggage/additional charges that I may have to pay as against permitted per passenger","Store staff not trained to assist as per my needs","Brand that I wanted to buy is not present","No unique/ exclusive collection","No or Lower discounts/ Schemes/ Offers","Don’t like shopping while carrying cabin baggage","Crowded/ atmosphere not pleasant or quiet","After sale service/ returns/ refunds is limited at airports    ","Quality of products is better in stores outside the airport","Lack of time – rushing towards or hurrying for the gates/ occupied with work / less time to explore products for shopping","No need"];





            const airportDataMap = {
                "Ahmedabad": 'in-2984',            // Gujarat
                "Lucknow": 'in-up',                // Uttar Pradesh
                "Mangaluru": 'in-ka',              // Karnataka
                "Jaipur": 'in-rj',                 // Rajasthan
                "Guwahati": 'in-as',               // Assam
                "Thiruvananthapuram": 'in-kl',     // Kerala
                "Mumbai": 'in-mh'                  // Maharashtra
            };

            // Add more arrays similarly for the remaining questions...

            var tblHead_1 = ["Category","Ahmedabad","Lucknow","Mangaluru","Jaipur","Guwahati","Thiruvananthapuram","Mumbai"];
            
            
            var ageLabel = ['18 – 30 years', '31 – 40 years', '41 – 50 years', '51 – 60 years'];
            var genderLabel = ['Male','Female'];
            var incomeLabel = ["Upto 5 lacs","5 to 10 lacs","10-20 lacs","20 lacs or more"];
            var segmentLabel = ["Traveller","Non-Traveller"];
            var typesLabel = ["Departure","Arrival"];
            var dwellLabel = ["Less than 30 mins","30 – 45 mins","45 mins – 1 hr","1 hr – 2 hrs","2 – 4 hrs","More than 4 hrs"];
            var tripLabel = ["1 – 2","3 – 5","6 – 10","11 – 20","21 or more"];
            var travellingLabel = ["Solo","Family & relatives","Group  of work colleagues","Group of friends"];
            var purposeLabel = ["Leisure","Business/ Work","Education/Student","Medical/Health","Religious/Pilgrimage"];
            var terminalLabel = ["Terminal 1","Terminal 2","Terminal 3"];
            var travellerLabel = ["Domestic","International"];

            var dutyFreeStatus = false;
            var overallBaseStatus = false;

            const twoRadialColor = [
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],
                        [
                            1,
                            Highcharts.color(
                                Highcharts.getOptions().colors[0]
                            ).setOpacity(0.5).get('rgba')
                        ]
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#191970']                 // Midnight Blue
                    ]
                }
            ];

            const twoRadialColor2 = [
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#4169E1']                 // Royal Blue
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],
                        [
                            1,
                            Highcharts.color(
                                Highcharts.getOptions().colors[0]
                            ).setOpacity(0.5).get('rgba')
                        ]
                    ]
                }
            ]

            // const twoRadialColor2 = [
            //     {
            //         radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
            //         stops: [
            //             [0, 'rgba(255,255,255,0.5)'],
            //             [
            //                 1,
            //                 Highcharts.color(
            //                     Highcharts.getOptions().colors[1]
            //                 ).setOpacity(0.5).get('rgba')
            //             ]
            //         ]
            //     },
            //     {
            //         radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
            //         stops: [
            //             [0, 'rgba(255,255,255,0.5)'],
            //             [
            //                 1,
            //                 Highcharts.color(
            //                     Highcharts.getOptions().colors[2]
            //                 ).setOpacity(0.5).get('rgba')
            //             ]
            //         ]
            //     },
            // ]

            const radialColors = [
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],
                        [
                            1,
                            Highcharts.color(
                                Highcharts.getOptions().colors[0]
                            ).setOpacity(0.5).get('rgba')
                        ]
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#1a66ff']                 // Dark Navy Blue
                    ]
                },
                // {
                //     radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                //     stops: [
                //         [0, 'rgba(255,255,255,0.5)'],
                //         [
                //             1,
                //             Highcharts.color(
                //                 Highcharts.getOptions().colors[9]
                //             ).setOpacity(0.5).get('rgba')
                //         ]
                //     ]
                // },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#751aff']                 // Midnight Blue
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#4169E1']                 // Royal Blue
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#00BFFF']                 // Deep Sky Blue
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#1E90FF']                 // Dodger Blue
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#4682B4']                 // Steel Blue
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#6A5ACD']                 // Slate Blue
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#6495ED']                 // Cornflower Blue
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#5F9EA0']                 // Cadet Blue
                    ]
                },
                {
                    radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
                    stops: [
                        [0, 'rgba(255,255,255,0.5)'],  // Light transparency
                        [1, '#008080']                 // Teal
                    ]
                }
            ];

        //     var radialColors = [
        //     {
        //         radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
        //         stops: [
        //             [0, 'rgba(255,255,255,0.5)'],
        //             [
        //                 1,
        //                 Highcharts.color(
        //                     Highcharts.getOptions().colors[0]
        //                 ).setOpacity(0.5).get('rgba')
        //             ]
        //         ]
        //     },
        //     {
        //         radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
        //         stops: [
        //             [0, 'rgba(255,255,255,0.5)'],
        //             [
        //                 1,
        //                 Highcharts.color(
        //                     Highcharts.getOptions().colors[1]
        //                 ).setOpacity(0.5).get('rgba')
        //             ]
        //         ]
        //     },
        //     {
        //         radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
        //         stops: [
        //             [0, 'rgba(255,255,255,0.5)'],
        //             [
        //                 1,
        //                 Highcharts.color(
        //                     Highcharts.getOptions().colors[2]
        //                 ).setOpacity(0.5).get('rgba')
        //             ]
        //         ]
        //     },
        //     {
        //         radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
        //         stops: [
        //             [0, 'rgba(255,255,255,0.5)'],
        //             [
        //                 1,
        //                 Highcharts.color(
        //                     Highcharts.getOptions().colors[3]
        //                 ).setOpacity(0.5).get('rgba')
        //             ]
        //         ]
        //     },
        //     {
        //         radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
        //         stops: [
        //             [0, 'rgba(255,255,255,0.5)'],
        //             [
        //                 1,
        //                 Highcharts.color(
        //                     Highcharts.getOptions().colors[4]
        //                 ).setOpacity(0.5).get('rgba')
        //             ]
        //         ]
        //     },
        //     {
        //         radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
        //         stops: [
        //             [0, 'rgba(255,255,255,0.5)'],
        //             [
        //                 1,
        //                 Highcharts.color(
        //                     Highcharts.getOptions().colors[5]
        //                 ).setOpacity(0.5).get('rgba')
        //             ]
        //         ]
        //     },
        //     {
        //         radialGradient: { cx: 0.4, cy: 0.3, r: 0.7 },
        //         stops: [
        //             [0, 'rgba(255,255,255,0.5)'],
        //             [
        //                 1,
        //                 Highcharts.color(
        //                     Highcharts.getOptions().colors[6]
        //                 ).setOpacity(0.5).get('rgba')
        //             ]
        //         ]
        //     }
        // ];

            //=================================Document.Ready START============================================
            $(document).ready(function() {
                window.scrollTo(0, 0);
                $(".splash").show();
                $("#outer_0").addClass("mm-active");
                $("#outer_0 > a").addClass("outer_div");
                $("#outer_0 > ul > li:first").addClass("mm-active");
                $("#outer_0 > ul > li:first").addClass("active");
                $("#outer_0 > ul > li:first > a").attr("aria-expanded", "true");
                $("#outer_0 > ul > li:first > a").addClass("active");

                $('#month').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#month").multiselect('selectAll', false);
                $("#month").multiselect("deselectAll", false);
                $("#month").multiselect('updateButtonText');

                $('#days').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#days").multiselect('selectAll', false);
                $("#days").multiselect("deselectAll", false);
                $("#days").multiselect('updateButtonText');

                $('#days_type').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#days_type").multiselect('selectAll', false);
                $("#days_type").multiselect("deselectAll", false);
                $("#days_type").multiselect('updateButtonText');

                $('#segment').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#segment").multiselect('selectAll', false);
                $("#segment").multiselect("deselectAll", false);
                $("#segment").multiselect('updateButtonText');

                $('#city').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#city").multiselect('selectAll', false);
                $("#city").multiselect("deselectAll", false);
                $("#city").multiselect('updateButtonText');

                $('#terminal').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#terminal").multiselect('selectAll', false);
                $("#terminal").multiselect("deselectAll", false);
                $("#terminal").multiselect('updateButtonText');

                $('#traveller').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#traveller").multiselect('selectAll', false);
                $("#traveller").multiselect("deselectAll", false);
                $("#traveller").multiselect('updateButtonText');

                $('#income').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#income").multiselect('selectAll', false);
                $("#income").multiselect("deselectAll", false);
                $("#income").multiselect('updateButtonText');

                $('#domestic_trip').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#domestic_trip").multiselect('selectAll', false);
                $("#domestic_trip").multiselect("deselectAll", false);
                $("#domestic_trip").multiselect('updateButtonText');

                $('#international_trip').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#international_trip").multiselect('selectAll', false);
                $("#international_trip").multiselect("deselectAll", false);
                $("#international_trip").multiselect('updateButtonText');

                $('#rot').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#rot").multiselect('selectAll', false);
                $("#rot").multiselect("deselectAll", false);
                $("#rot").multiselect('updateButtonText');

                $('#gender').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#gender").multiselect('selectAll', false);
                $("#gender").multiselect("deselectAll", false);
                $("#gender").multiselect('updateButtonText');

                $('#age').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#age").multiselect('selectAll', false);
                $("#age").multiselect("deselectAll", false);
                $("#age").multiselect('updateButtonText');

                $('#types').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#types").multiselect('selectAll', false);
                $("#types").multiselect("deselectAll", false);
                $("#types").multiselect('updateButtonText');

                $('#dwellD').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#dwellD").multiselect('selectAll', false);
                $("#dwellD").multiselect("deselectAll", false);
                $("#dwellD").multiselect('updateButtonText');

                $('#dwellA').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#dwellA").multiselect('selectAll', false);
                $("#dwellA").multiselect("deselectAll", false);
                $("#dwellA").multiselect('updateButtonText');

                $('#travelling').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#travelling").multiselect('selectAll', false);
                $("#travelling").multiselect("deselectAll", false);
                $("#travelling").multiselect('updateButtonText');


                $(".custom-tab-pane1").each(function(i,e){
                    var status = $(this).data('status');
                    statusArr[0].push(status);
                    var classArr2 = []
                    $(this).find(".row").each(function(i2,e2){
                        classArr2 = [];
                        $(this).find('table').addClass(`tblprofile_${i}`);
                        classArr2.push(`tblprofile_${i}`);
                    });
                    classArr.push(classArr2);
                });

                $(".custom-tab-pane2").each(function(i,e){
                    var status = $(this).data('status');
                    statusArr[1].push(status);
                    var classArr2 = []
                    $(this).find(".row").each(function(i2,e2){
                        classArr2 = [];
                        $(this).find('table').addClass(`tbl1_${i}`);
                        classArr2.push(`tbl1_${i}`);
                    });
                    classArr.push(classArr2);
                });

                $(".custom-tab-pane3").each(function(i,e){
                    var status = $(this).data('status');
                    statusArr[1].push(status);
                    var classArr2 = []
                    $(this).find(".row").each(function(i2,e2){
                        classArr2 = [];
                        $(this).find('table').addClass(`tbl2_${i}`);
                        classArr2.push(`tbl2_${i}`);
                    });
                    classArr.push(classArr2);
                });

                $(".custom-tab-pane4").each(function(i,e){
                    var status = $(this).data('status');
                    statusArr[1].push(status);
                    var classArr2 = []
                    $(this).find(".row").each(function(i2,e2){
                        classArr2 = [];
                        $(this).find('table').addClass(`tbl3_${i}`);
                        classArr2.push(`tbl3_${i}`);
                    });
                    classArr.push(classArr2);
                });

                //console.log(statusArr);
                

                $(".div-head > b").each(function(){
                    var text = $(this).text();
                    if(text!="NPS")
                    {
                        let words = text.split(" ");
                        const lastElement = words[words.length - 1];
                        if((words[0]=="Are")&&(!lastElement.endsWith("?")))
                        {
                            let transformedText = words.map((word, index) => index === 0 ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() : word.toLowerCase()).join(" ");
                            $(this).empty().append(`${transformedText}?`);
                        }
                        else
                        {
                            let transformedText = words.map((word, index) => index === 0 ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() : word.toLowerCase()).join(" ");
                            $(this).empty().append(transformedText);
                        }
                    }
                });

                select2Initialize();
                
                $("#trends_open_div").hide();
                $("#trends_close_div").hide();
                $("#data_type").hide();
                $("#data_type").next().hide();
                $("#swap_tbl_btn").hide();

            });

            $(window).on("load", function() {
                applyF();
                setTimeout(() => {
                    $(window).trigger('resize');
                }, 1000);
            });
            //=================================Document.Ready END============================================


            function checkAjaxCompletion()
            {
                //console.log(ajaxFlag);
                if (ajaxFlag.every(flag => flag === true)) 
                {
                    exportExcel();
                    //console.log("Done Now");
                }
                else
                {
                    //console.log("Not Now");
                }
            }

            //=================================Logout============================================
            function logout() {
                window.stop();
                $.ajax({
                    url: "api/logout.php",
                    type: "POST",
                    data: {
                        'action': 'logout'
                    },
                    success: function(response) {
                        if (response == "success") {
                            window.location.href = "index.php";
                        }
                    }
                })
            }
            //=================================Drodpown============================================
            function select2Initialize()
            {
                $(".js-select2").each(function(){
                    $(this).select2({
                        minimumResultsForSearch: 20,
                        dropdownParent: $(this).next('.dropDownSelect2')
                    });
                    $(".js-select2").each(function(){
                        $(this).on('select2:close', function (e){
                            if($(this).val() == "Please chooses") {
                                $('.js-show-service').slideUp();
                            }
                            else {
                                $('.js-show-service').slideUp();
                                $('.js-show-service').slideDown();
                            }
                        });
                    });
                });
            }
            //=================================Filter Sidebar START============================================

            function openF() 
            {
                // //debugger;
                document.getElementById("mySidebar2").style.width = "300px";
                document.getElementById("app-containerX").style.opacity = "0.5";
            }

            function closeF() 
            {
                // //debugger;
                document.getElementById("mySidebar2").style.width = "0px";
                document.getElementById("app-containerX").style.opacity = "1";
            }

            //=================================Filter Sidebar END============================================

            //=================================Reset Filter START============================================

            function resetFilters()
            {
                $('#month').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#month").multiselect('selectAll', false);
                $("#month").multiselect("deselectAll", false);
                $("#month").multiselect('updateButtonText');

                $('#days').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#days").multiselect('selectAll', false);
                $("#days").multiselect("deselectAll", false);
                $("#days").multiselect('updateButtonText');

                $('#days_type').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#days_type").multiselect('selectAll', false);
                $("#days_type").multiselect("deselectAll", false);
                $("#days_type").multiselect('updateButtonText');

                $('#segment').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#segment").multiselect('selectAll', false);
                $("#segment").multiselect("deselectAll", false);
                $("#segment").multiselect('updateButtonText');

                $('#city').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#city").multiselect('selectAll', false);
                $("#city").multiselect("deselectAll", false);
                $("#city").multiselect('updateButtonText');

                $('#terminal').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#terminal").multiselect('selectAll', false);
                $("#terminal").multiselect("deselectAll", false);
                $("#terminal").multiselect('updateButtonText');

                $('#traveller').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#traveller").multiselect('selectAll', false);
                $("#traveller").multiselect("deselectAll", false);
                $("#traveller").multiselect('updateButtonText');

                $('#income').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#income").multiselect('selectAll', false);
                $("#income").multiselect("deselectAll", false);
                $("#income").multiselect('updateButtonText');

                $('#domestic_trip').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#domestic_trip").multiselect('selectAll', false);
                $("#domestic_trip").multiselect("deselectAll", false);
                $("#domestic_trip").multiselect('updateButtonText');

                $('#international_trip').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#international_trip").multiselect('selectAll', false);
                $("#international_trip").multiselect("deselectAll", false);
                $("#international_trip").multiselect('updateButtonText');

                $('#rot').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#rot").multiselect('selectAll', false);
                $("#rot").multiselect("deselectAll", false);
                $("#rot").multiselect('updateButtonText');

                $('#gender').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#gender").multiselect('selectAll', false);
                $("#gender").multiselect("deselectAll", false);
                $("#gender").multiselect('updateButtonText');

                $('#age').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#age").multiselect('selectAll', false);
                $("#age").multiselect("deselectAll", false);
                $("#age").multiselect('updateButtonText');

                $('#types').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#types").multiselect('selectAll', false);
                $("#types").multiselect("deselectAll", false);
                $("#types").multiselect('updateButtonText');

                $('#dwellD').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#dwellD").multiselect('selectAll', false);
                $("#dwellD").multiselect("deselectAll", false);
                $("#dwellD").multiselect('updateButtonText');

                $('#dwellA').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#dwellA").multiselect('selectAll', false);
                $("#dwellA").multiselect("deselectAll", false);
                $("#dwellA").multiselect('updateButtonText');

                $('#travelling').multiselect({
                    includeSelectAllOption: true,
                    enableFiltering: false,
                    enableFullValueFiltering: false
                });
                $("#travelling").multiselect('selectAll', false);
                $("#travelling").multiselect("deselectAll", false);
                $("#travelling").multiselect('updateButtonText');

                flagConstruct();
            }

            //=================================Reset Filter End============================================

            //=================================Tab Sidebar START============================================
            function openS()
            {
                //debugger;
                var windowWidth = $(window).width();
                var sidebarWidth = ((18/100)*windowWidth);
                
                $("#mySidebar").css("width",sidebarWidth);  
                $("#mySidebar").css("min-width",sidebarWidth);
                $("#main").css("margin-left",sidebarWidth);
                
                setTimeout(() => {
                    var newWidth = $("#main").width();
                    newWidth = newWidth - 20 ;
                    //alert(newWidth);
                    if(trendStatus === false)
                    {
                        // $(targetedHighchartContainer).each(function() {
                        //     var chart = $(this).highcharts();
                        //     if (chart) {
                        //         //debugger;
                        //         chart.setSize(newWidth, null, true);
                        //     }
                        // });
                    }
                    else
                    {
                        // $(targetedHighchartContainerT).each(function() {
                        //     var chart2 = $(this).highcharts();
                        //     if (chart2) {
                        //         chart2.setSize(newWidth, null, true);
                        //     }
                        // });
                    }
                }, 800);
            }

            function closeS()
            {
                //debugger;
                var windowWidth = $(window).width();
                var sidebarWidth = ((0/100)*windowWidth);
                
                $("#mySidebar").css("width",sidebarWidth);
                $("#mySidebar").css("min-width",sidebarWidth);
                $("#main").css("margin-left",sidebarWidth);

                setTimeout(() => {
                    var newWidth = $("#main").width();
                    newWidth = newWidth - 20 ;
                    //alert(newWidth);
                    if(trendStatus === false)
                    {
                        // $(targetedHighchartContainer).each(function() {
                        //     var chart = $(this).highcharts();
                        //     if (chart) {
                        //         //debugger;
                        //         chart.setSize(newWidth, null, true);
                        //     }
                        // });
                    }
                    else
                    {
                        // $(targetedHighchartContainerT).each(function() {
                        //     var chart2 = $(this).highcharts();
                        //     if (chart2) {
                        //         chart2.setSize(newWidth, null, true);
                        //     }
                        // });
                    }
                }, 800);
            }
            
            function tabSidebar()
            {
                var sidebardataStatus = $('#openbtn').attr("data-status");
                if(sidebardataStatus==1)
                {
                    $('#openbtn').attr('data-status', '2');
                    closeS();
                }
                else
                {
                    $('#openbtn').attr('data-status', '1');
                    openS();
                }
            }
            //=================================Tab Sidebar END============================================

            //=================================Resizing Chart Start============================================
                $(window).on("resize", function() {
                    openS();
                });
            //=================================Resizing Chart END============================================

            //=================================Get Tab Name============================================
            function tabClick(id)
            {
                //debugger;
                if(id=="outer_0")
                {
                    $("#trends_open_div").hide();
                    $("#trends_close_div").hide();
                    $("#data_type").hide();
                    $("#data_type").next().hide();
                    $("#swap_tbl_btn").hide();
                    $("#swap_zero_btn").show();

                    $('#outer_0 > a').addClass('outer_div');
                    $('#outer_1 > a').removeClass('outer_div');
                    $('#outer_2 > a').removeClass('outer_div');
                    $('#outer_3 > a').removeClass('outer_div');

                    for(var j=0; j<5; j++)
                    {
                        $(`#tab-1-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-1-${j}`).attr('aria-selected', 'false');
                        $(`#tab-1-${j}`).parent().removeClass('mm-active');
                        $(`#tab-1-${j}`).parent().removeClass('active');
                        $(`#tab-1-${j}`).removeClass('active');
                    }

                    for(var j=0; j<2; j++)
                    {
                        $(`#tab-2-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-2-${j}`).attr('aria-selected', 'false');
                        $(`#tab-2-${j}`).parent().removeClass('mm-active');
                        $(`#tab-2-${j}`).parent().removeClass('active');
                        $(`#tab-2-${j}`).removeClass('active');
                    }

                    for(var j=0; j<1; j++)
                    {
                        $(`#tab-3-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-3-${j}`).attr('aria-selected', 'false');
                        $(`#tab-3-${j}`).parent().removeClass('mm-active');
                        $(`#tab-3-${j}`).parent().removeClass('active');
                        $(`#tab-3-${j}`).removeClass('active');
                    }
                }
                else if(id=="outer_1")
                {
                    
                    $('#outer_0 > a').removeClass('outer_div');
                    $('#outer_1 > a').addClass('outer_div');
                    $('#outer_2 > a').removeClass('outer_div');
                    $('#outer_3 > a').removeClass('outer_div');

                    for(var j=0; j<2; j++)
                    {
                        $(`#tab-0-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-0-${j}`).attr('aria-selected', 'false');
                        $(`#tab-0-${j}`).parent().removeClass('mm-active');
                        $(`#tab-0-${j}`).parent().removeClass('active');
                        $(`#tab-0-${j}`).removeClass('active');
                    }

                    for(var j=0; j<2; j++)
                    {
                        $(`#tab-2-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-2-${j}`).attr('aria-selected', 'false');
                        $(`#tab-2-${j}`).parent().removeClass('mm-active');
                        $(`#tab-2-${j}`).parent().removeClass('active');
                        $(`#tab-2-${j}`).removeClass('active');
                    }

                    for(var j=0; j<1; j++)
                    {
                        $(`#tab-3-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-3-${j}`).attr('aria-selected', 'false');
                        $(`#tab-3-${j}`).parent().removeClass('mm-active');
                        $(`#tab-3-${j}`).parent().removeClass('active');
                        $(`#tab-3-${j}`).removeClass('active');
                    }
                }
                else if(id=="outer_2")
                {
                    
                    $('#outer_0 > a').removeClass('outer_div');
                    $('#outer_2 > a').addClass('outer_div');
                    $('#outer_1 > a').removeClass('outer_div');
                    $('#outer_3 > a').removeClass('outer_div');
                    for(var j=0; j<2; j++)
                    {
                        $(`#tab-0-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-0-${j}`).attr('aria-selected', 'false');
                        $(`#tab-0-${j}`).parent().removeClass('mm-active');
                        $(`#tab-0-${j}`).parent().removeClass('active');
                        $(`#tab-0-${j}`).removeClass('active');
                    }

                    for(var j=0; j<5; j++)
                    {
                        $(`#tab-1-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-1-${j}`).attr('aria-selected', 'false');
                        $(`#tab-1-${j}`).parent().removeClass('mm-active');
                        $(`#tab-1-${j}`).parent().removeClass('active');
                        $(`#tab-1-${j}`).removeClass('active');
                    }

                    for(var j=0; j<1; j++)
                    {
                        $(`#tab-3-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-3-${j}`).attr('aria-selected', 'false');
                        $(`#tab-3-${j}`).parent().removeClass('mm-active');
                        $(`#tab-3-${j}`).parent().removeClass('active');
                        $(`#tab-3-${j}`).removeClass('active');
                    }
                }
                else
                {
                    debugger;
                    $('#outer_0 > a').removeClass('outer_div');
                    $('#outer_3 > a').addClass('outer_div');
                    $('#outer_1 > a').removeClass('outer_div');
                    $('#outer_2 > a').removeClass('outer_div');

                    for(var j=0; j<2; j++)
                    {
                        $(`#tab-0-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-0-${j}`).attr('aria-selected', 'false');
                        $(`#tab-0-${j}`).parent().removeClass('mm-active');
                        $(`#tab-0-${j}`).parent().removeClass('active');
                        $(`#tab-0-${j}`).removeClass('active');
                    }

                    for(var j=0; j<5; j++)
                    {
                        $(`#tab-1-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-1-${j}`).attr('aria-selected', 'false');
                        $(`#tab-1-${j}`).parent().removeClass('mm-active');
                        $(`#tab-1-${j}`).parent().removeClass('active');
                        $(`#tab-1-${j}`).removeClass('active');
                    }
                    for(var j=0; j<2; j++)
                    {
                        $(`#tab-2-${j}`).attr('aria-expanded', 'false');
                        $(`#tab-2-${j}`).attr('aria-selected', 'false');
                        $(`#tab-2-${j}`).parent().removeClass('mm-active');
                        $(`#tab-2-${j}`).parent().removeClass('active');
                        $(`#tab-2-${j}`).removeClass('active');
                    }
                }
            }

            function tabClick2(element)
            {
                //debugger;
                window.scrollTo(0, 0);
                $("#overallBase").show();
                $("#filter_div").show();
                $("#filterdefination_div").show();
                $("#swap_tbl_btn").show();

                const id = $(element).attr('id');
                dataOuter = $(element).attr('data-outer');
                dataInner = $(element).attr('data-inner');
                outerText = outerTab[dataOuter];
                innerText = innerTab[dataOuter][dataInner];

                if(dataInner != "1")
                {
                    //targetedHighchartContainer = $(`#tab-eg7-${dataOuter}-${dataInner} .chart_div .card div`);
                    //targetedHighchartContainerT = $(`#tab-eg7-${dataOuter}-${dataInner} .chart_divT .card div`);
                }

                $("#activetabname").empty().append(`${outerText} | ${innerText}`);

                if(trendStatus==true)
                {
                    $("#timeField").hide();
                    $("#weekField").show();
                    $("#weekdayField").show();
                    $("#dateField").show();
                    $("#filterdefination_overall_div").show();
                    $("#filterdefination_trend_div").hide();
                    $(".chart_div").show();
                    $(".tbl_div").hide();
                    $(".chart_divT").hide();

                    trendStatus = false;
                }

                if(tableStatus==true)
                {
                    $("#data_type").hide();
                    $("#data_type").next().hide();
                    $("#trends_open_div").hide();
                    $("#trends_close_div").hide();
                    $("#swap_zero_btn").show();
                }
                else
                {
                    $("#data_type").show();
                    $("#data_type").next().show();
                    $("#trends_open_div").show();
                    $("#trends_close_div").hide();
                    $("#swap_zero_btn").hide();
                    if(innerText=="NPS")
                    {
                        $("#data_type").hide();
                        $("#data_type").next().hide();
                    }
                    else
                    {
                        $("#data_type").show();
                        $("#data_type").next().show();
                    }
                }

                $(window).trigger('resize');

                
                statusArr[dataOuter][dataInner]="active";

                if(functionFlag[dataOuter][dataInner]===false)
                {
                    applyF();
                }
            }
            
            function flagConstruct()
            {
                statusArr = [
                    ['inactive'],
                    ['inactive','inactive'],
                    [],
                    []
                ];
                
                statusArr[dataOuter][dataInner]="active";

                ajaxFlag = [false, false, false, false, false, false, false, false];
                
                functionFlag = [
                    [false],
                    [false,false,false,false],
                    [false,false],
                    [false]
                ];

                functionFlagT = [
                    [],
                    [false, false, false, false, false, false, false, false, false, false],
                    [false, false, false, false, false, false, false, false, false, false, false, false],
                    [false, false, false, false, false, false]
                ];

                applyF();
            }
            function applyF()
            {
                //console.log("applyF trigger");
                debugger;
               $(".splash").show();
                closeF();
                condX = ``;
                trendcondX = ``;
                conX = ``;
                filtercondX = ``;
                trendsfiltercondX = ``;

                monthTxt = [];
                dayTxt = [];
                dayTypeTxt = [];
                cityTxt = [];
                genderTxt = [];
                ageTxt = [];
                terminalTxt = [];
                travellerTxt = [];
                incomeTxt = [];
                domestictripTxt = [];
                internationaltripTxt = [];
                rotTxt = [];
                segmentTxt = [];
                typesTxt = [];
                dwellDTxt = [];
                dwellATxt = [];
                travellingTxt = [];

                var monthLengthY = $("#month option:selected").length;
                var daysLengthY = $("#days option:selected").length;
                var days_typeLengthY = $("#days_type option:selected").length;
                var cityLengthY = $("#city option:selected").length;
                var genderLengthY = $("#gender option:selected").length;
                var ageLengthY = $("#age option:selected").length;
                var terminalLengthY = $("#terminal option:selected").length;
                var travellerLengthY = $("#traveller option:selected").length;
                var incomeLengthY = $("#income option:selected").length;
                var domestictripLengthY = $("#domestic_trip option:selected").length;
                var internationaltripLengthY = $("#international_trip option:selected").length;
                var rotLengthY = $("#rot option:selected").length;
                var segmentLengthY = $("#segment option:selected").length;
                var typesLengthY = $("#types option:selected").length;
                var dwellDLengthY = $("#dwellD option:selected").length;
                var dwellALengthY = $("#dwellA option:selected").length;
                var travellingLengthY = $("#travelling option:selected").length;
                
                var monthVal = $("#month").val();
                var daysVal = $("#days").val();
                var days_typeVal = $("#days_type").val();
                var cityVal = $("#city").val();
                var genderVal = $("#gender").val();
                var ageVal = $("#age").val();
                var terminalVal = $("#terminal").val();
                var travellerVal = $("#traveller").val();
                var incomeVal = $("#income").val();
                var domestictripVal = $("#domestic_trip").val();
                var internationaltripVal = $("#international_trip").val();
                var rotVal = $("#rot").val();
                var segmentVal = $("#segment").val();
                var typesVal = $("#types").val();
                var dwellDVal = $("#dwellD").val();
                var dwellAVal = $("#dwellA").val();
                var travellingVal = $("#travelling").val();

                var selectedOptionsS = $("#segment").find("option:selected");
                selectedOptionsS.each(function () {
                    var dataNameValue = $(this).data("name");
                    segmentTxt.push(dataNameValue);
                });

                var selectedOptionsMON = $("#month").find("option:selected");
                selectedOptionsMON.each(function () {
                    var dataNameValue = $(this).data("name");
                    monthTxt.push(dataNameValue);
                });

                var selectedOptionsDA = $("#days").find("option:selected");
                selectedOptionsDA.each(function () {
                    var dataNameValue = $(this).data("name");
                    dayTxt.push(dataNameValue);
                });

                var selectedOptionsDT = $("#days_type").find("option:selected");
                selectedOptionsDT.each(function () {
                    var dataNameValue = $(this).data("name");
                    dayTypeTxt.push(dataNameValue);
                });

                var selectedOptionsC = $("#city").find("option:selected");
                selectedOptionsC.each(function () {
                    var dataNameValue = $(this).data("name");
                    cityTxt.push(dataNameValue);
                });

                var selectedOptionsG = $("#gender").find("option:selected");
                selectedOptionsG.each(function () {
                    var dataNameValue = $(this).data("name");
                    genderTxt.push(dataNameValue);
                });

                var selectedOptionsA = $("#age").find("option:selected");
                selectedOptionsA.each(function () {
                    var dataNameValue = $(this).data("name");
                    ageTxt.push(dataNameValue);
                });

                var selectedOptionsTE = $("#terminal").find("option:selected");
                selectedOptionsTE.each(function () {
                    var dataNameValue = $(this).data("name");
                    terminalTxt.push(dataNameValue);
                });

                var selectedOptionsTR = $("#traveller").find("option:selected");
                selectedOptionsTR.each(function () {
                    var dataNameValue = $(this).data("name");
                    travellerTxt.push(dataNameValue);
                });

                var selectedOptionsIN = $("#income").find("option:selected");
                selectedOptionsIN.each(function () {
                    var dataNameValue = $(this).data("name");
                    incomeTxt.push(dataNameValue);
                });

                var selectedOptionsDTRIP = $("#domestic_trip").find("option:selected");
                selectedOptionsDTRIP.each(function () {
                    var dataNameValue = $(this).data("name");
                    domestictripTxt.push(dataNameValue);
                });

                var selectedOptionsITRIP = $("#international_trip").find("option:selected");
                selectedOptionsITRIP.each(function () {
                    var dataNameValue = $(this).data("name");
                    internationaltripTxt.push(dataNameValue);
                });

                var selectedOptionsR = $("#rot").find("option:selected");
                selectedOptionsR.each(function () {
                    var dataNameValue = $(this).data("name");
                    rotTxt.push(dataNameValue);
                });

                var selectedOptionsTY = $("#types").find("option:selected");
                selectedOptionsTY.each(function () {
                    var dataNameValue = $(this).data("name");
                    typesTxt.push(dataNameValue);
                });

                var selectedOptionsDD = $("#dwellD").find("option:selected");
                selectedOptionsDD.each(function () {
                    var dataNameValue = $(this).data("name");
                    dwellDTxt.push(dataNameValue);
                });

                var selectedOptionsDA = $("#dwellA").find("option:selected");
                selectedOptionsDA.each(function () {
                    var dataNameValue = $(this).data("name");
                    dwellATxt.push(dataNameValue);
                });

                var selectedOptionsTRAVE = $("#travelling").find("option:selected");
                selectedOptionsTRAVE.each(function () {
                    var dataNameValue = $(this).data("name");
                    travellingTxt.push(dataNameValue);
                });

                if((monthLengthY == 0) && (daysLengthY == 0) && (days_typeLengthY == 0) && (segmentLengthY == 0) && (cityLengthY == 0) && (genderLengthY == 0) && (ageLengthY == 0) && (terminalLengthY == 0) && (travellerLengthY == 0) && (incomeLengthY == 0) && (domestictripLengthY == 0) && (internationaltripLengthY == 0) && (rotLengthY == 0) && (typesLengthY == 0) && (dwellDLengthY == 0) && (dwellALengthY == 0) && (travellingLengthY == 0))
                {
                    conX = 1;
                }
                else
                {
                    conX = 2;
                }

                if(conX==2)
                {
                    filtercondX += `<b>Filters</b>: `;
                    // trendsfiltercondX += `<b>Trends Filters</b>: <b>Time Period</b> IN () || `;

                    if(monthLengthY != 0)
                    {
                        condX += `Q2 IN (${monthVal}) AND `;
                        trendcondX += `Q2 IN (${monthVal}) AND `;
                        filtercondX += `<b>Month</b> IN (${monthTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Month</b> IN (${monthTxt.join(", ")}) || `;
                    }

                    if(daysLengthY != 0)
                    {
                        condX += `Q3 IN (${daysVal}) AND `;
                        trendcondX += `Q3 IN (${daysVal}) AND `;
                        filtercondX += `<b>Days</b> IN (${daysTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Days</b> IN (${daysTxt.join(", ")}) || `;
                    }

                    if(days_typeLengthY != 0)
                    {
                        condX += `Q4 IN (${days_typeVal}) AND `;
                        trendcondX += `Q4 IN (${days_typeVal}) AND `;
                        filtercondX += `<b>Days</b> IN (${dayTypeTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Days</b> IN (${dayTypeTxt.join(", ")}) || `;
                    }

                    if(segmentLengthY != 0)
                    {
                        condX += `Q13a IN (${segmentVal}) AND `;
                        trendcondX += `Q13a IN (${segmentVal}) AND `;
                        filtercondX += `<b>Segment</b> IN (${segmentTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Segment</b> IN (${segmentTxt.join(", ")}) || `;
                    }

                    if(cityLengthY != 0)
                    {
                        condX += `Q5 IN (${cityVal}) AND `;
                        trendcondX += `Q5 IN (${cityVal}) AND `;
                        filtercondX += `<b>Airport</b> IN (${cityTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Airport</b> IN (${cityTxt.join(", ")}) || `;
                    }

                    if(genderLengthY != 0)
                    {
                        condX += `HQ8 IN (${genderVal}) AND `;
                        trendcondX += `HQ8 IN (${genderVal}) AND `;
                        filtercondX += `<b>Gender</b> IN (${genderTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Gender</b> IN (${genderTxt.join(", ")}) || `;
                    }

                    if(ageLengthY != 0)
                    {
                        condX += `HQ9 IN (${ageVal}) AND `;
                        trendcondX += `HQ9 IN (${ageVal}) AND `;
                        filtercondX += `<b>Age</b> IN (${ageTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Age</b> IN (${ageTxt.join(", ")}) || `;
                    }

                    if(terminalLengthY != 0)
                    {
                        condX += `Q5a IN (${terminalVal}) AND `;
                        trendcondX += `Q5a IN (${terminalVal}) AND `;
                        filtercondX += `<b>Terminal</b> IN (${terminalTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Terminal</b> IN (${terminalTxt.join(", ")}) || `;
                    }

                    if(travellerLengthY != 0)
                    {
                        condX += `Q14c IN (${travellerVal}) AND `;
                        trendcondX += `Q14c IN (${travellerVal}) AND `;
                        filtercondX += `<b>Traveller</b> IN (${travellerTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Traveller</b> IN (${travellerTxt.join(", ")}) || `;
                    }

                    if(incomeLengthY != 0)
                    {
                        condX += `Q11 IN (${incomeVal}) AND `;
                        trendcondX += `Q11 IN (${incomeVal}) AND `;
                        filtercondX += `<b>Income</b> IN (${incomeTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Income</b> IN (${incomeTxt.join(", ")}) || `;
                    }

                    if(domestictripLengthY != 0)
                    {
                        condX += `Q17a IN (${domestictripVal}) AND `;
                        trendcondX += `Q17a IN (${domestictripVal}) AND `;
                        filtercondX += `<b>Domestic Frequency of Travel</b> IN (${domestictripTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Domestic Frequency of Travel</b> IN (${domestictripTxt.join(", ")}) || `;
                    }

                    if(internationaltripLengthY != 0)
                    {
                        condX += `Q17b IN (${internationaltripVal}) AND `;
                        trendcondX += `Q17b IN (${internationaltripVal}) AND `;
                        filtercondX += `<b>International Frequency of Travel</b> IN (${internationaltripTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>International Frequency of Travel</b> IN (${internationaltripTxt.join(", ")}) || `;
                    }

                    if(rotLengthY != 0)
                    {
                        condX += `Q19 IN (${rotVal}) AND `;
                        trendcondX += `Q19 IN (${rotVal}) AND `;
                        filtercondX += `<b>Reason of Travel</b> IN (${rotTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Reason of Travel</b> IN (${rotTxt.join(", ")}) || `;
                    }

                    if(typesLengthY != 0)
                    {
                        condX += `Q13b IN (${typesVal}) AND `;
                        trendcondX += `Q13b IN (${typesVal}) AND `;
                        filtercondX += `<b>Types</b> IN (${typesTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Types</b> IN (${typesTxt.join(", ")}) || `;
                    }

                    if(dwellDLengthY != 0)
                    {
                        condX += `Q16a IN (${dwellDVal}) AND `;
                        trendcondX += `Q16a IN (${dwellDVal}) AND `;
                        filtercondX += `<b>Dwell Time Departure</b> IN (${dwellDTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Dwell Time Departure</b> IN (${dwellDTxt.join(", ")}) || `;
                    }

                    if(dwellALengthY != 0)
                    {
                        condX += `Q16b IN (${dwellAVal}) AND `;
                        trendcondX += `Q16b IN (${dwellAVal}) AND `;
                        filtercondX += `<b>Dwell Time Arrival</b> IN (${dwellATxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Dwell Time Arrival</b> IN (${dwellATxt.join(", ")}) || `;
                    }

                    if(travellingLengthY != 0)
                    {
                        condX += `Q18 IN (${travellingVal}) AND `;
                        trendcondX += `Q18 IN (${travellingVal}) AND `;
                        filtercondX += `<b>Travelling</b> IN (${travellingTxt.join(", ")}) || `;
                        trendsfiltercondX += `<b>Travelling</b> IN (${travellingTxt.join(", ")}) || `;
                    }

                }
                else
                {
                    filtercondX += `<b>Filters</b>: All Selected`;
                    trendsfiltercondX += `<b>Trends Filters</b>: <b>Time Period</b> IN () || `;
                }
                condX += ` 1=1`;
                // trendcondX += ` 1=1`;
                filtercondX = filtercondX.replace(/\|\| $/, '');
                // trendsfiltercondX = trendsfiltercondX.replace(/\|\| $/, '');
                $(".paraY").empty().append(filtercondX);
                // $(".paraYT").empty().append(trendsfiltercondX);

                // //console.log("condX");
                // //console.log(condX);
                // //console.log("trendcondX");
                // //console.log(trendcondX);
                // //console.log("filtercondX");
                // //console.log(filtercondX);
                // //console.log("trendsfiltercondX");
                // //console.log(trendsfiltercondX);

                fetchBase();

                statusArr.forEach(function(e,i,a){
                    e.forEach(function(e2,i2,a2){
                        if(e2=="active")
                        {
                            if(trendStatus===false)
                            {
                                if(functionFlag[i][i2]===false)
                                {
                                    const selectedFunction = allAjax[i][i2];
                                    functionFlag[i][i2] = true;
                                    selectedFunction();
                                }
                                else{}
                            }
                            else
                            {
                                if(functionFlagT[i][i2]===false)
                                {
                                    const selectedFunction = trendsAjax[i][i2];
                                    functionFlagT[i][i2] = true;
                                    selectedFunction();
                                }
                            }
                        }
                        else{}
                    });
                });

                //console.log(statusArr);
                //console.log(functionFlag);
            }

            //=================================Trends Start============================================
            function trends(type)
            {
                // 1 means show trends
                // 2 means hide trends
                if(type==1)
                {
                    $("#trends_open_div").hide();
                    $("#trends_close_div").show();
                    $("#swap_tbl_btn").hide();

                    $(".chart_div").hide();
                    $(".tbl_div").hide();
                    $(".chart_divT").show();

                    $("#timeField").show();

                    $("#weekField").hide();
                    $("#weekdayField").hide();
                    $("#dateField").hide();

                    $("#filterdefination_overall_div").hide();
                    $("#filterdefination_trend_div").show();

                    trendStatus = true;
                    $(window).trigger('resize');

                    //console.log("functionFlagT");
                    //console.log(functionFlagT);


                    if(functionFlagT[dataOuter][dataInner]===false)
                    {
                        applyF();
                    }
                }
                else
                {
                    $("#trends_open_div").show();
                    $("#trends_close_div").hide();
                    $("#swap_tbl_btn").show();

                    $(".chart_div").show();
                    $(".tbl_div").hide();
                    $(".chart_divT").hide();

                    $("#timeField").hide();

                    $("#weekField").show();
                    $("#weekdayField").show();
                    $("#dateField").show();

                    $("#filterdefination_overall_div").show();
                    $("#filterdefination_trend_div").hide();

                    trendStatus = false;
                    $(window).trigger('resize');
                }
            }
            //=================================Trends END============================================

            function swapTable(thisX,type)
            {
                //debugger;
                var getTxt = $(thisX).attr('data-value');
                if(getTxt=="Tbl")
                {
                    $(".chart_div").hide();
                    $(".tbl_div").show();
                    $("#trends_open_div").hide();
                    $(thisX).attr('data-value','Chart');
                    $(thisX).html('Show Chart');
                    $("#swap_chart_btn").hide();
                    $("#data_type").hide();
                    $("#data_type").next().hide();
                    $("#swap_zero_btn").show();

                    tableStatus = true;
                }
                else
                {
                    $(".chart_div").show();
                    $(".tbl_div").hide();
                    $("#trends_open_div").show();
                    $(thisX).attr('data-value','Tbl');
                    $(thisX).html('Show Table');
                    $("#swap_chart_btn").show();
                    $("#data_type").show();
                    $("#data_type").next().show();
                    $("#swap_zero_btn").hide();

                    if(innerText=="NPS")
                    {
                        $("#data_type").hide();
                        $("#data_type").next().hide();
                    }
                    else
                    {
                        $("#data_type").show();
                        $("#data_type").next().show();
                    }
                    tableStatus = false;
                }
            }

            function zeroLogic(thisX)
            {
                //debugger;
                var getTxt = $(thisX).attr('data-value');
                if(getTxt=="Zero")
                {
                    $('#tbl_profile tbody tr:eq(1)').each(function(){

                        $(this).find('td').each(function(index){

                            if($(this).text().trim() === "0.0%"){

                                $('#tbl_profile thead tr:eq(1) th').eq(index + 2).hide();

                                $('#tbl_profile tbody tr').each(function(){

                                    //debugger;
                                    $(this).find('td').eq(index).hide();
                                });
                            }
                        });
                    });

                    $('#tbl_profile2 tbody tr:eq(1)').each(function(){

                        $(this).find('td').each(function(index){

                            if($(this).text().trim() === "0.0%"){

                                $('#tbl_profile2 thead tr:eq(1) th').eq(index + 2).hide();

                                $('#tbl_profile2 tbody tr').each(function(){

                                    //debugger;
                                    $(this).find('td').eq(index).hide();
                                });
                            }
                        });
                    });
                    $(thisX).attr('data-value','NotZero');
                    $(thisX).html('Show Zero');
                    zeroStatus = true;

                    $('table:not(.non-zero) tbody tr').each(function() {
                        var firstTd = $(this).find('td').first();
                        var tdValue = parseInt(firstTd.text(), 10);
                        if (tdValue === 0) {
                            $(this).hide();
                        }
                    });
                }
                else
                {
                    $(thisX).attr('data-value','Zero');
                    $(thisX).html('Hide Zero');
                    zeroStatus = false;

                    $('#tbl_profile tbody tr:eq(1)').each(function(){

                        $(this).find('td').each(function(index){

                            if($(this).text().trim() === "0.0%"){

                                $('#tbl_profile thead tr:eq(1) th').eq(index + 2).show();

                                $('#tbl_profile tbody tr').each(function(){

                                    //debugger;
                                    $(this).find('td').eq(index).show();
                                });
                            }
                        });
                    });

                    $('#tbl_profile2 tbody tr:eq(1)').each(function(){

                        $(this).find('td').each(function(index){

                            if($(this).text().trim() === "0.0%"){

                                $('#tbl_profile2 thead tr:eq(1) th').eq(index + 2).show();

                                $('#tbl_profile2 tbody tr').each(function(){

                                    //debugger;
                                    $(this).find('td').eq(index).show();
                                });
                            }
                        });
                    });

                    $('table:not(.non-zero) tbody tr').each(function() {
                        var firstTd = $(this).find('td').first();
                        var tdValue = parseInt(firstTd.text(), 10);
                        if (tdValue === 0) {
                            $(this).show();
                        }
                    });
                }
            }

//------------------------------------------------------------ Data Transformation Functions START -------------------------------------------//

function extractValues(array,valueArray,baseArray,countArray,valueType)
{
    if(valueType=="Overall")
    {
        array.forEach(function(e,i,a){
            valueArray.push(e.percentage);
            baseArray.push(e.bCount);
            countArray.push(e.cCount);
        });
    }
    else
    {
        array.forEach(function(e,i,a){
            var arrayV2 = [];
            var arrayB2 = [];
            var arrayC2 = [];
            e.forEach(function(e2,i2,a2){
                arrayV2.push(e2.percentage);
                arrayB2.push(e2.bCount);
                arrayC2.push(e2.cCount);
            });
            valueArray.push(arrayV2);
            baseArray.push(arrayB2);
            countArray.push(arrayC2);
        });
    }
}  

function customizedArray(array,valueArray,labelArray,colorLabel,chartType)
{
    if(chartType=="Doughnut")
    {
        array.forEach(function(e,i,a){
            var valueE = {
                name: labelArray[i],
                y: e,
                color: colorLabel[i]
            };
            valueArray.push(valueE);
        });
    }
    else if(chartType=="StackBar")
    {
        array.forEach(function(e,i,a){
            var valueE = {
                name: labelArray[i],
                data: e,
                color: colorLabel[i]
            };
            valueArray.push(valueE);
        });
    }
    else if(chartType=="Line")
    {
        array.forEach(function(e,i,a){
            var valueE = {
                name: labelArray[i],
                data: e,
            };
            valueArray.push(valueE);
        });
    }
    else if(chartType=="Heat")
    {
        const result = array.flatMap((row, rowIndex) => 
            row.map((value, colIndex) => [rowIndex, colIndex, value])
        );
        valueArray.push(result);
    }
    else if(chartType=="Bubble")
    {
        array.forEach(function(e, i) {
            var arrX = {
                name: labelArray[i],
                data: [],
                marker: {
                    fillColor: radialColors[i]
                }
            };
            e.forEach(function(e2, i2) {
                var dataPoint = {
                    x: i2,
                    y: i,
                    z: e2
                };
                arrX.data.push(dataPoint);
            });
            valueArray.push(arrX);
        });
    }
    else
    {
        const dataX = airportName.map((airport, index) => ({
            'hc-key': airportDataMap[airport],
            value: array[index],
            name: airport
        }));

        valueArray.push(dataX);
    }
    
}

function transposeData(data) {
    return data[0].map((col, i) => data.map(row => row[i]));
}

function customizedArray2(array,valueArray,labelArray)
{
    array.forEach(function(e,i,a){
        var XX = [];
        e.forEach(function(e2,i2,a2){
            var valueE = {
                name: labelArray[i],
                x: e2,
                y: e2
            };
            valueArray.push(valueE);
        });
        valueArray.push(XX);
    });
}

function formtable(value,label,category,id)
{
    // var transposeValue  = transposeData(value);

    var htmlX = ``;
    htmlX += `<tr>`;
    htmlX += `<th>Airport</th>`;
    category.forEach(function(e,i,a){
        htmlX += `<th>${e}</th>`;
    });
    htmlX += `</tr>`;

    $(`#${id} > thead`).empty().append(htmlX);

    var htmlZ = ``;
    
    value.forEach(function(e,i,a){
        htmlZ += `<tr>`;
        htmlZ += `<th>${label[i]}</th>`;
        e.forEach(function(e2,i2,a2){
            htmlZ += `<td>${e2}%</td>`;
        });
        htmlZ += `</tr>`;
    });
    
    $(`#${id} > tbody`).empty().append(htmlZ);
}

// function clickableSlice(divId, dropdownName, optionName) 
// {
//     debugger;
//     if (dropdownName == "dwell departure") 
//     {
//         dropdownName = "dwellD";
//     } 
//     else if (dropdownName == "dwell arrival") 
//     {
//         dropdownName = "dwellA";
//     } 
//     else if (dropdownName == "frequency international") 
//     {
//         dropdownName = "international_trip";
//     } 
//     else if (dropdownName == "frequency domestic") 
//     {
//         dropdownName = "domestic_trip";
//     } 
//     else if (dropdownName == "purpose") 
//     {
//         dropdownName = "rot";
//     }

//     var option = $("#" + dropdownName + " option[data-name='" + optionName + "']");
//     if (option.is(':selected') === true) 
//     {
//         option.prop('selected', false);
//     } else 
//     {
//         option.prop('selected', true);
//     }

//     $("#"+dropdownName+"").multiselect('rebuild');
//     $("#"+dropdownName+"").change();
//     debugger;
//     if(dropdownName=="gender")
//     {

//         var imgElement = $(divId).find(".gender_img")
//         if (option.is(':selected')) 
//         {
//             if(optionName=='Male')
//             {
//                 imgElement.addClass('male_selected_shadow');
//             }
//             else
//             {
//                 imgElement.addClass('female_selected_shadow');
//             }
//         } 
//         else 
//         {
//             if(optionName=='Male')
//             {
//                 imgElement.removeClass('male_selected_shadow');
//             }
//             else
//             {
//                 imgElement.removeClass('female_selected_shadow');
//             }
//         }
//     }
//     else
//     {
//         var chart = Highcharts.charts.find(chart => chart.renderTo.id === divId);
    
//         if(chart) 
//         {
//             var sliceIndex = chart.series[0].data.findIndex(function(point) {
//                 return point.name === optionName;
//             });

//             if (sliceIndex !== -1) 
//             {
//                 var selectedSlice = chart.series[0].data[sliceIndex];
                
//                 if (option.is(':selected')) 
//                 {
//                     selectedSlice.update({
//                         borderWidth: 3,
//                         borderColor: '#000000',
//                     });
//                 } else 
//                 {
//                     selectedSlice.update({
//                         borderWidth: 1,
//                         borderColor: '#ccc',
//                         //color: null
//                     });
//                 }
//             }
//         }
//     }
//     flagConstruct();
// }


function clickableSlice(divId, dataNameX, dropdownName, optionName, types, types2)
{
    debugger;
    if(dropdownName=="dwell departure")
    {
        dropdownName = "dwellD";
    }
    else if(dropdownName=="dwell arrival")
    {
        dropdownName = "dwellA";
    }
    else if(dropdownName=="frequency international")
    {
        dropdownName = "international_trip";
    }
    else if(dropdownName=="frequency domestic")
    {
        dropdownName = "domestic_trip";
    }
    else if(dropdownName=="purpose")
    {
        dropdownName = "rot";
    }

    if(types2=="fresh")
    {
        var option = $("#"+dropdownName+" option[data-name='" + optionName + "']");
        if (option.is(':selected') === true) 
        {
            option.prop('selected', false);
        } 
        else 
        {
            option.prop('selected', true);
        }
        $("#"+dropdownName+"").multiselect('rebuild');
        $("#"+dropdownName+"").change();

        if(types=="charts")
        {
            debugger;
            $(`[data-name="${dataNameX}"]`).each(function() {
                var chart = $(this).highcharts();
                if(chart) 
                {
                    var sliceIndex = chart.series[0].data.findIndex(function(point) {
                        return point.name === optionName;
                    });

                    if (sliceIndex !== -1) 
                    {
                        var selectedSlice = chart.series[0].data[sliceIndex];
                        
                        if (option.is(':selected')) 
                        {
                            selectedSlice.update({
                                borderWidth: 3,
                                borderColor: '#000000',
                            });
                        } 
                        else 
                        {
                            selectedSlice.update({
                                borderWidth: 1,
                                borderColor: '#ccc',
                            });
                        }
                    }
                }
            });
        }
        else
        {
            $(`[data-name="${dataNameX}"]`).each(function() {
                if (option.is(':selected')) 
                {
                    if(optionName=='Male')
                    {
                        $(this).find("img").addClass('male_selected_shadow');
                    }
                    else
                    {
                        $(this).find("img").addClass('female_selected_shadow');
                    }
                } 
                else 
                {
                    if(optionName=='Male')
                    {
                        $(this).find("img").removeClass('male_selected_shadow');
                    }
                    else
                    {
                        $(this).find("img").removeClass('female_selected_shadow');
                    }
                }
            });
        }
        flagConstruct();
    }
    else
    {
        if(types=="charts")
        {
            debugger;
            //dataNameX.forEach(function(e,i,a){
                $(`[data-name="${dataNameX}"]`).each(function() {
                    var chart = $(this).highcharts();
                    if(chart) 
                    {
                        optionName.forEach(function(e,i,a){

                            var option = $("#"+dropdownName+" option[data-name='" + e + "']");

                            var sliceIndex = chart.series[0].data.findIndex(function(point) {
                                return point.name === e;
                            });
                            if (sliceIndex !== -1) 
                            {
                                var selectedSlice = chart.series[0].data[sliceIndex];
                                
                                if (option.is(':selected')) 
                                {
                                    selectedSlice.update({
                                        borderWidth: 3,
                                        borderColor: '#000000',
                                    });
                                } 
                                else 
                                {
                                    selectedSlice.update({
                                        borderWidth: 1,
                                        borderColor: '#ccc',
                                    });
                                }
                            }
                        });
                    }
                });
            //});
        }
        else
        {
            // var imgElement = $(divId).find(".gender_img")
            // if (option.is(':selected')) 
            // {
            //     if(optionName=='Male')
            //     {
            //         imgElement.addClass('male_selected_shadow');
            //     }
            //     else
            //     {
            //         imgElement.addClass('female_selected_shadow');
            //     }
            // } 
            // else 
            // {
            //     if(optionName=='Male')
            //     {
            //         imgElement.removeClass('male_selected_shadow');
            //     }
            //     else
            //     {
            //         imgElement.removeClass('female_selected_shadow');
            //     }
            // }
        }
    }
}


function clickableSlice2()
{
    
    var ageLengthY = $("#age option:selected").length;
    var incomeLengthY = $("#income option:selected").length;
    if(ageLengthY != 0)
    {
        clickableSlice("XX","age_profiling_chart","age",ageTxt,"charts","filters")
    }
    if(incomeLengthY != 0)
    {
        clickableSlice("XX","income_profiling_chart","income",incomeTxt,"charts","filters")
    }
}



//------------------------------------------------------------ Data Transformation Functions END --------------------------------------------//

// ------------------------------------------------------------ AJAX START ----------------------------------------------------- //

function fetchBase()
{
    //debugger;
    $.ajax({
        url: "api/base.php",
        type: "POST",
        data: {
            'condX' : condX,
            'conX' : conX,
            'tblX' : "tbl_1"
        },
        success: function(response) {
            var data = JSON.parse(response);
            overallBase = data['overall_base'];

            var htmlBase = `<h6 class="ml-2 mt-2"><b>Sample Size: ${overallBase}</b></h6>`;
            $("#overallBase").empty().append(htmlBase);
        }
    });
}

function profileAjax()
{
    $.ajax({
        url: "api/profile.php",
        type: "POST",
        data: {
            'condX' : condX,
            'conX' : conX,
            'tblX' : "tbl_1",
            'tabStatus' : overallBaseStatus
        },
        success: function(response) {
            var data = JSON.parse(response);
            
            if(overallBaseStatus==false)
            {
                var airportOverallValue = [];
                var airportOverallBase = [];
                var airportOverallCount = [];
                var airportOverallFinal = [];

                var ageOverallValue = [];
                var ageOverallBase = [];
                var ageOverallCount = [];
                var ageOverallFinal = [];

                var genderOverallValue = [];
                var genderOverallBase = [];
                var genderOverallCount = [];
                var genderOverallFinal = [];

                var incomeOverallValue = [];
                var incomeOverallBase = [];
                var incomeOverallCount = [];
                var incomeOverallFinal = [];

                var segmentOverallValue = [];
                var segmentOverallBase = [];
                var segmentOverallCount = [];
                var segmentOverallFinal = [];

                var typesOverallValue = [];
                var typesOverallBase = [];
                var typesOverallCount = [];
                var typesOverallFinal = [];

                var dwellOverallValueD = [];
                var dwellOverallBaseD = [];
                var dwellOverallCountD = [];
                var dwellOverallFinalD = [];

                var dwellOverallValueA = [];
                var dwellOverallBaseA = [];
                var dwellOverallCountA = [];
                var dwellOverallFinalA = [];

                var frequencyOverallValueI = [];
                var frequencyOverallBaseI = [];
                var frequencyOverallCountI = [];
                var frequencyOverallFinalI = [];

                var frequencyOverallValueD = [];
                var frequencyOverallBaseD = [];
                var frequencyOverallCountD = [];
                var frequencyOverallFinalD = [];

                var travellingOverallValue = [];
                var travellingOverallBase = [];
                var travellingOverallCount = [];
                var travellingOverallFinal = [];

                var purposeOverallValue = [];
                var purposeOverallBase = [];
                var purposeOverallCount = [];
                var purposeOverallFinal = [];

                var terminalOverallValue = [];
                var terminalOverallBase = [];
                var terminalOverallCount = [];
                var terminalOverallFinal = [];

                var travellerOverallValue = [];
                var travellerOverallBase = [];
                var travellerOverallCount = [];
                var travellerOverallFinal = [];

                var airportOverall = data['airportOverall'];
                var ageOverall = data['ageOverall'];
                var genderOverall = data['genderOverall'];
                var incomeOverall = data['incomeOverall'];
                var segmentOverall = data['segmentOverall'];
                var typesOverall = data['typesOverall'];
                var dwellOverallD = data['dwellOverallD'];
                var dwellOverallA = data['dwellOverallA'];
                var frequencyOverallD = data['frequencyOverallD'];
                var frequencyOverallI = data['frequencyOverallI'];
                var travellingOverall = data['travellingOverall'];
                var purposeOverall = data['purposeOverall'];
                var terminalOverall = data['terminalOverall'];
                var travellerOverall = data['travellerOverall'];

                extractValues(airportOverall,airportOverallValue,airportOverallBase,airportOverallCount,"Overall");
                customizedArray(airportOverallValue,airportOverallFinal,airportName,radialColors,"Map");
            
                extractValues(ageOverall,ageOverallValue,ageOverallBase,ageOverallCount,"Overall");
                customizedArray(ageOverallValue,ageOverallFinal,ageLabel,radialColors,"Doughnut");

                extractValues(genderOverall,genderOverallValue,genderOverallBase,genderOverallCount,"Overall");
                //customizedArray(genderOverallValue,genderOverallFinal,genderLabel,twoRadialColor2,"Doughnut");

                extractValues(incomeOverall,incomeOverallValue,incomeOverallBase,incomeOverallCount,"Overall");
                customizedArray(incomeOverallValue,incomeOverallFinal,incomeLabel,radialColors,"Doughnut");

                extractValues(segmentOverall,segmentOverallValue,segmentOverallBase,segmentOverallCount,"Overall");
                customizedArray(segmentOverallValue,segmentOverallFinal,segmentLabel,radialColors,"Doughnut");
                
                extractValues(typesOverall,typesOverallValue,typesOverallBase,typesOverallCount,"Overall");
                customizedArray(typesOverallValue,typesOverallFinal,typesLabel,radialColors,"Doughnut");
                
                extractValues(dwellOverallD,dwellOverallValueD,dwellOverallBaseD,dwellOverallCountD,"Overall");
                customizedArray(dwellOverallValueD,dwellOverallFinalD,dwellLabel,radialColors,"Doughnut");
            
                extractValues(dwellOverallA,dwellOverallValueA,dwellOverallBaseA,dwellOverallCountA,"Overall");
                customizedArray(dwellOverallValueA,dwellOverallFinalA,dwellLabel,radialColors,"Doughnut");

                extractValues(frequencyOverallI,frequencyOverallValueI,frequencyOverallBaseI,frequencyOverallCountI,"Overall");
                customizedArray(frequencyOverallValueI,frequencyOverallFinalI,tripLabel,radialColors,"Doughnut");

                extractValues(frequencyOverallD,frequencyOverallValueD,frequencyOverallBaseD,frequencyOverallCountD,"Overall");
                customizedArray(frequencyOverallValueD,frequencyOverallFinalD,tripLabel,radialColors,"Doughnut");

                extractValues(travellingOverall,travellingOverallValue,travellingOverallBase,travellingOverallCount,"Overall");
                customizedArray(travellingOverallValue,travellingOverallFinal,travellingLabel,radialColors,"Doughnut");

                extractValues(purposeOverall,purposeOverallValue,purposeOverallBase,purposeOverallCount,"Overall");
                customizedArray(purposeOverallValue,purposeOverallFinal,purposeLabel,radialColors,"Doughnut");

                extractValues(terminalOverall,terminalOverallValue,terminalOverallBase,terminalOverallCount,"Overall");
                customizedArray(terminalOverallValue,terminalOverallFinal,terminalLabel,radialColors,"Doughnut");

                extractValues(travellerOverall,travellerOverallValue,travellerOverallBase,travellerOverallCount,"Overall");
                customizedArray(travellerOverallValue,travellerOverallFinal,travellerLabel,radialColors,"Doughnut");

                $("#male_value").empty().append(genderOverallValue[0]+"%");
                $("#female_value").empty().append(genderOverallValue[1]+"%");

                doughnutChart(ageOverallFinal,"age_op","Age");
                //doughnutChart(genderOverallFinal,"gender_op","Gender");
                doughnutChart(incomeOverallFinal,"income_op","Income");
                doughnutChart(segmentOverallFinal,"segment_op","Segment");
                doughnutChart(typesOverallFinal,"type_op","Types");
                doughnutChart(dwellOverallFinalD,"dwell_opD","Dwell Departure");
                doughnutChart(dwellOverallFinalA,"dwell_opA","Dwell Arrival");
                doughnutChart(frequencyOverallFinalI,"frequency_opI","Frequency International");
                doughnutChart(frequencyOverallFinalD,"frequency_opD","Frequency Domestic");
                doughnutChart(travellingOverallFinal,"travelling_op","Travelling");
                doughnutChart(purposeOverallFinal,"purpose_op","Purpose");
                doughnutChart(terminalOverallFinal,"terminal_op","Terminal");
                doughnutChart(travellerOverallFinal,"traveller_op","Traveller");

            }
            
            var ageAirportValue = [];
            var ageAirportBase = [];
            var ageAirportCount = [];
            var ageAirportFinal = [];

            var genderAirportValue = [];
            var genderAirportBase = [];
            var genderAirportCount = [];
            var genderAirportFinal = [];

            var incomeAirportValue = [];
            var incomeAirportBase = [];
            var incomeAirportCount = [];
            var incomeAirportFinal = [];

            var segmentAirportValue = [];
            var segmentAirportBase = [];
            var segmentAirportCount = [];
            var segmentAirportFinal = [];

            var typesAirportValue = [];
            var typesAirportBase = [];
            var typesAirportCount = [];
            var typesAirportFinal = [];
            
            var dwellAirportValueD = [];
            var dwellAirportBaseD = [];
            var dwellAirportCountD = [];
            var dwellAirportFinalD = [];

            var dwellAirportValueA = [];
            var dwellAirportBaseA = [];
            var dwellAirportCountA = [];
            var dwellAirportFinalA = [];

            var frequencyAirportValueI = [];
            var frequencyAirportBaseI = [];
            var frequencyAirportCountI = [];
            var frequencyAirportFinalI = [];

            var frequencyAirportValueD = [];
            var frequencyAirportBaseD = [];
            var frequencyAirportCountD = [];
            var frequencyAirportFinalD = [];

            var travellingAirportValue = [];
            var travellingAirportBase = [];
            var travellingAirportCount = [];
            var travellingAirportFinal = [];

            var purposeAirportValue = [];
            var purposeAirportBase = [];
            var purposeAirportCount = [];
            var purposeAirportFinal = [];

            var terminalAirportValue = [];
            var terminalAirportBase = [];
            var terminalAirportCount = [];
            var terminalAirportFinal = [];

            var travellerAirportValue = [];
            var travellerAirportBase = [];
            var travellerAirportCount = [];
            var travellerAirportFinal = [];
            
            var ageAirport = data['ageAirport'];
            var genderAirport = data['genderAirport'];
            var incomeAirport = data['incomeAirport'];
            var segmentAirport = data['segmentAirport'];
            var typesAirport = data['typesAirport'];
            var dwellAirportD = data['dwellAirportD'];
            var dwellAirportA = data['dwellAirportA'];
            var frequencyAirportD = data['frequencyAirportD'];
            var frequencyAirportI = data['frequencyAirportI'];
            var travellingAirport = data['travellingAirport'];
            var purposeAirport = data['purposeAirport'];
            var terminalAirport = data['terminalAirport'];
            var travellerAirport = data['travellerAirport'];

            extractValues(ageAirport,ageAirportValue,ageAirportBase,ageAirportCount,"Airport");
            customizedArray(ageAirportValue,ageAirportFinal,ageLabel,radialColors,"StackBar");

            extractValues(genderAirport,genderAirportValue,genderAirportBase,genderAirportCount,"Airport");
            customizedArray(genderAirportValue,genderAirportFinal,genderLabel,twoRadialColor2,"StackBar");

            extractValues(incomeAirport,incomeAirportValue,incomeAirportBase,incomeAirportCount,"Airport");
            customizedArray(incomeAirportValue,incomeAirportFinal,incomeLabel,radialColors,"StackBar");

            extractValues(segmentAirport,segmentAirportValue,segmentAirportBase,segmentAirportCount,"Airport");
            customizedArray(segmentAirportValue,segmentAirportFinal,segmentLabel,radialColors,"StackBar");

            extractValues(typesAirport,typesAirportValue,typesAirportBase,typesAirportCount,"Airport");
            customizedArray(typesAirportValue,typesAirportFinal,typesLabel,radialColors,"StackBar");

            extractValues(dwellAirportD,dwellAirportValueD,dwellAirportBaseD,dwellAirportCountD,"Airport");
            customizedArray(dwellAirportValueD,dwellAirportFinalD,dwellLabel,radialColors,"StackBar");

            extractValues(dwellAirportA,dwellAirportValueA,dwellAirportBaseA,dwellAirportCountA,"Airport");
            customizedArray(dwellAirportValueA,dwellAirportFinalA,dwellLabel,radialColors,"StackBar");

            extractValues(frequencyAirportI,frequencyAirportValueI,frequencyAirportBaseI,frequencyAirportCountI,"Airport");
            customizedArray(frequencyAirportValueI,frequencyAirportFinalI,tripLabel,radialColors,"StackBar");

            extractValues(frequencyAirportD,frequencyAirportValueD,frequencyAirportBaseD,frequencyAirportCountD,"Airport");
            customizedArray(frequencyAirportValueD,frequencyAirportFinalD,tripLabel,radialColors,"StackBar");
            
            extractValues(travellingAirport,travellingAirportValue,travellingAirportBase,travellingAirportCount,"Airport");
            customizedArray(travellingAirportValue,travellingAirportFinal,travellingLabel,radialColors,"StackBar");

            extractValues(purposeAirport,purposeAirportValue,purposeAirportBase,purposeAirportCount,"Airport");
            customizedArray(purposeAirportValue,purposeAirportFinal,purposeLabel,radialColors,"StackBar");

            extractValues(terminalAirport,terminalAirportValue,terminalAirportBase,terminalAirportCount,"Airport");
            customizedArray(terminalAirportValue,terminalAirportFinal,terminalLabel,radialColors,"StackBar");

            extractValues(travellerAirport,travellerAirportValue,travellerAirportBase,travellerAirportCount,"Airport");
            customizedArray(travellerAirportValue,travellerAirportFinal,travellerLabel,radialColors,"StackBar");

            stackbarChart(genderAirportFinal,genderAirportBase,"gender_ap");
            stackcolumnChart(ageAirportFinal,ageAirportBase,"age_ap");
            stackbarChart(incomeAirportFinal,incomeAirportBase,"income_ap");
            stackcolumnChart(segmentAirportFinal,segmentAirportBase,"segment_ap");
            stackbarChart(typesAirportFinal,typesAirportBase,"type_ap");
            stackcolumnChart(dwellAirportFinalD,dwellAirportBaseD,"dwell_apD");
            stackbarChart(dwellAirportFinalA,dwellAirportBaseA,"dwell_apA");
            stackcolumnChart(frequencyAirportFinalI,frequencyAirportBaseI,"frequency_apI");
            stackbarChart(frequencyAirportFinalD,frequencyAirportBaseD,"frequency_apD");
            stackcolumnChart(travellingAirportFinal,travellingAirportBase,"travelling_ap");
            stackcolumnChart(purposeAirportFinal,purposeAirportBase,"purpose_ap");
            stackcolumnChart(terminalAirportFinal,terminalAirportBase,"terminal_ap");
            stackcolumnChart(travellerAirportFinal,travellerAirportBase,"traveller_ap");

            // countryChart(airportOverallFinal[0],"country_chart");
        },
        complete: function (data) 
        {
            $(".splash").hide();
            overallBaseStatus = true
        }
    });
}

function firstAjax()
{
    $.ajax({
        url: "api/ajax1.php",
        type: "POST",
        data: {
            'condX' : condX,
            'conX' : conX,
            'tblX' : "tbl_1",
            'tabStatus' : dutyFreeStatus
        },
        success: function(response) {
            var data = JSON.parse(response);
            console.log(data);
            debugger;
            if(dutyFreeStatus==false)
            {
                var airportOverallShopper = data['airportOverall_s'];
                var ageOverallShopper = data['ageOverall_s'];
                var genderOverallShopper = data['genderOverall_s'];
                var incomeOverallShopper = data['incomeOverall_s'];
                var segmentOverallShopper = data['segmentOverall_s'];
                var typesOverallShopper = data['typesOverall_s'];
                var dwellOverallDShopper = data['dwellOverallD_s'];
                var dwellOverallAShopper = data['dwellOverallA_s'];
                var frequencyOverallDShopper = data['frequencyOverallD_s'];
                var frequencyOverallIShopper = data['frequencyOverallI_s'];
                var travellingOverallShopper = data['travellingOverall_s'];
                var purposeOverallShopper = data['purposeOverall_s'];
                var terminalOverallShopper = data['terminalOverall_s'];
                var travellerOverallShopper = data['travellerOverall_s'];

                var airportOverallNonShopper = data['airportOverall_ns'];
                var ageOverallNonShopper = data['ageOverall_ns'];
                var genderOverallNonShopper = data['genderOverall_ns'];
                var incomeOverallNonShopper = data['incomeOverall_ns'];
                var segmentOverallNonShopper = data['segmentOverall_ns'];
                var typesOverallNonShopper = data['typesOverall_ns'];
                var dwellOverallDNonShopper = data['dwellOverallD_ns'];
                var dwellOverallANonShopper = data['dwellOverallA_ns'];
                var frequencyOverallDNonShopper = data['frequencyOverallD_ns'];
                var frequencyOverallINonShopper = data['frequencyOverallI_ns'];
                var travellingOverallNonShopper = data['travellingOverall_ns'];
                var purposeOverallNonShopper = data['purposeOverall_ns'];
                var terminalOverallNonShopper = data['terminalOverall_ns'];
                var travellerOverallNonShopper = data['travellerOverall_ns'];


                var airportOverallValueShopper = [];
                var airportOverallBaseShopper = [];
                var airportOverallCountShopper = [];
                var airportOverallFinalShopper = [];

                var ageOverallValueShopper = [];
                var ageOverallBaseShopper = [];
                var ageOverallCountShopper = [];
                var ageOverallFinalShopper = [];

                var genderOverallValueShopper = [];
                var genderOverallBaseShopper = [];
                var genderOverallCountShopper = [];
                var genderOverallFinalShopper = [];

                var incomeOverallValueShopper = [];
                var incomeOverallBaseShopper = [];
                var incomeOverallCountShopper = [];
                var incomeOverallFinalShopper = [];

                var segmentOverallValueShopper = [];
                var segmentOverallBaseShopper = [];
                var segmentOverallCountShopper = [];
                var segmentOverallFinalShopper = [];

                var typesOverallValueShopper = [];
                var typesOverallBaseShopper = [];
                var typesOverallCountShopper = [];
                var typesOverallFinalShopper = [];

                var dwellOverallValueDShopper = [];
                var dwellOverallBaseDShopper = [];
                var dwellOverallCountDShopper = [];
                var dwellOverallFinalDShopper = [];

                var dwellOverallValueAShopper = [];
                var dwellOverallBaseAShopper = [];
                var dwellOverallCountAShopper = [];
                var dwellOverallFinalAShopper = [];

                var frequencyOverallValueIShopper = [];
                var frequencyOverallBaseIShopper = [];
                var frequencyOverallCountIShopper = [];
                var frequencyOverallFinalIShopper = [];

                var frequencyOverallValueDShopper = [];
                var frequencyOverallBaseDShopper = [];
                var frequencyOverallCountDShopper = [];
                var frequencyOverallFinalDShopper = [];

                var travellingOverallValueShopper = [];
                var travellingOverallBaseShopper = [];
                var travellingOverallCountShopper = [];
                var travellingOverallFinalShopper = [];

                var purposeOverallValueShopper = [];
                var purposeOverallBaseShopper = [];
                var purposeOverallCountShopper = [];
                var purposeOverallFinalShopper = [];

                var terminalOverallValueShopper = [];
                var terminalOverallBaseShopper = [];
                var terminalOverallCountShopper = [];
                var terminalOverallFinalShopper = [];

                var travellerOverallValueShopper = [];
                var travellerOverallBaseShopper = [];
                var travellerOverallCountShopper = [];
                var travellerOverallFinalShopper = [];

                var airportOverallValueNonShopper = [];
                var airportOverallBaseNonShopper = [];
                var airportOverallCountNonShopper = [];
                var airportOverallFinalNonShopper = [];

                var ageOverallValueNonShopper = [];
                var ageOverallBaseNonShopper = [];
                var ageOverallCountNonShopper = [];
                var ageOverallFinalNonShopper = [];

                var genderOverallValueNonShopper = [];
                var genderOverallBaseNonShopper = [];
                var genderOverallCountNonShopper = [];
                var genderOverallFinalNonShopper = [];

                var incomeOverallValueNonShopper = [];
                var incomeOverallBaseNonShopper = [];
                var incomeOverallCountNonShopper = [];
                var incomeOverallFinalNonShopper = [];

                var segmentOverallValueNonShopper = [];
                var segmentOverallBaseNonShopper = [];
                var segmentOverallCountNonShopper = [];
                var segmentOverallFinalNonShopper = [];

                var typesOverallValueNonShopper = [];
                var typesOverallBaseNonShopper = [];
                var typesOverallCountNonShopper = [];
                var typesOverallFinalNonShopper = [];

                var dwellOverallValueDNonShopper = [];
                var dwellOverallBaseDNonShopper = [];
                var dwellOverallCountDNonShopper = [];
                var dwellOverallFinalDNonShopper = [];

                var dwellOverallValueANonShopper = [];
                var dwellOverallBaseANonShopper = [];
                var dwellOverallCountANonShopper = [];
                var dwellOverallFinalANonShopper = [];

                var frequencyOverallValueINonShopper = [];
                var frequencyOverallBaseINonShopper = [];
                var frequencyOverallCountINonShopper = [];
                var frequencyOverallFinalINonShopper = [];

                var frequencyOverallValueDNonShopper = [];
                var frequencyOverallBaseDNonShopper = [];
                var frequencyOverallCountDNonShopper = [];
                var frequencyOverallFinalDNonShopper = [];

                var travellingOverallValueNonShopper = [];
                var travellingOverallBaseNonShopper = [];
                var travellingOverallCountNonShopper = [];
                var travellingOverallFinalNonShopper = [];

                var purposeOverallValueNonShopper = [];
                var purposeOverallBaseNonShopper = [];
                var purposeOverallCountNonShopper = [];
                var purposeOverallFinalNonShopper = [];

                var terminalOverallValueNonShopper = [];
                var terminalOverallBaseNonShopper = [];
                var terminalOverallCountNonShopper = [];
                var terminalOverallFinalNonShopper = [];

                var travellerOverallValueNonShopper = [];
                var travellerOverallBaseNonShopper = [];
                var travellerOverallCountNonShopper = [];
                var travellerOverallFinalNonShopper = [];

                extractValues(airportOverallShopper,airportOverallValueShopper,airportOverallBaseShopper,airportOverallCountShopper,"Overall");
                customizedArray(airportOverallValueShopper,airportOverallFinalShopper,airportName,radialColors,"Map");
                
                extractValues(ageOverallShopper,ageOverallValueShopper,ageOverallBaseShopper,ageOverallCountShopper,"Overall");
                customizedArray(ageOverallValueShopper,ageOverallFinalShopper,ageLabel,radialColors,"Doughnut");

                extractValues(genderOverallShopper,genderOverallValueShopper,genderOverallBaseShopper,genderOverallCountShopper,"Overall");

                extractValues(incomeOverallShopper,incomeOverallValueShopper,incomeOverallBaseShopper,incomeOverallCountShopper,"Overall");
                customizedArray(incomeOverallValueShopper,incomeOverallFinalShopper,incomeLabel,radialColors,"Doughnut");

                extractValues(segmentOverallShopper,segmentOverallValueShopper,segmentOverallBaseShopper,segmentOverallCountShopper,"Overall");
                customizedArray(segmentOverallValueShopper,segmentOverallFinalShopper,segmentLabel,radialColors,"Doughnut");

                extractValues(typesOverallShopper,typesOverallValueShopper,typesOverallBaseShopper,typesOverallCountShopper,"Overall");
                customizedArray(typesOverallValueShopper,typesOverallFinalShopper,typesLabel,radialColors,"Doughnut");

                extractValues(dwellOverallDShopper,dwellOverallValueDShopper,dwellOverallBaseDShopper,dwellOverallCountDShopper,"Overall");
                customizedArray(dwellOverallValueDShopper,dwellOverallFinalDShopper,dwellLabel,radialColors,"Doughnut");

                extractValues(dwellOverallAShopper,dwellOverallValueAShopper,dwellOverallBaseAShopper,dwellOverallCountAShopper,"Overall");
                customizedArray(dwellOverallValueAShopper,dwellOverallFinalAShopper,dwellLabel,radialColors,"Doughnut");

                extractValues(frequencyOverallIShopper,frequencyOverallValueIShopper,frequencyOverallBaseIShopper,frequencyOverallCountIShopper,"Overall");
                customizedArray(frequencyOverallValueIShopper,frequencyOverallFinalIShopper,tripLabel,radialColors,"Doughnut");

                extractValues(frequencyOverallDShopper,frequencyOverallValueDShopper,frequencyOverallBaseDShopper,frequencyOverallCountDShopper,"Overall");
                customizedArray(frequencyOverallValueDShopper,frequencyOverallFinalDShopper,tripLabel,radialColors,"Doughnut");

                extractValues(travellingOverallShopper,travellingOverallValueShopper,travellingOverallBaseShopper,travellingOverallCountShopper,"Overall");
                customizedArray(travellingOverallValueShopper,travellingOverallFinalShopper,travellingLabel,radialColors,"Doughnut");

                extractValues(purposeOverallShopper,purposeOverallValueShopper,purposeOverallBaseShopper,purposeOverallCountShopper,"Overall");
                customizedArray(purposeOverallValueShopper,purposeOverallFinalShopper,purposeLabel,radialColors,"Doughnut");

                extractValues(terminalOverallShopper,terminalOverallValueShopper,terminalOverallBaseShopper,terminalOverallCountShopper,"Overall");
                customizedArray(terminalOverallValueShopper,terminalOverallFinalShopper,terminalLabel,radialColors,"Doughnut");

                extractValues(travellerOverallShopper,travellerOverallValueShopper,travellerOverallBaseShopper,travellerOverallCountShopper,"Overall");
                customizedArray(travellerOverallValueShopper,travellerOverallFinalShopper,travellerLabel,radialColors,"Doughnut");

                extractValues(airportOverallNonShopper,airportOverallValueNonShopper,airportOverallBaseNonShopper,airportOverallCountNonShopper,"Overall");
                customizedArray(airportOverallValueNonShopper,airportOverallFinalNonShopper,airportName,radialColors,"Map");
                
                extractValues(ageOverallNonShopper,ageOverallValueNonShopper,ageOverallBaseNonShopper,ageOverallCountNonShopper,"Overall");
                customizedArray(ageOverallValueNonShopper,ageOverallFinalNonShopper,ageLabel,radialColors,"Doughnut");

                extractValues(genderOverallNonShopper,genderOverallValueNonShopper,genderOverallBaseNonShopper,genderOverallCountNonShopper,"Overall");

                extractValues(incomeOverallNonShopper,incomeOverallValueNonShopper,incomeOverallBaseNonShopper,incomeOverallCountNonShopper,"Overall");
                customizedArray(incomeOverallValueNonShopper,incomeOverallFinalNonShopper,incomeLabel,radialColors,"Doughnut");

                extractValues(segmentOverallNonShopper,segmentOverallValueNonShopper,segmentOverallBaseNonShopper,segmentOverallCountNonShopper,"Overall");
                customizedArray(segmentOverallValueNonShopper,segmentOverallFinalNonShopper,segmentLabel,radialColors,"Doughnut");

                extractValues(typesOverallNonShopper,typesOverallValueNonShopper,typesOverallBaseNonShopper,typesOverallCountNonShopper,"Overall");
                customizedArray(typesOverallValueNonShopper,typesOverallFinalNonShopper,typesLabel,radialColors,"Doughnut");

                extractValues(dwellOverallDNonShopper,dwellOverallValueDNonShopper,dwellOverallBaseDNonShopper,dwellOverallCountDNonShopper,"Overall");
                customizedArray(dwellOverallValueDNonShopper,dwellOverallFinalDNonShopper,dwellLabel,radialColors,"Doughnut");

                extractValues(dwellOverallANonShopper,dwellOverallValueANonShopper,dwellOverallBaseANonShopper,dwellOverallCountANonShopper,"Overall");
                customizedArray(dwellOverallValueANonShopper,dwellOverallFinalANonShopper,dwellLabel,radialColors,"Doughnut");

                extractValues(frequencyOverallINonShopper,frequencyOverallValueINonShopper,frequencyOverallBaseINonShopper,frequencyOverallCountINonShopper,"Overall");
                customizedArray(frequencyOverallValueINonShopper,frequencyOverallFinalINonShopper,tripLabel,radialColors,"Doughnut");

                extractValues(frequencyOverallDNonShopper,frequencyOverallValueDNonShopper,frequencyOverallBaseDNonShopper,frequencyOverallCountDNonShopper,"Overall");
                customizedArray(frequencyOverallValueDNonShopper,frequencyOverallFinalDNonShopper,tripLabel,radialColors,"Doughnut");

                extractValues(travellingOverallNonShopper,travellingOverallValueNonShopper,travellingOverallBaseNonShopper,travellingOverallCountNonShopper,"Overall");
                customizedArray(travellingOverallValueNonShopper,travellingOverallFinalNonShopper,travellingLabel,radialColors,"Doughnut");

                extractValues(purposeOverallNonShopper,purposeOverallValueNonShopper,purposeOverallBaseNonShopper,purposeOverallCountNonShopper,"Overall");
                customizedArray(purposeOverallValueNonShopper,purposeOverallFinalNonShopper,purposeLabel,radialColors,"Doughnut");

                extractValues(terminalOverallNonShopper,terminalOverallValueNonShopper,terminalOverallBaseNonShopper,terminalOverallCountNonShopper,"Overall");
                customizedArray(terminalOverallValueNonShopper,terminalOverallFinalNonShopper,terminalLabel,radialColors,"Doughnut");

                extractValues(travellerOverallNonShopper,travellerOverallValueNonShopper,travellerOverallBaseNonShopper,travellerOverallCountNonShopper,"Overall");
                customizedArray(travellerOverallValueNonShopper,travellerOverallFinalNonShopper,travellerLabel,radialColors,"Doughnut");

                $("#male_value_dfs").empty().append(genderOverallValueShopper[0]+"%");
                $("#female_value_dfs").empty().append(genderOverallValueShopper[1]+"%");

                $("#male_value_dfns").empty().append(genderOverallValueNonShopper[0]+"%");
                $("#female_value_dfns").empty().append(genderOverallValueNonShopper[1]+"%");

                doughnutChart(ageOverallFinalShopper,"age_op_dfs","Age");
                doughnutChart(incomeOverallFinalShopper,"income_op_dfs","Income");
                doughnutChart(segmentOverallFinalShopper,"segment_op_dfs","Segment");
                doughnutChart(typesOverallFinalShopper,"type_op_dfs","Types");
                doughnutChart(dwellOverallFinalDShopper,"dwell_op_dfsD","Dwell Departure");
                doughnutChart(dwellOverallFinalAShopper,"dwell_op_dfsA","Dwell Arrival");
                doughnutChart(frequencyOverallFinalIShopper,"frequency_op_dfsI","Frequency International");
                doughnutChart(frequencyOverallFinalDShopper,"frequency_op_dfsD","Frequency Domestic");
                doughnutChart(travellingOverallFinalShopper,"travelling_op_dfs","Travelling");
                doughnutChart(purposeOverallFinalShopper,"purpose_op_dfs","Purpose");
                doughnutChart(terminalOverallFinalShopper,"terminal_op_dfs","Terminal");
                doughnutChart(travellerOverallFinalShopper,"traveller_op_dfs","Traveller");

                doughnutChart(ageOverallFinalNonShopper,"age_op_dfns","Age");
                doughnutChart(incomeOverallFinalNonShopper,"income_op_dfns","Income");
                doughnutChart(segmentOverallFinalNonShopper,"segment_op_dfns","Segment");
                doughnutChart(typesOverallFinalNonShopper,"type_op_dfns","Types");
                doughnutChart(dwellOverallFinalDNonShopper,"dwell_op_dfnsD","Dwell Departure");
                doughnutChart(dwellOverallFinalANonShopper,"dwell_op_dfnsA","Dwell Arrival");
                doughnutChart(frequencyOverallFinalINonShopper,"frequency_op_dfnsI","Frequency International");
                doughnutChart(frequencyOverallFinalDNonShopper,"frequency_op_dfnsD","Frequency Domestic");
                doughnutChart(travellingOverallFinalNonShopper,"travelling_op_dfns","Travelling");
                doughnutChart(purposeOverallFinalNonShopper,"purpose_op_dfns","Purpose");
                doughnutChart(terminalOverallFinalNonShopper,"terminal_op_dfns","Terminal");
                doughnutChart(travellerOverallFinalNonShopper,"traveller_op_dfns","Traveller");
            }

            var Q101 = data['Q101'];
            var Q102 = data['Q102'];
            var Q103 = data['Q103'];
            var Q106 = data['Q106'];
            var Q109 = data['Q109'];

            var Q201 = data['Q201'];
            var Q202 = data['Q202'];
            var Q206 = data['Q206'];
            var Q209 = data['Q209'];

            
            var Q101V = [];
            var Q101B = [];
            var Q101C = [];
            var Q101VX = [];

            var Q102V = [];
            var Q102B = [];
            var Q102C = [];
            var Q102VX = [];

            var Q103V = [];
            var Q103B = [];
            var Q103C = [];
            var Q103VX = [];

            var Q106V = [];
            var Q106B = [];
            var Q106C = [];
            var Q106VX = [];

            var Q109V = [];
            var Q109B = [];
            var Q109C = [];
            var Q109VX = [];

            var Q201V = [];
            var Q201B = [];
            var Q201C = [];
            var Q201VX = [];

            var Q202V = [];
            var Q202B = [];
            var Q202C = [];
            var Q202VX = [];

            var Q206V = [];
            var Q206B = [];
            var Q206C = [];
            var Q206VX = [];

            var Q209V = [];
            var Q209B = [];
            var Q209C = [];
            var Q209VX = [];

            

            

            extractValues(Q101,Q101V,Q101B,Q101C,"Airport");
            customizedArray(Q101V,Q101VX,Q101L,radialColors,"Line");
            lineChart(Q101VX,"q101",airportName);
            formtable(Q101V,Q101L,airportName,"q101_tbl");

            // barChart(Q101VX,"q101_2");

            extractValues(Q102,Q102V,Q102B,Q102C,"Airport");
            customizedArray(Q102V,Q102VX,Q101L,radialColors,"Line");
            lineChart(Q102VX,"q102",airportName);
            formtable(Q102V,Q101L,airportName,"q102_tbl2");

            extractValues(Q103,Q103V,Q103B,Q103C,"Airport");
            var transposedQ103 = transposeData(Q103V);
            customizedArray(transposedQ103,Q103VX,Q103L,radialColors,"Heat");
            heatChart(Q103VX[0],Q103B,"q103",airportName,Q103L,"#0099ff");
            debugger;
            formtable(Q103V,Q103L,airportName,"q103_tbl");

            extractValues(Q106,Q106V,Q106B,Q106C,"Airport");
            var transposedQ106 = transposeData(Q106V);
            customizedArray(transposedQ106,Q106VX,Q101L,radialColors,"Heat");
            heatChart(Q106VX[0],Q106B,"q106",airportName,Q101L,"#0099ff");
            formtable(Q106V,Q101L,airportName,"q106_tbl");

            extractValues(Q109,Q109V,Q109B,Q109C,"Airport");
            var transposedQ109 = transposeData(Q109V);
            formtable(Q109V,Q109L,airportName,"q109_tbl2");

            extractValues(Q201,Q201V,Q201B,Q201C,"Airport");
            customizedArray(Q201V,Q201VX,Q101L,radialColors,"Line");
            lineChart(Q201VX,"q201");
            formtable(Q201V,Q101L,airportName,"q201_tbl");

            extractValues(Q202,Q202V,Q202B,Q202C,"Airport");
            var transposedQ202 = transposeData(Q202V);
            customizedArray(transposedQ202,Q202VX,Q202L,radialColors,"Heat");
            heatChart(Q202VX[0],Q202B,"q202",airportName,Q202L,"#0099ff");
            formtable(Q202V,Q202L,airportName,"q202_tbl");

            extractValues(Q206,Q206V,Q206B,Q206C,"Airport");
            var transposedQ206 = transposeData(Q206V);
            formtable(Q206V,Q101L,airportName,"q206_tbl2");

            extractValues(Q209,Q209V,Q209B,Q209C,"Airport");
            customizedArray(Q209V,Q209VX,Q109L,radialColors,"Line");
            lineChart(Q209VX,"q209");
            formtable(Q209V,Q109L,airportName,"q209_tbl");

            

            var html = ``;
            html += `<tr>`;
            html += `<td></td>`;
            Q101L.forEach(function(e,i,a){
                html += `<td>${Q101L[i]}</td>`;
            });
            html += `</tr>`;
            transposedQ206.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q101L[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q206_tbl > tbody").empty().append(html);

            var html = ``;
            html += `<tr>`;
            html += `<td></td>`;
            Q109L.forEach(function(e,i,a){
                html += `<td>${e}</td>`;
            });
            html += `</tr>`;
            transposedQ109.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q109L[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q109_tbl > tbody").empty().append(html);



        },
        complete: function (data) 
        {
            $(".splash").hide();
            dutyFreeStatus = true;
            clickableSlice2();
            // ajaxFlag[1] = true;
        }
    });
}

function secondAjax()
{
    $.ajax({
        url: "api/ajax2.php",
        type: "POST",
        data: {
            'condX' : condX,
            'conX' : conX,
            'tblX' : "tbl_1"
        },
        success: function(response) {
            var data = JSON.parse(response);
            //console.log(data);

            var Q301a = data['Q301a'];
            var Q303a = data['Q303a'];
            var Q308a = data['Q308a'];
            
            var Q401a = data['Q401a'];
            var Q404a = data['Q404a'];
            var Q409b = data['Q409b'];

            var Q301aV = [];
            var Q301aB = [];
            var Q301aC = [];
            var Q301aVX = [];

            var Q303aV = [];
            var Q303aB = [];
            var Q303aC = [];
            var Q303aVX = [];

            var Q308aV = [];
            var Q308aB = [];
            var Q308aC = [];
            var Q308aVX = [];

            var Q401aV = [];
            var Q401aB = [];
            var Q401aC = [];
            var Q401aVX = [];

            var Q404aV = [];
            var Q404aB = [];
            var Q404aC = [];
            var Q404aVX = [];
            var Q404aVX2 = [];

            var Q409bV = [];
            var Q409bB = [];
            var Q409bC = [];
            var Q409bVX = [];

            extractValues(Q301a,Q301aV,Q301aB,Q301aC,"Airport");
            var transposedQ301a = transposeData(Q301aV);
            customizedArray(transposedQ301a,Q301aVX,Q301aL,radialColors,"Heat");
            heatChart(Q301aVX[0],Q301aB,"q301a",airportName,Q301aL,"#0099ff");
            formtable(Q301aV,Q301aL,airportName,"q301a_tbl");

            extractValues(Q303a,Q303aV,Q303aB,Q303aC,"Airport");
            customizedArray(Q303aV,Q303aVX,Q303aL,radialColors,"Line");
            lineChart(Q303aVX,"q303a");
            formtable(Q303aV,Q303aL,airportName,"q303a_tbl");

            extractValues(Q308a,Q308aV,Q308aB,Q308aC,"Airport");
            var transposedQ308a = transposeData(Q308aV);
            formtable(Q308aV,Q308aL,airportName,"q308a_tbl2");
            // barChart(Q308aVX,Q308aB,"q308a");


            extractValues(Q401a,Q401aV,Q401aB,Q401aC,"Airport");
            var transposedQ401a = transposeData(Q401aV);
            customizedArray(transposedQ401a,Q401aVX,Q401aL,radialColors,"Heat");
            heatChart(Q401aVX[0],Q401aB,"q401a",airportName,Q401aL,"#0099ff");
            formtable(Q401aV,Q401aL,airportName,"q401a_tbl");
        
            extractValues(Q404a,Q404aV,Q404aB,Q404aC,"Airport");
            customizedArray(Q404aV,Q404aVX,Q303aL,radialColors,"Line");
            lineChart(Q404aVX,"q404a");
            formtable(Q404aV,Q303aL,airportName,"q404a_tbl");

            extractValues(Q409b,Q409bV,Q409bB,Q409bC,"Airport");
            var transposedQ409b = transposeData(Q409bV);
            formtable(Q409bV,Q308aL,airportName,"q409b_tbl2");

            var html = ``;
            html += `<tr>`;
            html += `<td></td>`;
            Q308aL.forEach(function(e,i,a){
                html += `<td>${e}</td>`;
            });
            html += `</tr>`;
            transposedQ308a.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q308aL[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q308a_tbl > tbody").empty().append(html);

            var html = ``;
            html += `<tr>`;
            html += `<td></td>`;
            Q308aL.forEach(function(e,i,a){
                html += `<td>${e}</td>`;
            });
            html += `</tr>`;
            transposedQ409b.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q308aL[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q409b_tbl > tbody").empty().append(html);
        },
        complete: function (data) 
        {
            $(".splash").hide();
            // ajaxFlag[1] = true;
        }
    });
}

function thirdAjax()
{
    $.ajax({
        url: "api/ajax3.php",
        type: "POST",
        data: {
            'condX' : condX,
            'conX' : conX,
            'tblX' : "tbl_1"
        },
        success: function(response) {
            var data = JSON.parse(response);
            //console.log("ajax3.php");
            //console.log(data);

            var Q301b = data['Q301b'];
            var Q302b = data['Q302b'];
            var Q304b = data['Q304b'];
            var Q306b = data['Q306b'];

            var Q401b = data['Q401b'];
            var Q405b = data['Q405b'];

            var Q301bV = [];
            var Q301bB = [];
            var Q301bC = [];
            var Q301bVX = [];

            var Q302bV = [];
            var Q302bB = [];
            var Q302bC = [];
            var Q302bVX = [];

            var Q304bV = [];
            var Q304bB = [];
            var Q304bC = [];
            var Q304bVX = [];

            var Q306bV = [];
            var Q306bB = [];
            var Q306bC = [];
            var Q306bVX = [];

            var Q401bV = [];
            var Q401bB = [];
            var Q401bC = [];
            var Q401bVX = [];

            var Q405bV = [];
            var Q405bB = [];
            var Q405bC = [];
            var Q405bVX = [];

            extractValues(Q301b,Q301bV,Q301bB,Q301bC,"Airport");
            var transposedQ301b = transposeData(Q301bV);
            formtable(Q301bV,Q301bL,airportName,"q301b_tbl2");

            extractValues(Q302b,Q302bV,Q302bB,Q302bC,"Airport");
            var transposedQ302b = transposeData(Q302bV);
            customizedArray(transposedQ302b,Q302bVX,Q302bL,radialColors,"Heat");
            heatChart(Q302bVX[0],Q302bB,"q302b",airportName,Q302bL,"#0099ff");
            formtable(Q302bV,Q302bL,airportName,"q302b_tbl");

            extractValues(Q304b,Q304bV,Q304bB,Q304bC,"Airport");
            var transposedQ304b = transposeData(Q304bV);
            customizedArray(transposedQ304b,Q304bVX,Q304bL,radialColors,"Heat");
            heatChart(Q304bVX[0],Q304bB,"q304b",airportName,Q304bL,"#0099ff");
            formtable(Q304bV,Q304bL,airportName,"q304b_tbl");

            extractValues(Q306b,Q306bV,Q306bB,Q306bC,"Airport");
            var transposedQ306b = transposeData(Q306bV);
            formtable(Q306bV,Q306bL,airportName,"q306b_tbl2");

            extractValues(Q401b,Q401bV,Q401bB,Q401bC,"Airport");
            var transposedQ401b = transposeData(Q401bV);
            customizedArray(transposedQ401b,Q401bVX,Q401bL,radialColors,"Heat");
            heatChart(Q401bVX[0],Q401bB,"q401b",airportName,Q401bL,"#0099ff");
            formtable(Q401bV,Q401bL,airportName,"q401b_tbl");

            extractValues(Q405b,Q405bV,Q405bB,Q405bC,"Airport");
            var transposedQ405b = transposeData(Q405bV);
            formtable(Q405bV,Q306bL,airportName,"q405b_tbl2");


            var html = ``;
            html += `<tr>`;
            html += `<td></td>`;
            Q301bL.forEach(function(e,i,a){
                html += `<td>${e}</td>`;
            });
            html += `</tr>`;
            transposedQ301b.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q301bL[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q301b_tbl > tbody").empty().append(html);

            var html = ``;
            html += `<tr>`;
            html += `<td></td>`;
            Q306bL.forEach(function(e,i,a){
                html += `<td>${e}</td>`;
            });
            html += `</tr>`;
            transposedQ306b.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q306bL[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q306b_tbl > tbody").empty().append(html);

            var html = ``;
            html += `<tr>`;
            html += `<td></td>`;
            Q306bL.forEach(function(e,i,a){
                html += `<td>${e}</td>`;
            });
            html += `</tr>`;
            transposedQ405b.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q306bL[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q405b_tbl > tbody").empty().append(html);
        },
        complete: function (data) 
        {
            $(".splash").hide();
            // ajaxFlag[1] = true;
        }

    });
}

function forthAjax()
{
    $.ajax({
        url: "api/ajax4.php",
        type: "POST",
        data: {
            'condX' : condX,
            'conX' : conX,
            'tblX' : "tbl_1"
        },
        success: function(response) {
            var data = JSON.parse(response);
            //console.log(data);

            var Q501 = data['Q501'];
            var Q502 = data['Q502'];
            var Q503 = data['Q503'];
            var Q504 = data['Q504'];
            var Q504a = data['Q504a'];
            var Q505 = data['Q505'];
            var Q506 = data['Q506'];
            var Q507 = data['Q507'];
            var Q508 = data['Q508'];
            var Q509 = data['Q509'];
            var Q510 = data['Q510'];
            var Q511 = data['Q511'];
            var Q512 = data['Q512'];
            var Q513 = data['Q513'];

            var Q601 = data['Q601'];
            var Q602 = data['Q602'];
            var Q602a = data['Q602a'];
            var Q603 = data['Q603'];
            var Q604 = data['Q604'];
            var Q605 = data['Q605'];

            var Q501V = [];
            var Q501B = [];
            var Q501C = [];
            var Q501VX = [];

            var Q502V = [];
            var Q502B = [];
            var Q502C = [];
            var Q502VX = [];

            var Q503V = [];
            var Q503B = [];
            var Q503C = [];
            var Q503VX = [];

            var Q504V = [];
            var Q504B = [];
            var Q504C = [];
            var Q504VX = [];

            var Q504aV = [];
            var Q504aB = [];
            var Q504aC = [];
            var Q504aVX = [];

            var Q505V = [];
            var Q505B = [];
            var Q505C = [];
            var Q505VX = [];

            var Q506V = [];
            var Q506B = [];
            var Q506C = [];
            var Q506VX = [];

            var Q507V = [];
            var Q507B = [];
            var Q507C = [];
            var Q507VX = [];

            var Q508V = [];
            var Q508B = [];
            var Q508C = [];
            var Q508VX = [];

            var Q509V = [];
            var Q509B = [];
            var Q509C = [];
            var Q509VX = [];

            var Q510V = [];
            var Q510B = [];
            var Q510C = [];
            var Q510VX = [];

            var Q511V = [];
            var Q511B = [];
            var Q511C = [];
            var Q511VX = [];

            var Q512V = [];
            var Q512B = [];
            var Q512C = [];
            var Q512VX = [];

            var Q513V = [];
            var Q513B = [];
            var Q513C = [];
            var Q513VX = [];

            var Q601V = [];
            var Q601B = [];
            var Q601C = [];
            var Q601VX = [];

            var Q602V = [];
            var Q602B = [];
            var Q602C = [];
            var Q602VX = [];

            var Q602aV = [];
            var Q602aB = [];
            var Q602aC = [];
            var Q602aVX = [];

            var Q603V = [];
            var Q603B = [];
            var Q603C = [];
            var Q603VX = [];

            var Q604V = [];
            var Q604B = [];
            var Q604C = [];
            var Q604VX = [];

            var Q605V = [];
            var Q605B = [];
            var Q605C = [];
            var Q605VX = [];

            extractValues(Q501,Q501V,Q501B,Q501C,"Airport");
            var transposedQ501 = transposeData(Q501V);
            customizedArray(transposedQ501,Q501VX,Q501L,radialColors,"Heat");
            heatChart(Q501VX[0],Q501B,"q501",airportName,Q501L,"#0099ff");
            formtable(Q501V,Q501L,airportName,"q501_tbl");


            extractValues(Q502,Q502V,Q502B,Q502C,"Airport");
            var transposedQ502 = transposeData(Q502V);
            formtable(Q502V,Q502L,airportName,"q502_tbl2");
            
            extractValues(Q503,Q503V,Q503B,Q503C,"Airport");
            var transposedQ503 = transposeData(Q503V);
            customizedArray(transposedQ503,Q503VX,Q503L,radialColors,"Heat");
            heatChart(Q503VX[0],Q503B,"q503",airportName,Q503L,"#0099ff");
            formtable(Q503V,Q503L,airportName,"q503_tbl");


            extractValues(Q504,Q504V,Q504B,Q504C,"Airport");
            var transposedQ504 = transposeData(Q504V);
            formtable(Q504V,Q504L,airportName,"q504_tbl2");


            extractValues(Q504a,Q504aV,Q504aB,Q504aC,"Airport");
            customizedArray(Q504aV,Q504aVX,Q504aL,radialColors,"Line");
            lineChart(Q504aVX,"q504a");
            formtable(Q504aV,Q504aL,airportName,"q504a_tbl");


            extractValues(Q505,Q505V,Q505B,Q505C,"Airport");
            var transposedQ505 = transposeData(Q505V);
            customizedArray(transposedQ505,Q505VX,Q505L,radialColors,"Heat");
            heatChart(Q505VX[0],Q505B,"q505",airportName,Q505L,"#0099ff");
            formtable(Q505V,Q505L,airportName,"q505_tbl");


            extractValues(Q506,Q506V,Q506B,Q506C,"Airport");
            var transposedQ506 = transposeData(Q506V);
            formtable(Q506V,Q506L,airportName,"q506_tbl2");

            extractValues(Q507,Q507V,Q507B,Q507C,"Airport");
            var transposedQ507 = transposeData(Q507V);
            formtable(Q507V,Q507L,airportName,"q507_tbl2");

            extractValues(Q508,Q508V,Q508B,Q508C,"Airport");
            var transposedQ508 = transposeData(Q508V);
            customizedArray(transposedQ508,Q508VX,Q508L,radialColors,"Heat");
            heatChart(Q508VX[0],Q508B,"q508",airportName,Q508L,"#0099ff");
            formtable(Q508V,Q508L,airportName,"q508_tbl");


            extractValues(Q509,Q509V,Q509B,Q509C,"Airport");
            var transposedQ509 = transposeData(Q509V);
            customizedArray(transposedQ509,Q509VX,Q509L,radialColors,"Heat");
            heatChart(Q509VX[0],Q509B,"q509",airportName,Q509L,"#0099ff");
            formtable(Q509V,Q509L,airportName,"q509_tbl");


            extractValues(Q510,Q510V,Q510B,Q510C,"Airport");
            var transposedQ510 = transposeData(Q510V);
            customizedArray(transposedQ510,Q510VX,Q510L,radialColors,"Heat");
            heatChart(Q510VX[0],Q510B,"q510",airportName,Q510L,"#0099ff");
            formtable(Q510V,Q510L,airportName,"q510_tbl");

            extractValues(Q511,Q511V,Q511B,Q511C,"Airport");
            var transposedQ511 = transposeData(Q511V);
            customizedArray(transposedQ511,Q511VX,Q511L,radialColors,"Heat");
            heatChart(Q511VX[0],Q511B,"q511",airportName,Q511L,"#0099ff");
            formtable(Q511V,Q511L,airportName,"q511_tbl");

            extractValues(Q512,Q512V,Q512B,Q512C,"Airport");
            customizedArray(Q512V,Q512VX,Q512L,twoRadialColor2,"StackBar");
            stackbarChart(Q512VX,Q512B,"q512");
            formtable(Q512V,Q512L,airportName,"q512_tbl");

            extractValues(Q513,Q513V,Q513B,Q513C,"Airport");
            var transposedQ513 = transposeData(Q513V);
            formtable(Q513V,Q513L,airportName,"q513_tbl2");

            extractValues(Q601,Q601V,Q601B,Q601C,"Airport");
            var transposedQ601 = transposeData(Q601V);
            customizedArray(transposedQ601,Q601VX,Q601L,radialColors,"Heat");
            heatChart(Q601VX[0],Q601B,"q601",airportName,Q601L,"#0099ff");
            formtable(Q601V,Q601L,airportName,"q601_tbl");

            extractValues(Q602,Q602V,Q602B,Q602C,"Airport");
            var transposedQ602 = transposeData(Q602V);
            customizedArray(transposedQ602,Q602VX,Q602L,radialColors,"Heat");
            heatChart(Q602VX[0],Q602B,"q602",airportName,Q602L,"#0099ff");
            formtable(Q602V,Q602L,airportName,"q602_tbl");

            extractValues(Q602a,Q602aV,Q602aB,Q602aC,"Airport");
            var transposedQ602a = transposeData(Q602aV);
            customizedArray(transposedQ602a,Q602aVX,Q602aL,radialColors,"Heat");
            heatChart(Q602aVX[0],Q602aB,"q602a",airportName,Q602aL,"#0099ff");
            formtable(Q602aV,Q602aL,airportName,"q602a_tbl");

            extractValues(Q603,Q603V,Q603B,Q603C,"Airport");
            var transposedQ603 = transposeData(Q603V);
            customizedArray(transposedQ603,Q603VX,Q603L,radialColors,"Heat");
            heatChart(Q603VX[0],Q603B,"q603",airportName,Q603L,"#0099ff");
            formtable(Q603V,Q603L,airportName,"q603_tbl");

            extractValues(Q604,Q604V,Q604B,Q604C,"Airport");
            var transposedQ604 = transposeData(Q604V);
            customizedArray(transposedQ604,Q604VX,Q604L,radialColors,"Heat");
            heatChart(Q604VX[0],Q604B,"q604",airportName,Q604L,"#0099ff");
            formtable(Q604V,Q604L,airportName,"q604_tbl");

            extractValues(Q605,Q605V,Q605B,Q605C,"Airport");
            var transposedQ605 = transposeData(Q605V);
            customizedArray(transposedQ605,Q605VX,Q605L,radialColors,"Heat");
            heatChart(Q605VX[0],Q605B,"q605",airportName,Q605L,"#0099ff");
            formtable(Q605V,Q605L,airportName,"q605_tbl");

            var html = ``;
            html += `<tr class="top_row">`;
            html += `<td></td>`;
            Q502L.forEach(function(e,i,a){
                html += `<td class="top_col">${e}</td>`;
            });
            html += `</tr>`;
            transposedQ502.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q502L[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q502_tbl > tbody").empty().append(html);

            var html = ``;
            html += `<tr class="top_row">`;
            html += `<td></td>`;
            Q504L.forEach(function(e,i,a){
                html += `<td class="top_col">${e}</td>`;
            });
            html += `</tr>`;
            transposedQ504.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q504L[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q504_tbl > tbody").empty().append(html);

            var html = ``;
            html += `<tr class="top_row">`;
            html += `<td></td>`;
            Q506L.forEach(function(e,i,a){
                html += `<td class="top_col">${e}</td>`;
            });
            html += `</tr>`;
            transposedQ506.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q506L[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q506_tbl > tbody").empty().append(html);

            var html = ``;
            html += `<tr class="top_row">`;
            html += `<td></td>`;
            Q507L.forEach(function(e,i,a){
                html += `<td class="top_col">${e}</td>`;
            });
            html += `</tr>`;
            transposedQ507.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q507L[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q507_tbl > tbody").empty().append(html);

            var html = ``;
            html += `<tr class="top_row">`;
            html += `<td></td>`;
            Q513L.forEach(function(e,i,a){
                html += `<td class="top_col">${Q513L[i]}</td>`;
            });
            html += `</tr>`;
            transposedQ513.forEach(function(e,i,a){
                html += `<tr>`;
                html += `<td class="rowLabel">${airportName[i]}</td>`;
                e.forEach(function(e2,i2,a2){
                    html += `
                    <td class="colX col${i2+1}">
                        <div class="td_item">
                            <div class="option_text" title="${Q513L[i2]}">
                                
                                <div class="option_item count">${e2}%</div>
                            </div>
                            <div class="widget-progress-wrapper">
                                <div class="progress-bar-sm progress-bar-animated-alt progress">
                                    <div class="progress-bar bg-primary" role="progressbar" aria-valuenow="43" aria-valuemin="0" aria-valuemax="100" style="width: ${e2}%;"></div>
                                </div>
                            </div>
                        </div>
                    </td>`;
                });
                html += `<tr><td colspan="9"></td></tr>`;
                html += `</tr>`;
            }); 

            $("#q513_tbl > tbody").empty().append(html);


        },
        complete: function (data) 
        {
            $(".splash").hide();
            // ajaxFlag[1] = true;
        }

    });
}

function fifthAjax()
{
    $.ajax({
        url: "api/ajax5.php",
        type: "POST",
        data: {
            'condX' : condX,
            'conX' : conX,
            'tblX' : "tbl_2"
        },
        success: function(response) {
            var data = JSON.parse(response);
            
            var Q901a = data['Q901a'];
            var Q902b = data['Q902b'];

            var Q901aV = [];
            var Q901aB = [];
            var Q901aC = [];
            var Q901aVX = [];

            var Q902bV = [];
            var Q902bB = [];
            var Q902bC = [];
            var Q902bVX = [];

            extractValues(Q901a,Q901aV,Q901aB,Q901aC,"Airport");
            var transposedQ901a = transposeData(Q901aV);
            customizedArray(transposedQ901a,Q901aVX,Q901aL,radialColors,"Heat");
            heatChart(Q901aVX[0],Q901aB,"q901a",airportName,Q901aL,"#0099ff");

            extractValues(Q902b,Q902bV,Q902bB,Q902bC,"Airport");
            var transposedQ902b = transposeData(Q902bV);
            customizedArray(transposedQ902b,Q902bVX,Q902bL,radialColors,"Heat");
            heatChart(Q902bVX[0],Q902bB,"q902b",airportName,Q902bL,"#0099ff");

        },
        complete: function (data) 
        {
            $(".splash").hide();
            // ajaxFlag[1] = true;
        }

    });
}

function sixthAjax()
{
    $.ajax({
        url: "api/ajax6.php",
        type: "POST",
        data: {
            'condX' : condX,
            'conX' : conX,
            'tblX' : "tbl_2"
        },
        success: function(response) {
            var data = JSON.parse(response);
            
            var Q1001a = data['Q1001a'];
            var Q1002b = data['Q1002b'];

            var Q1001aV = [];
            var Q1001aB = [];
            var Q1001aC = [];
            var Q1001aVX = [];

            var Q1002bV = [];
            var Q1002bB = [];
            var Q1002bC = [];
            var Q1002bVX = [];

            extractValues(Q1001a,Q1001aV,Q1001aB,Q1001aC,"Airport");
            var transposedQ1001a = transposeData(Q1001aV);
            customizedArray(transposedQ1001a,Q1001aVX,Q1001aL,radialColors,"Heat");
            heatChart(Q1001aVX[0],Q1001aB,"q1001a",airportName,Q1001aL,"#0099ff");

            extractValues(Q1002b,Q1002bV,Q1002bB,Q1002bC,"Airport");
            var transposedQ1002b = transposeData(Q1002bV);
            customizedArray(transposedQ1002b,Q1002bVX,Q1002bL,radialColors,"Heat");
            heatChart(Q1002bVX[0],Q1002bB,"q1002b",airportName,Q1002bL,"#0099ff");

        },
        complete: function (data) 
        {
            $(".splash").hide();
            // ajaxFlag[1] = true;
        }

    });
}

function seventhAjax()
{
    $.ajax({
        url: "api/ajax7.php",
        type: "POST",
        data: {
            'condX' : condX,
            'conX' : conX,
            'tblX' : "tbl_1"
        },
        success: function(response) {
            var data = JSON.parse(response);

            var Q1101 = data['Q1101'];
            var Q1102 = data['Q1102'];
            var Q1103 = data['Q1103'];
            var Q1104 = data['Q1104'];
            var Q1105 = data['Q1105'];
            var Q1106 = data['Q1106'];
            var Q1107 = data['Q1107'];

            var Q1101V = [];
            var Q1101B = [];
            var Q1101C = [];
            var Q1101VX = [];

            var Q1102V = [];
            var Q1102B = [];
            var Q1102C = [];
            var Q1102VX = [];

            var Q1103V = [];
            var Q1103B = [];
            var Q1103C = [];
            var Q1103VX = [];

            var Q1104V = [];
            var Q1104B = [];
            var Q1104C = [];
            var Q1104VX = [];

            var Q1105V = [];
            var Q1105B = [];
            var Q1105C = [];
            var Q1105VX = [];

            var Q1106V = [];
            var Q1106B = [];
            var Q1106C = [];
            var Q1106VX = [];

            var Q1107V = [];
            var Q1107B = [];
            var Q1107C = [];
            var Q1107VX = [];

            extractValues(Q1101,Q1101V,Q1101B,Q1101C,"Airport");
            customizedArray(Q1101V,Q1101VX,Q1101L,radialColors,"Line");
            lineChart(Q1101VX,"q1101");

            extractValues(Q1102,Q1102V,Q1102B,Q1102C,"Airport");
            customizedArray(Q1102V,Q1102VX,Q1102L,twoRadialColor2,"StackBar");
            stackbarChart(Q1102VX,Q1102B,"q1102");

            extractValues(Q1103,Q1103V,Q1103B,Q1103C,"Airport");
            customizedArray(Q1103V,Q1103VX,Q1102L,twoRadialColor2,"StackBar");
            stackbarChart(Q1103VX,Q1103B,"q1103");

            extractValues(Q1104,Q1104V,Q1104B,Q1104C,"Airport");
            customizedArray(Q1104V,Q1104VX,Q1102L,twoRadialColor2,"StackBar");
            stackbarChart(Q1104VX,Q1104B,"q1104");

            extractValues(Q1105,Q1105V,Q1105B,Q1105C,"Airport");
            customizedArray(Q1105V,Q1105VX,Q1102L,twoRadialColor2,"StackBar");
            stackbarChart(Q1105VX,Q1105B,"q1105");

            extractValues(Q1106,Q1106V,Q1106B,Q1106C,"Airport");
            var transposedQ1106 = transposeData(Q1106V);
            customizedArray(transposedQ1106,Q1106VX,Q1106L,radialColors,"Heat");
            heatChart(Q1106VX[0],Q1106B,"q1106",airportName,Q1106L,"#0099ff");

            extractValues(Q1107,Q1107V,Q1107B,Q1107C,"Airport");
            customizedArray(Q1107V,Q1107VX,Q1102L,twoRadialColor2,"StackBar");
            stackbarChart(Q1107VX,Q1107B,"q1107");
        },
        complete: function (data) 
        {
            $(".splash").hide();
            // ajaxFlag[1] = true;
        }

    });
}


// ------------------------------------------------------------ AJAX END ----------------------------------------------------- //

// ------------------------------------------------------------ CHART START ----------------------------------------------------- //

function barChart(lucifer,id)
{
    lucifer = [
        {
            "name": "Ahemdabad",
            "data": [
                63,
                72,
                32,
                72,
                63,
                72,
                32,
                72,
                45
            ]
        }
    ];
    Highcharts.chart(id, {
        chart: {
            style: {
                fontFamily: 'Roboto'
            },
            "backgroundColor": "transparent",
            type: 'bar'
        },
        title: {
            text: '',
        },
        navigation: {
            buttonOptions: {
                enabled: false
            }
        },
        credits: {
            enabled: false
        },
        xAxis: {
            categories: Q101L,
            title: {
                text: null
            },
            gridLineWidth: 0,
            lineWidth: 0,
            labels: {
                style: {
                    fontWeight: 'bold'
                },
            }
        },
        yAxis: {
            min: 0,
            max: 130,
            title: {
                text: '',
                align: 'high'
            },
            labels: {
                overflow: 'justify'
            },
            gridLineWidth: 0,
            minorGridLineWidth: 0,
            alignTicks: false,
            labels: {
                enabled: false
            },
        },
        tooltip: {
            valueSuffix: ' %'
        },
        plotOptions: {
            bar: {
                borderRadius: {
                    radius: 10,
                    where: 'all'
                },
                dataLabels: {
                    enabled: true
                },
                groupPadding: 0.1
            },
            series: {
                colorByPoint: true,
                cursor: 'pointer',
                // dataLabels: {
                    style: {
                        textOutline: false,
                        fontSize : "15px"
                    },
                dataLabels: {
                    style: {
                        textOutline: false,
                        fontSize : "15px"
                    },

                    enabled: true,
                    style: {
                        textOutline: false,
                        fontSize : "13px"
                    },
                    formatter: function() {
                        if(this)
                        {
                            return this.y + "%";
                        }
                        
                    },
                }
            }
        },
        credits: {
            enabled: false
        },
        // colors: radialColors,
        colors: [
            '#001F3F', // Navy Blue
            '#007B7F', // Teal
            '#005F00', // Dark Green
            '#708090', // Slate Gray
            '#800000', // Maroon
            '#DAA520', // Goldenrod
            '#4682B4', // Steel Blue
            '#6B8E23', // Olive Drab
            '#DC143C', // Crimson
            '#7851A9'  // Royal Purple
        ],
        series: lucifer
    });

}

function stackbarChart(data,baseE,id)
{
    Highcharts.chart(id, {
        chart: {
            style: {
                fontFamily: 'Roboto'
            },
            "backgroundColor": "transparent",
            type: 'bar'
        },
        title: {
            text: ''
        },
        xAxis: {
            categories: airportName,
            lineWidth: 0,
            labels: {
                style: {
                    fontWeight: 'bold'
                },
            }
        },
        navigation: {
            buttonOptions: {
                enabled: false
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: ''
            },
            gridLineWidth: 0,
            minorGridLineWidth: 0,
            alignTicks: false,
            labels: {
                enabled: false
            },
        },
        tooltip: {
            valueSuffix: ' %'
        },
        credits: {
            enabled: false
        },
        legend: {
            reversed: true
        },
        plotOptions: {
            bar: {
                pointPadding: 0,
                groupPadding: 0,
                borderRadius: {
                    radius: 10,
                    where: 'all'
                },
                
                
            },
            series: {
                stacking: 'normal',
                pointWidth: 16,
                dataLabels: {
                    enabled: true,
                    formatter: function() {
                        if(this)
                        {
                            return this.y + "%";
                        }
                        
                    }
                }
            }
        },
        // colors: ["#87CEFA","#00BFFF","#1E90FF","#4169E1","#0000CD","#00008B","#000080","#191970","#002147"],
        colors: ["#003399","#004de6","#3377ff","#80aaff","#b3ccff"],
        series: data
    });
}

function stackcolumnChart(lucifer,baseE,id)
{
    Highcharts.chart(id, {
        chart: {
            style: {
                fontFamily: 'Roboto'
            },
            "backgroundColor": "transparent",
            type: 'column',
        },
        title: {
            text: '',
        },
        navigation: {
            buttonOptions: {
                enabled: false
            }
        },
        xAxis: [{
            categories: airportName,
            lineWidth: 0,
            labels: {
                style: {
                    fontWeight: 'bold'
                },
                rotation:0,
                useHTML: true,
                padding:15,
                height:10,
                width:10,
            }
        }],
        yAxis: [{
            min: 0,
            title: {
                text:''
            },
            gridLineWidth: 0,
            minorGridLineWidth: 0,
            alignTicks: false,
            labels: {
                enabled: false
            },
            stackLabels: {
                textAlign: 'center',
                enabled: false,
                borderRadius: 5,
                backgroundColor: '#333333',
                borderWidth: 1,
                borderColor: '#AAA',
                y: -15,
                align: 'center',
                style: {
                    fontWeight: 'bold',
                    fontSize:'13px',
                    // shadow: false,
                    color: '#FFFFFF',
                }
            }
        }],

        tooltip: {
            shared: true,
            split: false,
            enabled: true,
            headerFormat: '<b>{point.x}</b><br/>',
            pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}%</b> <br/>',
        },
        credits: {
            enabled: false
        },
        legend: {
            
        },
        plotOptions: {
            column: {
                stacking: 'normal',
            },
            series: {
                pointWidth: 40,
                stacking: 'normal',
                // pointWidth: 20,
                cursor: 'pointer',
                    style: {
                        textOutline: false,
                        fontSize : "14px"
                    },
                dataLabels: {
                    style: {
                        textOutline: false,
                        fontSize : "13px"
                    },

                    enabled: true,
                    style: {
                        textOutline: false
                    },
                    formatter: function() {
                        if(this)
                        {
                            return (this.y) + '%';
                        }
                        
                    },
                }
            }
        },
//         colors: [
//     "#000080",  // Navy
//     "#00008B",  // Dark Blue
//     "#191970",  // Midnight Blue
//     "#002147",  // Oxford Blue
//     "#003153",  // Prussian Blue
//     "#0000CD",  // Medium Blue
//     "#1E90FF",  // Dodger Blue
//     "#4169E1",  // Royal Blue
//     "#4682B4",  // Steel Blue
//     "#6495ED",  // Cornflower Blue
//     "#00BFFF",  // Deep Sky Blue
//     "#87CEFA",  // Light Sky Blue
//     "#B0E0E6",  // Powder Blue
//     "#F0F8FF"   // Alice Blue
// ]
        colors: [
            "#003399",
            "#004de6",
            "#3377ff",
            "#80aaff",
            "#b3ccff",
            "#e6eeff"
],
        series: lucifer
    });
}


function heatChart(lucifer,baseE,id,airport,catLabel,colorX)
{
    Highcharts.chart(id, {
    chart: {
        type: 'heatmap',
        plotBorderWidth: 1
    },
    title: {
        text: '',
    },
    navigation: {
        buttonOptions: {
            enabled: false
        }
    },
    credits: {
        enabled: false
    },

    xAxis: {
        categories: airportName,
        labels: {
            useHTML: true,
        }
    },
    // #70db70 - Green
    yAxis: {
        categories: catLabel,
        title: null,
        reversed: true,
    },

    colorAxis: {
        min: 0,
        minColor: '#FFFFFF',
        maxColor: colorX
    },

    legend: {
        align: 'right',
        layout: 'vertical',
        margin: 0,
        verticalAlign: 'top',
        y: 25,
        symbolHeight: 280,
        enabled:false
    },

    tooltip: {
        format: '<b>{series.xAxis.categories.(point.x)}</b><br>' +
            '<b>{series.yAxis.categories.(point.y)} : {point.value}%</b>'
    },

    series: [{
        name: 'Sales per employee',
        borderWidth: 1,
        data: lucifer,
        dataLabels: {
            enabled: true,
            color: '#000000',
            style: {
                textOutline: false,
                fontSize : "12px"
            },
            formatter: function () {
                return this.point.value + '%';
            }
        }
    }],

    responsive: {
        rules: [{
            condition: {
                maxWidth: 500
            },
            chartOptions: {
                yAxis: {
                    labels: {
                        format: '{substr value 0 1}'
                    }
                }
            }
        }]
    }

});

}

function areaChart(lucifer,baseE,id)
{
    Highcharts.chart(id, {
        chart: {
            style: {
                fontFamily: 'Roboto'
            },
            "backgroundColor": "transparent",
            type: 'area',
            height: "500px"
        },
        title: {
            text: ''
        },
        navigation: {
            buttonOptions: {
                enabled: false
            }
        },
        xAxis: {
            categories: airportName,
            labels: {
                style: {
                    fontWeight: 'bold'
                },
                rotation:0,
                useHTML: true,
                padding:15,
                height:10,
                width:10,
            }
        },
        yAxis: {
            title: {
                text: ''
            },
            gridLineWidth: 0,
            minorGridLineWidth: 0,
            alignTicks: false,
            labels: {
                enabled: false
            }
        },
        tooltip: {
            pointFormat: '{series.name} had stockpiled <b>{point.y:,.0f}</b><br/>' +
                'warheads in {point.x}'
        },
        plotOptions: {
            area: {
                stacking: 'normal',
                marker: {
                    enabled: false,
                    symbol: 'circle',
                    radius: 2,
                    states: {
                        hover: {
                            enabled: true
                        }
                    }
                },
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    formatter: function() {
                        return (this.y)+"%";
                    },
                }
            }
        },
        credits: {
            enabled: false
        },
        // colors: ['#C07B60','#FA8D62','#2C626E','#B1DCD3','#74A9CE','#A6BCDB','#D0D0E7'],
        colors: [
            "#003399",
            "#004de6",
            "#3377ff",
            "#80aaff",
            "#b3ccff",
            "#e6eeff"
        ],
        series: lucifer
    });
}

function doughnutChart(lucifer,divId,seriesName)
{
    Highcharts.chart(divId, {
        chart: {
            type: 'pie',
            custom: {},
            style: {
                fontFamily: 'Roboto'
            },
            "backgroundColor": "transparent",
        },
        accessibility: {
            point: {
                valueSuffix: '%'
            }
        },
        navigation: {
            buttonOptions: {
                enabled: false
            }
        },
        title: {
            text: ''
        },
        subtitle: {
            text: ''
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        legend: {
            enabled: true
        },
        credits: {
            enabled: false
        },
        plotOptions: {
            series: {
                allowPointSelect: true,
                cursor: 'pointer',
                borderRadius: 8,
                dataLabels: [{
                    enabled: false,
                    distance: 20,
                    format: '{point.name}'
                }, {
                    enabled: true,
                    formatter: function() {
                        return this.y > 0 ? this.percentage.toFixed(1) + '%' : null;
                    },
                    distance: 20,
                    // format: '{point.percentage:.1f}%',
                    style: {
                        fontSize: '0.9em'
                    }
                }],
                showInLegend: true,
                point: {
                    events: {
                        click: function() {
                            var idX = this.series.chart.renderTo.id;
                            console.log(idX);
                            var dataNameX = $(`#${idX}`).data("name");
                            var dropdownName = this.series.name.toLowerCase();
                            var valueName = this.name;
                            clickableSlice(idX, dataNameX, dropdownName, valueName, "charts", "fresh");
                        }
                    }
                }
            }
        },
        // colors: ['#C07B60','#FA8D62','#2C626E','#B1DCD3','#74A9CE','#A6BCDB','#D0D0E7'],
        series: [{
            name: seriesName,
            colorByPoint: true,
            innerSize: '75%',
            data: lucifer
        }],
    });
}

function bubbleChart(lucifer,base,id,airportName,categoryL,heightX)
{
    Highcharts.chart(id, {
        chart: {
            type: 'bubble',
            plotBorderWidth: 1,
            height: heightX
        },
        navigation: {
            buttonOptions: {
                enabled: false
            }
        },
        title: {
            text: ''
        },
        subtitle: {
            text: ''
        },
        credits: {
            enabled: false
        },
        xAxis: {
            categories: airportName,
            startOnTick: false,
            endOnTick: false,
            showLastLabel: true,
            // labels: {
            //     rotation: -45
            // }
        },
        yAxis: {
            title: {
                text: ''
            },
            categories: categoryL,
            startOnTick: false,
            endOnTick: false,
            showLastLabel: true
        },
        tooltip: {
            headerFormat: '<b>{series.name}</b><br>',
            pointFormat: 'Gender: {point.y}, Airport: {point.x}, Value: {point.z}'
        },
        plotOptions: {
            bubble: {
                minSize: 0,
                maxSize: 70,
                dataLabels: {
                    enabled: true,
                    format: '{point.z}%',  // Show the z value inside the bubble
                    style: {
                        color: 'black',    // Make the label color black for better contrast
                        textOutline: 'none', // Remove the text outline
                        fontWeight: 'bold',
                        fontSize: "12px"
                    }
                }
            }
        },
        series: lucifer
    });

}

function lineChart(lucifer,id)
{
    Highcharts.chart(id, {
        chart: {
            type: 'line',
            style: {
                fontFamily: 'Roboto'
            },
            "backgroundColor": "transparent",
        },
        title: {
            text: ''
        },
        xAxis: {
            categories: airportName
        },
        yAxis: {
            title: {
                text: ''
            },
            gridLineWidth: 0,
            minorGridLineWidth: 0,
            alignTicks: false,
            labels: {
                enabled: false
            }
        },
        navigation: {
            buttonOptions: {
                enabled: false
            }
        },
        credits: {
            enabled: false
        },
        tooltip: {
            shared: true,
            split: false,
            enabled: true,
            headerFormat: '<b>{point.x}</b><br/>',
            pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}%</b> <br/>',
        },
        plotOptions: {
            line: {
                dataLabels: {
                    enabled: true,
                    cursor: 'pointer',
                    formatter: function() {
                        return this.y + '%';
                    },
                },
                enableMouseTracking: true
            }
        },
        colors: [
            '#001F3F', // Navy Blue
            '#007B7F', // Teal
            '#005F00', // Dark Green
            '#708090', // Slate Gray
            '#800000', // Maroon
            '#DAA520', // Goldenrod
            '#4682B4', // Steel Blue
            '#6B8E23', // Olive Drab
            '#DC143C', // Crimson
            '#7851A9'  // Royal Purple
        ],
        series: lucifer
    });
}

function countryChart(lucifer,id) {
    const displayStates = new Set(lucifer.map(item => item['hc-key']));

    fetch('https://code.highcharts.com/mapdata/countries/in/in-all.topo.json')
        .then(response => response.json())
        .then(topology => {
            // Create the chart
            Highcharts.mapChart(id, {
                chart: {
                    map: topology
                },

                title: {
                    text: ''
                },
                credits: {
                    enabled: false
                },
                navigation: {
                    buttonOptions: {
                        enabled: false
                    }
                },
                mapNavigation: {
                    enabled: false,
                    buttonOptions: {
                        verticalAlign: 'bottom'
                    }
                },

                colorAxis: {
                    min: 0
                },
                legend: {
                    align: 'right',
                    layout: 'vertical',
                    margin: 0,
                    verticalAlign: 'top',
                    y: 25,
                    symbolHeight: 280,
                    enabled:false
                },

                series: [{
                    data: lucifer,
                    joinBy: 'hc-key',  // Join data by 'hc-key' to map regions correctly
                    name: 'Airport Data',
                    states: {
                        hover: {
                            color: '#BADA55'
                        }
                    },
                    dataLabels: {
                        enabled: true,
                        formatter: function() {
                            if (displayStates.has(this.point['hc-key'])) {
                                //console.log(`${this.point.name}: ${this.point.value}`);
                                return `${this.point.name}: ${this.point.value}`;
                            }
                            return null;
                        },
                    }
                }]
            });
        })
        .catch(error => console.error('Error loading map data:', error));
}





// ------------------------------------------------------------ CHART END ----------------------------------------------------- //

//------------------------------------------------------------EXCEL EXPORT START--------------------------------------------------------------

function exportExcelFlag()
{
    $("#alert_div").show();
    exportExcel();

    setTimeout(() => {
        $("#alert_div").hide();
    }, 2000);
}

function exportExcel()
{
    var url = "excel.php?condX=" + encodeURIComponent(condX) + "&conX=" + encodeURIComponent(conX) + "&filtercondX=" + encodeURIComponent(filtercondX) + "&zeroStatus=" + encodeURIComponent(zeroStatus);

    $("#frame").empty().append('<iframe src="' + url + '" frameborder="0"></iframe>');
}

window.addEventListener("message", (e) => {
    var data= e.data; // hare are data sent by other window postMessage method
    if(data==1)
    {
        $("#alert_div2").show();
        setTimeout(() => {
            $("#alert_div2").hide();
        }, 3000);
    }
});

//------------------------------------------------------------EXCEL EXPORT END--------------------------------------------------------------



        </script>
    </body>
</html>