$(function(){
  var r = new RegExp(/.*m=(\w*)/);
  var match = r.exec(window.location.href);
  var index;

  if(match)
  {
    index = menu.indexOf(match[1]);
  }
  else
  {
    index = 0;
  }

  var tabs = $("ul#map_menu").tabs("div#map_container > div", {

    effect: 'fade',

    onBeforeClick: function(event, i) {

      // get the pane to be opened
      var pane = this.getPanes().eq(i);

      // only load once. remove the if ( ... ){ } clause if you want the page to be loaded every time
      if (pane.is(":empty")) {

        // load it with a page specified in the tab's href attribute
        pane.load(this.getTabs().eq(i).attr("href"));
      }

    },

    initialIndex: index
    
  }).history();

  $('a#map_switch').live('click', function(){
    $('div#google_map_container').toggle();
    $('div.inner_map.map').toggle();
    return false;
  });

});