/*
 *	init_browser.js
 */
hostenv.loadScript("jess.js");

dojo.hostenv.setModulePrefix("jess", "../jess");
dojo.hostenv.setModulePrefix("MochiKit", "../MochiKit");

dojo.addOnLoad(function() { jess.run(document.body.version) });

jess.run = function(version, runJso) {
	var l = window.location.toString();
	var start = new Date();

	if(l.indexOf("localhost") !== -1) {
		version = -1;
		l += "&uc=1";
	}

	hostenv.__callstack_trace_enabled = l.indexOf("&cs=1") !== -1;
	
	jess._version = version;
	if(l.indexOf("&uc=1") === -1) {
		hostenv.loadScript("jess_.js?" + jess.getVersion());
	} else {
		hostenv.loadScript("jess/lang.js?" + jess.getVersion());
		jess.require("jess.lang.Class");
		jess.require("jess.log");
		jess.require("jess.context");
		jess.require("jess.util.Url");
		jess.require("jess.util.Library");
	}

	if(runJso !== false) {
		var params = jess.util.Url.getParams();
		if(!params.length || params[0].name !== "appl") {
			jess.require("jess.jso");
			jess.jso.run(params);
		} else {
			jess.require(params[0].value);
		}

		var node = document.getElementById("loading");
		if(node !== null) {
			node.parentNode.removeChild(node);
		}

		jess.log.debug("loaded", new Date() - start);
	}

	jess.run = function() {};
}
