
var yourListener = function(newLocation, historyData) {

  var what = ($('workdetail')) ? 'workdetail' : 'person';

  if ($(what)) {
    if ((historyData == null) || (newLocation == 'list')) {
      $(what).hide(); 
      $('listwrap').setStyle('visibility:visible');
    }
    else {
      new Ajax.Updater(what, newLocation+location.search, {asynchronous:true, evalScripts:true, 
            onComplete:function(request, json) {initRelateds(); initGallery(); $(what).show(); $('listwrap').setStyle('visibility:hidden'); }});
    }
  }
}

window.dhtmlHistory.create({
  toJSON: function(o) {
      return Object.toJSON(o);
    }
    , fromJSON: function(s) {
      return s.evalJSON();
    }
  });

Event.observe(window, 'load', function() {

  var initialHash = window.dhtmlHistory.getCurrentLocation();

  if (initialHash)
    yourListener(initialHash, 'first');

  dhtmlHistory.initialize();
  dhtmlHistory.addListener(yourListener);

});




