Drupal tabs activated trough URL anchors

This is the code for calling a js file from the module

<?php
$path
= drupal_get_path('module', 'name_of _the_module');   
drupal_add_js($path .'/name_js_file.js');
?>

this is the js code for the functions
<?php
if (Drupal.jsEnabled) {
  $(
document).ready(function() {
    var
myFile = document.location.toString();
    if (
myFile.match('#')) { // the URL contains an anchor
        // click the navigation item corresponding to the anchor
       
var myAnchor = '#' + myFile.split('#')[1];
        $(
'ul.anchors li a[href="' + myAnchor + '"]').click();
    }
  });
}
?>