Start with a tab based on url

Start with a tab based on url

How can I make the UI tabs start with a tab definded by php
so if a go to a page with a uri of http://example.com/page.php?tab-17
i want the tab-17 to be displayed
i managed to get the uri but i don't really know what to do next

the $url[1] is the tab-17

  1. <?php
  2.       $page = $_SERVER['REQUEST_URI'];
  3.       $url = explode("?", $page);
  4. ?>
  5. <script type="text/javascript">
  6.       $(document).ready(function() {
  7.       $("#tabs").tabs();
  8.       <?php
  9.             if ($url[1] == "") {
  10.                   echo "$('div.ui-tabs:first-child').removeClass('ui-tabs-hide');";
  11.             } else {
  12.                   echo "$('div.ui-tabs:first-child').tabs({disabled: true});
  13.                   $('div#$url[1]').tabs('enable');";
  14.             }
  15.       ?>           
  16.       });
  17. </script>
Any help would is appreciated!

Kajusz