/**
 * = Linker -- (Almost) simple JavaScript loader
 * (c) 2007 Ivan Zhekov, Thomas Fuchs
 *
 * Remake of scriptaculous.js by Thomas Fuchs.
 * Linker is freely distributable under the terms of an MIT-style license.
 *
 *--------------------------------------------------------------------------*/

// Anonymous function
(function() {

var Linker = {
  Version: "1.0.2",
  require: function (libraryName) {
    // inserting via DOM fails in Safari 2.0, so brute force approach
    document.write("\n<script type=\"text/javascript\" src=\"" + libraryName + "\"></script>");
  },
  load: function() {
    var scripts = document.getElementsByTagName("script");
    for (var i = 0; i < scripts.length; i++) {
      if (scripts[i].src && scripts[i].src.match(/linker\.js(\?.*)?$/)) {
	this.path = scripts[i].src.replace(/linker\.js(\?.*)?$/,"");
	this.params = scripts[i].src.match(/\?.*load=([A-Za-z0-9.,\-\_\/]*)/);
	Linker.params
	  ? this.includes = Linker.params[1].split(",")
	  : this.includes = "prototype,pngfix/pngfix".split(",");
	for (j = 0; j < Linker.includes.length; j++) {
	  Linker.require(Linker.path + Linker.includes[j] + ".js");
	};
      };
    };
  }
}
Linker.load();

})();