var anMenu = 180 //<-- anchura del menú
var totalMen = 9 //<-- total de botones principales
var imaflecha = 'url(http://cadenasdevaloryppp.org/modules/gui/templates/gtz/images/menu_arrow_white.gif)'  //<-- ruta de la imagen de flecha
function tunMen(tex,enl,dest,subOp,an){
this.tex = tex;
this.enl = enl;
this.dest = dest;
this.subOp = subOp;
this.an = an;
}
/* Configurar las opciones aquí */
Op_0 = new tunMen('Inicio','/?page=Inicio',null,0,150)
Op_1 = new tunMen('¿Quienes Somos?',null,null,4,150)
	Op_1_0 = new tunMen('Usuarios','/?page=Clientes',null,0,150)
	Op_1_1 = new tunMen('Plan de Trabajo','/?page=Plan',null,0,150)
	Op_1_2 = new tunMen('Oferta de Servicios','/?page=Oferta',null,0,150)
	Op_1_3 = new tunMen('Folleto ERC','/files/otros/FolletoERC.pdf',null,0,150)
	Op_2 = new tunMen('Cadenas de Valor',null,null,5,200)
        Op_2_0 = new tunMen('Manual Value Links','/?page=Manual_Value_Links',null,0,200)
				Op_2_1 = new tunMen('Manual Value Links (Portugues)','/?page=Manual_Value_Links_Pgs',null,0,200)
				Op_2_2 = new tunMen('Manual Value Links - Género','/?page=Manual_Value_Links_Genero',null,0,200)
        Op_2_3 = new tunMen('Capacitación Modelo','/?page=Capacitacion_Modelo',null,0,200)
        Op_2_4 = new tunMen('Caja de Herramientas','/?page=Caja_de_Herramientas',null,0,200)
Op_3 = new tunMen('Proyectos Públicos Privados-PPP','/?page=Proyectos_Publicos',null,0,200)
Op_4 = new tunMen('Biocomercio','/?page=Iniciativa_Biocomercio',null,0,150)
//Op_5 = new tunMen('Foros de Discusión','/?page=Foro',null,0,150)
Op_5 = new tunMen('Documentos','/?page=Documentos',null,0,150)
Op_6 = new tunMen('Eventos y Capacitaciones','/?page=Eventos_y_Capacitacion',null,0,150)
Op_7 = new tunMen('Boletines','/?page=Boletines',null,0,150)
Op_8 = new tunMen('Links','/?page=Enlaces',null,0,150)
/* Fin de configuración.
   No tocar a partir de aquí */
