// Loads the required libraries from xft-base
(function() {
	if (typeof cm4all == "undefined") {
		cm4all = {};
	}

	try {
		var script = (function (e) {
			return (e.nodeName == 'SCRIPT') ? e: arguments.callee(e.lastChild || e.previousSibling);
		})(document.body || document);
		
		var regexres = /load=([^&]+)/.exec(script.src);
		var baseregexres = /([^\/]+:\/\/[^\/]+)/.exec(script.src);
		
		var toload = regexres ? regexres[1] : "";
		var libz = [
			[ "/res/js/thirdparty/prototype-1.6.1/prototype.js", function() { return (typeof Prototype == "undefined");} ],
			[ "/res/js/lib/HttpURL.js", function() { return true; } ],
			[ "/res/js/lib/XFrameTunnel/" + toload + ".js", function() { return true; } ]
		];

		cm4all.XFrameTunnel = {
            base : baseregexres ? baseregexres[1] : "",
            data : (script.textContent || script.text)
        };
		
		for (var i = 0 ; i < libz.length ; i++) {
			if (libz[i][1]()) {
				document.write('<scr'+'ipt type="text/javascript" src="' + cm4all.XFrameTunnel.base + libz[i][0] + '"></scr'+'ipt>');
			}
		}
	} catch (x) {
		alert("Exception:" + x);
	}
})();
