var itm = {
	submenuNode: null,
	collapseSubmenu: function() {
		if(this.submenuNode!=null){
			this.submenuNode.style.display='none';
			this.submenuNode=null;
		}
	},
	expandMenu: function(where, sectionPrefix) {
		if(this.submenuNode) {
			if(this.submenuNode.parentNode!=where)
				this.collapseSubmenu();
			else
				return null;
		}
		if(where._submenuNode) {
			if(where._submenuNode==true) return null;
			where._submenuNode.style.display="block";
			this.submenuNode=where._submenuNode;
			return null;
		}
		eval("var data="+flamework.json.mod_sections.getSectionList(sectionPrefix));
		if(data.sections && data.sections!=null){
			var ul=where.appendChild(document.createElement('ul'));
			ul.className='submenu';
			ul.style.position='absolute';
			ul.style.top='100%';
			ul.style.left='0px';
			data=data.sections.section;
			if(!data.length)
				data=new Array(data);
			for(var i=0; i<data.length;i++){
				var li=ul.appendChild(document.createElement('li'));
				li.className='submenu';
				var a=li.appendChild(document.createElement('a'));
				a.setAttribute('onclick', 'document.location.href="/section/'+data[i].name+'; return false;"');
				a.setAttribute('href', '/section/'+data[i].name);
				a.style.top='15px';
				a.appendChild(document.createTextNode(data[i].aliases.alias.alias));
			}
			this.submenuNode=ul;
			where._submenuNode=ul;
		}
	},
	preloadMenu: function(where, sectionPrefix) {
		eval("var data="+flamework.json.mod_sections.getSectionList(sectionPrefix));
		if(data.sections && data.sections!=null){
			var ul=where.appendChild(document.createElement('ul'));
			ul.className='submenu';
			ul.style.display='none';
			ul.style.position='absolute';
			ul.style.top='100%';
			ul.style.left='0px';
			data=data.sections.section;
			if(!data.length)
				data=new Array(data);
			for(var i=0; i<data.length;i++){
				var li=ul.appendChild(document.createElement('li'));
				li.className='submenu';
				var a=li.appendChild(document.createElement('a'));
				a.setAttribute('onclick', 'document.location.href="/section/'+data[i].name+'; return false;"');
				a.setAttribute('href', '/section/'+data[i].name);
				a.style.top='15px';
				a.appendChild(document.createTextNode(data[i].aliases.alias.alias));
			}
			where._submenuNode=ul;
		}
		else
		{
			where._submenuNode=true;
		}
	}

}

