i have this jquery code:

```
<script type="text/javascript">
  $(document).ready(function() {
    $(".tabLink").each(function(){
      $(this).click(function(){
        tabeId = $(this).attr('id');
        $(".tabLink").removeClass("activeLink");
        $(this).addClass("activeLink");
        $(".tabcontent").addClass("hide");
        $("#"+tabeId+"-1").removeClass("hide")   
        return false;     
      });
    });  
  });
</script>

```

i am trying to make it so the tab is remembered if the page is refreshed by using this code:

```
<script type="text/javascript">
  $(document).ready(function() {
    $(".tabLink").each(function(){
      $(this).click(function(){
        localStorage.selectedTab = $(this).index() + 1;
        tabeId = $(this).attr('id');
        $(".tabLink").removeClass("activeLink");
        $(this).addClass("activeLink");
        $(".tabcontent").addClass("hide");
        $("#"+tabeId+"-1").removeClass("hide")   
        return false;     
      });
    });  

    // search for local storage
    if (localStorage.selectedTab) {
      $(".tabLink:eq(" + (localStorage.selectedTab - 1) + ")").click();
    }
  });
</script>

```

HTML:

```
<div class="tab-box">
        <a href="javascript:;" class="tabLink activeLink" id="viewcustomer">View Customer</a> 
        <a href="javascript:;" class="tabLink activeLink" id="viewresellercustomers">View Reseller Customer</a> 
        <a href="javascript:;" class="tabLink activeLink" id="viewsalesmancustomer">View Salesman Customer</a> 
        <a href="javascript:;" class="tabLink" id="archivedcustomers">View Archived Customer</a> 
        </div>

<div class="tabcontent" id="viewcustomer-1">
content...
</div>.....

```

it works fine, but the tabs are on multiple pages so if i go to a different page, a different tab is selected as its trying to remember the last selected tab.

how can i make it remember the last selected tab for each page?