function loadJS(libraryName) {
    document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
}

function initJS() {
	var authTokenCookie=document.cookie.match('authToken=(.*?)(;|$)');
	if (!authTokenCookie) return;
	token=unescape(authTokenCookie[1]);
	if (token=="") return;

	loadJS("/js/admin.js");

	if (document.getElementById('article-title')) {
		loadJS("/js/article-edit.js");
	} 
	if (document.getElementById('active')) {
		loadJS("/js/items-edit.js");
	} 
	if (document.getElementById('portal')) {
		loadJS("/js/portal.js");
	}
}

initJS();

if ($('subscribe_alert')) {
	loadJS("/js/alert.js");
}

function wireThumbnail(elem) {
	new Control.Modal(elem, {
		hover: true,
		image: true,
		position: 'relative', 
		offsetLeft: 40
	});
}

if ($('active')) {
	items=$('active').getElementsByClassName('thumb');
	if (items.length>0)
		items.each(wireThumbnail);
	
}
