function createMenu(list){
	
	
	
	argsMenu=list.shift();
	
	//Init Menu
	var menu=document.createElement("div");
	menu.id=argsMenu.id;
	menu.className="dropdown";
	menu.style.width=argsMenu.width +"px";


var menuInner=document.createElement("div");
		menuInner.className="mi";
		menuInner.id='dropdownInner_'+menu.id;
		menu.appendChild(menuInner);


	var i=0;

	list.each(function(argsEntry){
	
	var entry = document.createElement("div");
			entry.className="entry";
			entry.title=argsEntry.title;
			entry.onclick=argsEntry.onclick;
	
		if(!argsEntry.disabled){
			
	entry.onmouseover=function(){
							
		Element.addClassName(this,"hover");
			
	}.bind(entry);
	
	entry.onmouseout=function(){
	
		Element.removeClassName(this,"hover");
	
	}.bind(entry);

		}else{
		
			Element.addClassName(entry,"disabled");
		
		}

		if(argsEntry.name){
			entry.id=argsEntry.name;
		}

		if(argsEntry.selected){
			Element.addClassName(entry,'selected');
		}
		
		
			if(argsEntry.selectable){
				
				var func=function(){
					if(Element.hasClassName(this,'selected')){
						Element.removeClassName(this,"selected");
						this.selected=false;
					}else{
					Element.addClassName(this,"selected");
					this.selected=true;
					}
				}.bind(entry);
				
			}else if(!argsEntry.disabled){
				
					var func=function(){
							
							toggleMenu(this);
					
						}.bind(menu);
				
			}

if(typeof entry.onclick!='function'){
	
		entry.onclick=func;
	
	}else{
	
	var oldevent=entry.onclick;
	
		entry.onclick=function(){
		
		func();
	
			if(oldevent){oldevent();}
	
		};
	
	}

var entryInner=document.createElement("div");
		entryInner.className="ei";

		var entryTable=document.createElement("table");
		var entryTableTBody=document.createElement("tbody");
		var entryTableTr=document.createElement("tr");
		var entryIcon=document.createElement("td");

				entryIcon.className="icon";

					if(argsEntry.icon){
						var iconParams=argsEntry.icon.split(/ /);
						
						var entryIconImg=document.createElement("img");
								entryIconImg.src=iconParams[0];
								entryIconImg.width=iconParams[1]||16;
								entryIconImg.height=iconParams[2]||16;
								entryIconImg.alt='';
								entryIcon.appendChild(entryIconImg);
					}
		
		entryTableTr.appendChild(entryIcon);
				
						var entryLabel=document.createElement("td");
								entryLabel.className="label";
								entryLabel.innerHTML=argsEntry.label;
								entryTableTr.appendChild(entryLabel);
								entryTableTBody.appendChild(entryTableTr);
								entryTable.appendChild(entryTableTBody);
								entryInner.appendChild(entryTable);
								entry.appendChild(entryInner);

		
		menuInner.appendChild(entry);

if(i<this.length-1){
	
	var entrySep=document.createElement("div");
			entrySep.className="sep";
			menuInner.appendChild(entrySep);
			
}

i++;

}.bind(list));

if(argsMenu.closebutton){
	
	var entrySep=document.createElement("div");
			entrySep.className="sep";
	
	menuInner.appendChild(entrySep);
	
	var closeButton=document.createElement("div");
			closeButton.className="close";
			closeButton.onclick=function(){
				
				hideMenu(this);
			
			}.bind(menu);
			
	var closeSpan=document.createElement("span");
	var closeText=document.createTextNode(popuptext['close']);
	
	closeSpan.appendChild(closeText);
	closeButton.appendChild(closeSpan);
	
	menuInner.appendChild(closeButton);
	closeButton.style.zIndex=999;
	
}


menu._arguments=argsMenu;


Element.hide(menu);
$(argsMenu.container).appendChild(menu);

if(typeof argsMenu.height=='number' && argsMenu.overflow){
	
	if(Element.getDimensions(menu).height > argsMenu.height){
		menuInner.style.height=argsMenu.height;
		menuInner.style.overflow='auto';
	}

}

}

function toggleMenu(menu,options){

if(typeof(options)=='undefined'){
	options={};
}

options.duration=0.3;
	Effect.toggle(menu,(window.opera?'blind':'appear'),options);

}

function hideMenu(menu,options){

if(typeof(options)=='undefined'){options={};}

options.duration=0.3;if(!window.opera){func=Effect.Fade;}else{func=Effect.BlindUp;}
func(menu,options);

}