var tunIex=navigator.appName=="Microsoft Internet Explorer"?true:false;
if(tunIex && navigator.userAgent.indexOf('Opera')>=0){tunIex = false}
var Opera = navigator.userAgent.indexOf('Opera')>=0 ? true : false;
var manita = tunIex ? 'hand' : 'pointer'
var subOps = new Array()
function construye(){
cajaMenu = document.createElement('ul')
cajaMenu.style.width = anMenu + "px"
cajaMenu.style.zIndex = 1
cajaMenu.style.marginLeft = 0
cajaMenu.style.paddingLeft = 0
document.getElementById('me').appendChild(cajaMenu)
for(m=0; m < totalMen; m++){
	opchon = eval('Op_'+m)
	boton = document.createElement('li')
	boton.style.marginLeft = 0
	boton.style.paddingLef = 0
	boton.style.listStyleType = 'none'
	boton.style.position = 'relative'
	boton.style.zIndex = (100 - m)
	boton.className = 'botones'
	boton.style.cursor = manita
	boton.id = 'op_' + m
	if(opchon.enl){
		lin = document.createElement('a')
		lin.className = 'enlacesmenu'
		lin.href = opchon.enl
		if(opchon.dest){
			lin.target = opchon.dest
		}
	boton.appendChild(lin)
	lin.appendChild(document.createTextNode(opchon.tex))
	}
	else{
		boton.appendChild(document.createTextNode(opchon.tex))
	}
	boton.onmouseover = function(){
		mostrar(this)
		}
	boton.onmouseout=function(){
		ocultar(this)
		}
	cajaMenu.appendChild(boton)
	if(opchon.subOp > 0 ){
		espan = document.createElement('span')
		espan.style.position = 'absolute'
		espan.style.right = 0
		boton.style.backgroundImage = imaflecha
		boton.style.backgroundPosition = 'center right'
		boton.style.backgroundRepeat = 'no-repeat'
		espan.className = 'espan'
		boton.appendChild(espan)
		subOps[subOps.length] = boton.id.replace(/o/,"O")
		}
	}
if(subOps.length >0){subMes()}
}
function subMes(){
lar = subOps.length
for(t=0;t<subOps.length;t++){
	opc =eval(subOps[t])
	for(v=0;v<opc.subOp;v++){
		if(eval(subOps[t] + "_" + v + ".subOp") >0){
			subOps[subOps.length] = subOps[t] + "_" + v
			}
		}
	}
construyeSub()
}
function construyeSub(){
for(y=0; y<subOps.length;y++){
opchon = eval(subOps[y])
capa = document.createElement('ul')
capa.className = 'subMe'
capa.style.width = opchon.an + "px"
capa.style.visibility = 'hidden'
capa.style.position = 'absolute'
capa.style.marginLeft = 0
capa.style.paddingLeft = 0
document.getElementById(subOps[y].toLowerCase()).firstChild.nextSibling.appendChild(capa)
	for(s=0;s < opchon.subOp; s++){
		sopchon = eval(subOps[y] + "_" + s)
		opc = document.createElement('li')
		opc.style.marginLeft = 0
		opc.style.paddingLeft = 0
		opc.style.listStyleType = 'none'
		opc.className = 'botones'
		opc.id = subOps[y].toLowerCase() + "_" + s
		if(sopchon.enl){
			lin = document.createElement('a')
			lin.className = 'enlacesmenu'
			lin.href = sopchon.enl
			if(sopchon.dest){
				lin.target = sopchon.dest
			}
		opc.appendChild(lin)
		lin.appendChild(document.createTextNode(sopchon.tex))
		}
		else{
			opc.appendChild(document.createTextNode(sopchon.tex))
		}
		capa.appendChild(opc)
		opc.style.cursor = manita
		opc.onmouseover = function(){
			mostrar(this)
			}
		opc.onmouseout=function(){
			ocultar(this)
			}
		if(sopchon.subOp > 0 ){
			espan = document.createElement('span')
			espan.style.position = 'absolute'
			espan.style.right = 0
			opc.style.backgroundImage = imaflecha
			opc.style.backgroundPosition = 'center right'
			opc.style.backgroundRepeat = 'no-repeat'
			espan.className = 'espan'
			opc.appendChild(espan)
			}
		}
	}
}
function mostrar(cual){
if(Opera || (document.styleSheets.length > 0 && !document.styleSheets[0].disabled)){
	if(tunIex){cual.className = 'botonesHover'}
	if(cual.childNodes.length > 1){
		cual.firstChild.nextSibling.firstChild.style.visibility = 'visible'
		}
	}
}
function ocultar(cual){
	if(Opera || (document.styleSheets.length > 0 && !document.styleSheets[0].disabled)){
	if(tunIex){cual.className = 'botones'}
		if(cual.childNodes.length > 1){
		cual.firstChild.nextSibling.firstChild.style.visibility = 'hidden'
		}
	}
}
function enlace(cual){
enla = eval('O' + cual.substr(1)).enl
targ = eval('O' + cual.substr(1)).dest
if(targ && targ.toLowerCase() == '_blank'){
	window.open(enla,'','')
	}
else{
	location.href = enla
	}

}
onload = construye
