Adding CSS Class through a Repeater
===

I have a repeater which dynamically generate tab links using Sitecore (sc:Link) like this:

    <asp:Repeater ID="rptTab" runat="server" OnItemDataBound="rptTab_ItemBound">
                <ItemTemplate>
                    <li id= "liTabTest" runat = "server" class="tab-label">
                        <asp:HyperLink onclick = "javascript: TabClick(this)" runat="server" id="aLink">
                            <sc:Link ID="hlTabLink" Field="scTabLink" runat="server" ></sc:Link>
                        </asp:HyperLink>
                    </li>
                </ItemTemplate>
           </asp:Repeater>

Now I have a JS which is handling the CSS:

    var loadURL;
    $(document).ready(function () {
        init();
    });
    
    function init() {
         $("ul#Tab-labels li:first").addClass("TabbedPanelsTabSelected");
      };
    
      function TabClick(obj) {
          $("ul#Tab-labels li").removeClass("TabbedPanelsTabSelected");
          $(obj).addClass("TabbedPanelsTabSelected");
    
     };

This is not working because the each tab is a separate .ASPX page, so the page is getting rendered again and that is why Init() in JS is getting called and CSS is getting executed to the first item everytime. 

This is my code behind:

            protected void rptTab_ItemBound(Object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Item i = e.Item.DataItem as Item;
                Link hlTabLink = e.Item.FindControl("hlTabLink") as Link;
                hlTabLink.DataSource = i.Paths.FullPath;
                hlTabLink.Field = "Title";
                HyperLink aLink = e.Item.FindControl("aLink") as HyperLink;
                aLink.NavigateUrl = Sitecore.Links.LinkManager.GetItemUrl(i);
            }
        }

I tried adding CSS through code-behind but it didnt work because I cannot get the index of the tab (which tab is getting selected). Any solution will be appreciated! Thanks!