var call = {
	cnt: 0,
	routeMaxLen: 0,
	loaded: 0,
	funcSet: new Array(),
	funcIndex: 0,
	cssSet: new Array(),
	css: function() {
		var args = this.css.arguments;
		for (var i = 0; i < args.length; i++) {
			if (this.cssSet[args[i]]) continue;
			var link   = document.createElement('link');
			link.rel   = 'stylesheet';
			link.type  = 'text/css';
			link.href  = args[i]; //Path of your Stylesheet files
			link.media = 'screen';
			document.getElementsByTagName('head')[0].appendChild(link);
			this.cssSet[args[i]] = true;
		}
	},

	createFunction: function(args) {
		var func = escape(args[0]);
		while (this.funcSet[func]) {
			func += '::addFunc';
		}
		this.funcSet[func] = new Array();
		var cnt = 0;
		this.funcSet[func][0] = args[0];
		for (var idx = 1; idx < args.length; idx++) {
			this.funcSet[func][idx] = args[idx];
		}
	},

	func: function() {
		this.createFunction(this.func.arguments);
		if (this.loaded == 1) return this.funcExec();
		return false;
	},

	exec: function() {
		if (this.loaded == 0) {
			alert('확장 요소가 아직 구성되지 않았습니다. 몇 초 뒤에 시도하세요.');
			return false;
		}
		this.createFunction(this.exec.arguments);
		return this.funcExec();
	},

	funcExec: function() {
		var returnValue;
		for (var index in this.funcSet) {
			var func = call.funcSet[index][0];
			if (typeof(func) == 'string' || typeof(func) == 'function') {
				var code = '';
				if (typeof(func) == 'string') {
					code += func + '(';
				}
				else if (typeof(func) == 'function') {
					code += "call.funcSet['" +index+ "'][0](";
				}

				for (var idx = 1; idx < this.funcSet[index].length; idx++) {
					code += "call.funcSet['" +index+ "'][" +idx+ "], ";
				}
				code = code.replace(/, $/, '');
				code += ');';
				try { returnValue = eval(code); }
				catch (e) { alert(unescape(code) +': '+ e.message); }
			}
		}

		this.funcSet = new Array();
		this.funcIndex = 0;
		return returnValue;
	},

	call: function() {
		setTimeout(function() {
			var script = document.createElement('script');
			script.defer = true;
			script.charset = 'utf-8';
			script.src = '/proxy/js/';
			try {
				document.getElementsByTagName('head').item(0).appendChild(script);
			} catch (e) { alert(e.message); }
		}, 1);
	}
};
onload = function() { call.call('/proxy/js/'); };

