// dlib.. DNA js library
// loader file idea taken from scriptaculous.js
// 2006 Paul Crabtree | DNA
var Dlib = {
	path: '', deps: {}, libs: [], imported: {},
	require: function(l) {
		if (l in this.imported) return; // dont load anything twice
		if (this.deps[l]) for (var i=0; i<this.deps[l].length; i++) this.require(this.deps[l][i]);
		document.write('<script type="text/javascript" src="'+this.path+'lib/'+(this.imported[l] = l).replace(/\./gi, '/')+'.js"></script>');
	},
	init: function() {
		for (var i=0, m=null, s=document.getElementsByTagName('script'); i<s.length; i++)
		   if (s[i].src.match(/(.*dlib\/)core\.js(.*)?/)) { this.path = RegExp.$1; break; }
		return this;
	},
	css: function(p, local, condition) {
	    if (typeof condition == 'function' && !condition()) return;
	    if (typeof p == 'string') document.writeln('<link rel="stylesheet" type="text/css" href="'+(local?this.path:'')+p+'"/>');
		else { 
			document.writeln('<style type="text/css">');
			for (var sel in p) document.writeln(sel+' {'+p[sel]+'}');
			document.writeln('</style>');
		}
	},
	dependency: function(lib, deps) {
		this.deps[lib] = deps;
	}
}.init();

// load the default libs.
Dlib.require('moo.83');
Dlib.require('moo.loader');
Dlib.require('png.fix');