var root_path = null;

var jsf = {
	version: '0.9',
	path : null,

	require: function(libraryName) {
		document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
	},
	
	load: function() {
		if(typeof Prototype=='undefined') throw("jsf requires the Prototype JavaScript framework");
		
		var js = /jscripts\/jsf\.js(\?.*)?$/;
	
		$$('head script[src]').findAll(function(s) {return s.src.match(js);}).each(
			(function(s) {
				this.path = s.src.replace(js, '');
      			var includes = s.src.match(/\?.*load=([a-z,]*)/);
				root_path = this.path.match(/^(.*?\/)[a-z0-9]+\/$/)[1];
				
				(includes ? 'global,'+includes[1] : 'global').split(',').each(
					(function(include) {this.require(this.path+'jscripts/'+include+'.js') }).bind(this));
    		}).bind(this)
		);
	}
};

jsf.load();