/* charlotte.js
 * Author: arthur@hippo.nl
 * Date: 19/09/2002
*/

// provides access to libraries
Charlotte = function() {
	this.librarypath = '';
	this.packages = [];
}

Charlotte.prototype.addPackage = function(pckg) {
	if (this.packages[pckg]) return;
	this.packages[pckg] = { libs: [] };
}
Charlotte.prototype.addLibrary = function(path,files) {
	var pckg = path.substring(0,path.indexOf('.'));
	if (!pckg) {
		alert("Error: Incorrect Charlotte.addLibrary usage");
		return;
	}
	var name = path.substring(path.indexOf('.')+1);
	if (!this.packages[pckg]) this.addPackage(pckg);
	if (this.packages[pckg].libs[name]) {
		alert("Error: Library "+name+" already exists");
		return;
	}
	this.packages[pckg].libs[name] = files;
}
Charlotte.prototype.inc = function(src,pth) {
	src=src.split('.');
	if (src[src.length-1] == 'js') src.length -= 1;
	var path=pth||this.librarypath||'';
	if (path.substr(path.length-1) != "/") path += "/";
	var pckg=src[0];
	var grp=src[1];
	var file=src[2];
	if (file=='*') {
		if (this.packages[pckg]) group=this.packages[pckg].libs[grp];
		if (group) for (var i=0;i<group.length;i++) document.write('<script language="Javascript" src="'+path+pckg+'/'+grp+'/' +group[i]+'.js"><\/script>');
		else alert('include()\n\nThe following package could not be loaded:\n'+src+'\n\nmake sure you specified the correct path.');
	} else document.write('<script language="Javascript1.2" src="'+path+src.join('/')+'.js"><\/script>');
}

Charlotte.prototype.setLibraryPath = function(path) {
	if (path.substring(path.length-1)!='/') path+='/';
	this.librarypath=path;
}

cl = new Charlotte();
cl.addPackage('cbe');
cl.addLibrary('cbe.core' , ["cbe_core"]);
cl.addLibrary('cbe.event', ["cbe_event"]);
cl.addLibrary('cbe.gui'  , ["cbe_clip","cbe_slide"]);
cl.addLibrary('cbe.util' , ["cbe_util"]);
cl.addLibrary('cbe.debug', ["cbe_debug"]);

cl.addPackage('hippo');
cl.addLibrary('hippo.util' , ['hippo_container',"hippo_window"]);
cl.addLibrary('hippo.nld' , ['hippo_nld_navigation']);

