<%@ page language="C#" masterpagefile="~/Pages/Common/MasterPages/MainMasterPage_new.master" autoeventwireup="true" inherits="Pages_Transport_TrackMyBus, App_Web_y4s5qbrn" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="~/UserControls/GridViewPager/GridViewPager.ascx" TagName="GridViewPager" TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/Common/ScreenGroup/ScreenGroup.ascx" TagName="ScreenGroupControl" TagPrefix="ScreenGroup" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
    <asp:UpdatePanel ID="ResonMasterUpdatePanel" runat="server">
        <ContentTemplate>
            <div id="divContentPage" class="divcontentpagemargin">
                <div class="dashBoardLeftCont">
                    <div class="himssuHeader3WireBox">
                        <table>
                            <tr>
                                <td>
                                    <div class="himsBoxContent">
                                        <div class="leftUlMenu">
                                            <ScreenGroup:ScreenGroupControl EnableViewState="true" ID="ScreenGroupControl" ScreenGroupId="172"
                                                Visible="true" runat="server" />
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="whiteboxpaddingleft row">
                    <div class="card card-box">
                        <div class="himssuHeader5WireBox">
                            <div class="himsBoxHeader card-head">
                                <div class="leftdiv">
                                </div>
                                <div class="himsBoxTitle">
                                    <div class="headerText">
                                        <header>
                                            <i class="fas fa-search"></i>
                                            <asp:Label ID="SelectLibraryLabel" runat="server" Text="Track My Bus"></asp:Label>
                                        </header>
                                    </div>
                                </div>
                            </div>
                            <div class="himsBoxContent card-body">
                                <asp:HiddenField ID="VTSSubUserPasswordHiddenField" runat="server" />
                                <asp:HiddenField ID="VTSSubUserNameHiddenField" runat="server" />
                                <asp:HiddenField ID="VehicleRegistrationNoHiddenField" runat="server" />
                                <asp:HiddenField ID="RouteTypeIdHiddenField" runat="server" />
                                <div class="contentHolder">
                                    <div id="VTSRedirectDiv" runat="server" class="pt-2 pb-2 row ml-2 mr-2 mt-2" style="border: 1px solid black; border-radius: 4px;">
                                        <div class="col-md-6 text-center text-white">
                                            <a id="PickUpLink" runat="server" target="_blank" class="btn btn-info" text="&#xf207; Pickup Route"><i class="fas fa-map-marker-alt"></i>Pickup Route</a>
                                        </div>
                                        <div class="col-md-6 text-center text-white">
                                            <a id="DropLink" runat="server" target="_blank" class="btn btn-info"><i class="fas fa-map-marker-alt"></i>Drop Route</a>
                                        </div>
                                    </div>
                                    <div id="GoogleMapDiv" runat="server">
                                        <div id="VTSButtonDiv" runat="server" class="pt-2 pb-2 row ml-2 mr-2 mt-2" style="border: 1px solid black; border-radius: 4px;">
                                            <div class="col-md-6 text-center text-white">
                                                <asp:Button ID="VTSPickUp" runat="Server" OnClick="VTSPickUp_Click"
                                                    Text="&#xf06e; Pickup Route" SkinID="CustomWidthButton,0" CssClass="btn btn-assign fas" />
                                            </div>
                                            <div class="col-md-6 text-center text-white">
                                                <asp:Button ID="VTSDrop" runat="Server" OnClick="VTSDrop_Click"
                                                    Text="&#xf06e; Drop Route" SkinID="CustomWidthButton,0" CssClass="btn btn-assign fas" />
                                            </div>
                                        </div>
                                        <div id="VTSMapDiv" runat="server">
                                            <iframe id="mapFrame" width="600" height="450" frameborder="0" style="border: 0" allowfullscreen></iframe>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            </div>
           
        </ContentTemplate>
    </asp:UpdatePanel>
    <%--<script data-main="../../JavaScript/rjs/encrypt/select-transport-encrypt" src="../../JavaScript/rjs/require.js"></script>--%>
    <script data-main='<%=ResolveUrl("~/JavaScript/rjs/select-transport")%>' src='<%=ResolveUrl("~/JavaScript/rjs/require.js")%>'></script>
    <script type="text/javascript">
        window.onload = function () {
            startAutoRefresh();
        }

        function startAutoRefresh() {
            setInterval(refreshMap, 60002); // Refresh every 10 seconds
        }

        function refreshMap() {
            $.ajax({
                type: "POST",
                url: "TrackMyBus.aspx/RefreshMap",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify({
                    "VTSSubUserPassword": document.getElementById('<%=VTSSubUserPasswordHiddenField.ClientID%>').value,
                    "VTSSubUserName": document.getElementById('<%=VTSSubUserNameHiddenField.ClientID%>').value,
                    "VehicleRegistrationNo": document.getElementById('<%=VehicleRegistrationNoHiddenField.ClientID%>').value,
                    "RouteTypeId": document.getElementById('<%=RouteTypeIdHiddenField.ClientID%>').value
                }),
                dataType: "json",
                success: function (result) {
                    
                    document.getElementById('mapFrame').src = result.d;

                },
                error: function (xhr, status, error) {
                    var err = eval("(" + xhr.responseText + ")");
                    console.log(err.Message);
                }
            });
        }
    </script>
</asp:Content>
