TempoAPIObject = function() {
	this.loaded = false;
	this.librarypath = '';
	this.packages = [];
	this.errorHandling = true;
	this.returnErrors = true;
	this.version = '1.0';
	this.ns4 = (document.layers)? true:false
	this.ns6 = (document.layers)? true:false
	this.ie4 = (document.all)? true:false
}
TempoAPIObject.prototype.setLibraryPath = function(path) {
	if (path.substring(path.length-1)!='/') path+='/';
	this.librarypath=path;
}
TempoAPIObject.prototype.include = 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="Javascript1.2" 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>');
}
TempoAPIObject.prototype.addPackage = function(pckg) {
	if (this.packages[pckg]) return;
	this.packages[pckg] = { libs: [] };
}
TempoAPIObject.prototype.addLibrary = function(path,files) {
	var pckg = path.substring(0,path.indexOf('.'));
	if (!pckg) {
		alert("API Error: Incorrect API.addLibrary usage");
		return;
	}
	var name = path.substring(path.indexOf('.')+1);
	if (!this.packages[pckg]) this.addPackage(pckg);
	if (this.packages[pckg].libs[name]) {
		alert("API Error: Library "+name+" already exists");
		return;
	}
	this.packages[pckg].libs[name] = files;
}
TempoAPIObject.prototype.errorHandler = function (msg, url, lno) {
	if (!this.loaded || !this.errorHandling) return false;
	if (is.ie) {
		lno-=1;
		alert("API reported an error\n\nError in project: '" + url + "'.\nLine number: " + lno + ".\n\nMessage: " + msg);
	} else if (is.ns4 || is.ns6) {
		alert("API reported an error\n\nError in file: '" + url + "'.\nLine number: " + lno + ".\n\nMessage: " + msg);
	} else return false;
	return this.returnErrors;
}
TempoAPI = new TempoAPIObject();
onerror = function(msg, url, lno) { TempoAPI.errorHandler(msg, url, lno); }
TempoAPI.addPackage('tempoapi');
TempoAPI.addLibrary('tempoapi.gui' ,["browser","gui"]);
TempoAPI.addLibrary('tempoapi.form' ,["form"]);
TempoAPI.addLibrary('tempoapi.form1' ,["form1"]);