window.SEJS = function(lib, cb) {if (!cb) SEJS.Import(lib); else SEJS.Import(lib, cb)}
SEJS.siteroot = "";
SEJS.lib = [
			'Accordion','Ajax','Alert','CharacterLimit','Clipboard','Clock','Cookie','Cursor','Element','Fileinput','Form',
			'InputSkin','Lightbox','RemoteAjax','SelectSwap','Site','Template','Tooltip','Xml'
];
SEJS.init = function() {
	for (var i in SEJS.lib) SEJS.createProxy(SEJS.lib[i]);
	SEJS.queue.run('SEJS');
	try {document.getElementsByTagName('head')[0].removeChild(document.getElementById("SEJS"))} catch(e){};
}
SEJS.createProxy = function(lib) {
	SEJS[lib] = function() {
		var arrArgs = Array.prototype.slice.apply(arguments);
		SEJS(lib, function() {SEJS[lib].apply(SEJS[lib], arrArgs)});
	}
}
SEJS.Env = {
	ie: (/*@cc_on!@*/false),
	ie5: (/*@cc_on!@*/false && /msie 5\.0/i.test(navigator.userAgent)),
	opera: (/opera/i.test(navigator.userAgent)),
	khtml: (/Konqueror|Safari|KHTML|WebKit/i.test(navigator.userAgent)),
	moz: (/mozilla/i.test(navigator.userAgent) && !/(compati)/.test(navigator.userAgent))
};
SEJS.queue = function(sejsevent, callback) {
	var Q = SEJS.queue.q, e = sejsevent, c = callback;
	if(!Q[e]) Q[e] = {callback: [c], hasrun: 0};
	else if(Q[e].hasrun == 1) c.call();
	else Q[e].callback.push(c);
}
SEJS.queue.q = {};
SEJS.queue.run = function(e) {
	var Q = SEJS.queue.q;
	if (Q[e]) {
		if (Q[e].callback) for (var i = 0; i < Q[e].callback.length; ++i) Q[e].callback[i].call();
		Q[e].hasrun = 1;
	}
	else Q[e] = {hasrun: 1};
}
SEJS.writeLog = function(msg,skiptest) {if (SEJS.Env.moz || skiptest) try{console.log(msg)} catch(e){}}
SEJS.Import = function(lib, callback) {
	var Q = SEJS.queue, c = callback;
	if (c) Q(lib, c);
	Q('SEJS', function() {SEJS.Import.run(lib)});
}
SEJS.Import.loaded = {};
SEJS.Import.datestamp = ((new Date()).getTime()).toString();
SEJS.Import.run = function(lib) {
	var I = SEJS.Import.loaded, l = lib;
	if (!I[l]) {
		I[l] = true;
		var path = SEJS.siteroot + '/sejs/';
		for (var j in SEJS.lib) if(SEJS.lib[j] == l) path += "lib/" + l + ".js";
		if (SEJS.custom) for (var j in SEJS.custom) if (SEJS.custom[j] == l) path += "custom/" + l + ".js";
		if (l == 'Global') path += "site/" + l + ".js";
		if (l == 'currentpage') path += "site/" + SEJS.Site.currentpage + ".js";
		SEJS.Import.addScript(l, path);
	}
}
SEJS.Import.addScript = function(id, path) {
	path += ((path.indexOf("?") == -1) ? "?" : "&") + "__nc=" + SEJS.Import.datestamp;
	var s = document.createElement('script');
	s.id = "SEJS_Import_" + id;
	s.src = path;
	s.type = 'text/javascript';
	document.getElementsByTagName('head')[0].appendChild(s);
}
SEJS.checkIn = function(l) {
	SEJS.queue.run(l);
	SEJS.Import.removeScript(((l == 'SEJS') ? l : "SEJS_Import_" + l));
}
SEJS.Import.removeScript = function(id) {
	var r = function(){document.getElementsByTagName('head')[0].removeChild(document.getElementById(id))};
	try {r()} catch(e) {setTimeout(function(){try {r()} catch(e){}}, 2000)}
}
SEJS.settings = function(defaultsettings, customsettings) {
	var m = defaultsettings, c = customsettings;
	for (var i in c) {
		if (typeof(c[i]) == typeof(m[i])) {
			if (typeof(c[i]) == "object") for (var j in c[i]) m[i][j] = c[i][j];
			else m[i] = c[i];
		}
	}
	return m;
}
SEJS('Site', function(){SEJS.Site.init()});
SEJS.WindowEvent = function(event_name, callback) {
	SEJS.queue("Window_on" + event_name, callback);
	window['on' + event_name] = function(){SEJS.queue.run("Window_on" + event_name)};
}
SEJS.Event = function(windowevent, callback, target) {
	var E = SEJS.Event, id = SEJS.uid(), w = windowevent, cb = callback, t = (target) ? target : window;
	try{t.eventid = id} catch(e){};
	id = (t.eventid) ? t.eventid : "windowevent_" + w;
	if (!E.events[id]) {
		E.events[id] = (typeof(t['on' + w]) == "function") ? [t['on' + w]] : [];
		t['on' + w] = function(ev){E.notify(id,ev)};
	}
	E.events[id].push(cb);
}
SEJS.Event.notify = function(id,ev) {
	var E = SEJS.Event;
	var ee = E.events;
	if (!ev) var ev = window.event;
	if (!ev) ev = {type: 'load'};
	if (id) if (ee[id]) for (var i = 0; i < ee[id].length; ++i) if (typeof ee[id][i] == "function") ee[id][i](ev);
}
SEJS.ElementEvent = function(event_name, target_id, callback, toreturn) {
	if (!document.getElementById(target_id)) return;
	var qname = target_id + "_on" + event_name;
	if (SEJS.queue.q[qname]) SEJS.queue.q[qname].hasrun = 0;
	SEJS.queue(qname, function(){callback(event_name, target_id)});
	document.getElementById(target_id)['on' + event_name] = function(){SEJS.queue.run(qname); return (toreturn)};
}
SEJS.get = function(name_or_id) {
	var e = document.getElementById(name_or_id);
	if (!e) e = document.getElementsByName[name_or_id];
	if (!e) return null;
	if (!e.id) e.id = "SEJS_uid_" + SEJS.idcounter++;
	return e;
}
SEJS.uid = function() {return "SEJS_uid_" + SEJS.idcounter++}
SEJS.idcounter = 0;
SEJS.Event.events = [];
SEJS.Event('load', function() {SEJS.init()});