var History = {
  require: function(libraryName) {
    // inserting via DOM fails in Safari 2.0, so brute force approach
    document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
  },
  load: function() {
    if((typeof Prototype=='undefined') || 
       (typeof Element == 'undefined') || 
       (typeof Element.Methods=='undefined') ||
       parseFloat(Prototype.Version.split(".")[0] + "." +
                  Prototype.Version.split(".")[1]) < 1.5)
       throw("script.aculo.us requires the Prototype JavaScript framework >= 1.5.0");
       
    $A(document.getElementsByTagName("head")[0].getElementsByTagName("script")).findAll( function(s) {
       //if(console) console.log(s.src);
       return (s.src && s.src.match(/history\.js(\?.*)?$/))
     }).each( function(s) {
      var path = s.src.replace(/history\.js(\?.*)?$/,'');
      var includes = s.src.match(/history\.js\?.*load=([a-z,]*)/);
      (includes ? includes[1] : 'Ajax.Application.Base,Ajax.Application.Cache,EventDispatcher,Ajax.Application.Event,Ajax.Service.Base,Ajax.Service.History').split(',').each(
      function(include)
      {
        //if( console ) console.log(path+include+'.js');
        History.require(path+include+'.js')
      });
    });
  }
}

History.load();