btnCss="itemTemplate01";
vertOffset=9;
horOffset=180;
btnCss="itemTemplate01";
btnCssHover="itemTemplate01Hover";

function mOutTimerStart(){
	var ref=this;
	globalTimer=setTimeout(function(){ref.className=btnCss;},50);
}
function mOut(){
	this.className=btnCss;
}
function mOver(){
	clearTimeout(globalTimer);
	var todoLoDeMas=Array('sec0','sec1','sec2','sec3','sec4','sec5');
	var t;
	for(i=0;i<todoLoDeMas.length;i++){
		t=dg(todoLoDeMas[i]);
		if(t.className!=btnCss){
			t.className=btnCss;
		}
	}
	this.className=btnCssHover;
	this.style.zIndex=99;
}
function mOverSection(){
	
}
function nBtnFunc(b,i){
		if(!this.target){
			alert("Target del menu sin definir");
		}else{
			var btn=this.ce("DIV");
			btn.id="sec"+i;
			btn.name="secciones";
			btn.className="itemTemplate01";
			btn.onmouseover=mOver;
			btn.onmouseout=mOutTimerStart;
			btn.innerHTML=b[0];
			if(b[1].isArray()){
					var sb=b[1];
					var subSec=this.ce("DIV");
					subSec.name="subSecciones";
					subSec.mouseover=mOverSection;
					subSec.style.position="relative";
					subSec.style.left="0px";
					subSec.style.marginTop=vertOffset+"px";
					subSec.id=btn.id+"sub";
					for(si=0;si<sb.length;si++){
						subSec.appendChild(this.nBtn(sb[si],i));
					}
					btn.appendChild(subSec);
					btn.onclick=function(){
						//alert(btn.id);
					}
				}else{
					btn.onclick=function(){
						document.location.href=b[1];
					}
				}
			return btn;
		}
	}

function MenuEngine(n){
	this.name=n;
	this.layOut=null;
	this.html="";
	this.dg=function(a){return document.getElementById(a);}
	this.ce=function(a){return document.createElement(a);}
	this.target;
	this.setTarget=function(t){
		this.target=this.dg(t);
	}
	this.nBtn=nBtnFunc;
	this.init=function(lo){
		this.layOut=lo;
		for(i=0;i<this.layOut.length;i++){
			this.target.appendChild(this.nBtn(this.layOut[i],i));
		}
	}
}