﻿/*
V.2007082101
O.May 16 2007 
A.Zed Gu @ Eachui Team
D.for Load JS Files
Copyright (c) 2007, Eachnet All rights reserved.
*/

var ejs = {
	path: function() {
		return this.filter(/js\.js(\?.*)?$/).match(/(.*)\/js\.js/)[1] + '/';
	},
	require: function() {
		eval("var tS = /" + arguments[0] + "/;");
		if (this.filter(/(.*).js/).match(tS) != arguments[0] || arguments[2]) {
			if (typeof(arguments[1]) != "string") {
				arguments[1] = this.path();
			}
			var tA = arguments[0].split('.');
			document.write('<script type="text/javascript" src="' + arguments[1] + tA[0] + '.js?v=' + tA[1] + '"></script>');
		}
	},
	load: function() {
		var s = this.filter(/js\.js(\?.*)?$/);
		if (typeof(s) != "undefined") {
			var a = s.match(/\.*f=(.*)/);
			var p = s.match(/&\.*p=(.*)/);
			var f = a[1].split(',');
			if (p != null) {p = p[1];}
			for (var i = 0; i < f.length; i++) {
				this.require(f[i],p,true);
			}
		}
	},
	filter: function(pPath) {
		var path = false;
		var s = document.getElementsByTagName("script");
		for (var i = 0;i<s.length;i++) {
			if (s[i].src && s[i].src.match(pPath)) {
				path = s[i].src;
				break;
			}
		}
		return path;
	}
};
ejs.load();
