/**************************************************************
Menú desplegable vertical. Script creado por Tunait! (4/jun/2006)
Script de libre uso siempre y cuando se mantengan las correspondientes líneas de créditos de autor.
Distribución no autorizada sin previo permiso.
http://javascript.tunait.com/
tunait@yahoo.com 
****************************************************************/


var anMenu = 189 //<-- anchura del menú
var totalMen = 10 //<-- total de botones principales
var imaflecha = 'url(flechitaazul.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','index.html',null,0,200)
Op_1 = new tunMen('Dirección del Departamento','direccion/direccion.html',null,0,200)
Op_2 = new tunMen('Miembros del Departamento','miembros/miembros.html',null,0,200)


Op_3 = new tunMen('Docencia',null,null,6,200)
	Op_3_0 = new tunMen('Grado',null,null,5,200)
		Op_3_0_0 = new tunMen('Grado en Óptica y Optometría','http://grados.ugr.es/optica/',null,0,100)
		Op_3_0_1 = new tunMen('Grado en Física','http://grados.ugr.es/fisica/',null,0,100)
		Op_3_0_2 = new tunMen('Grado en Química','http://grados.ugr.es/quimica/',null,0,100)
		Op_3_0_3 = new tunMen('Grado en Ingeniería Química','http://grados.ugr.es/iquimica/',null,0,100)
		Op_3_0_4 = new tunMen('Grado en Ingeniería de Tecnologías de Telecomunicación','http://grados.ugr.es/telecomunicacion/',null,0,100)
	Op_3_1 = new tunMen('Primer y Segundo Ciclo',null,null,6,200)
		Op_3_1_0 = new tunMen('Licenciado en Física','http://www.ugr.es/~geoptica/docencia/licFis.html',null,0,100)
		Op_3_1_1 = new tunMen('Diplomado en Óptica y Optometría','http://www.ugr.es/~geoptica/docencia/dipOpt.html',null,0,100)
		Op_3_1_2 = new tunMen('Ingeniero Electrónico','http://www.ugr.es/~geoptica/docencia/ingElect.html',null,0,100)
		Op_3_1_3 = new tunMen('Ingeniero Químico','http://www.ugr.es/~geoptica/docencia/ingQuim.html',null,0,100)
		Op_3_1_4 = new tunMen('Ingeniero de Telecomunicaciones','http://www.ugr.es/~geoptica/docencia/ingTel.html',null,0,100)
		Op_3_1_5 = new tunMen('Libre Configuracion Específica','http://www.ugr.es/~geoptica/docencia/lce.html',null,0,100)
	Op_3_2 = new tunMen('Postgrado',null,null,1,100)
		Op_3_2_0 = new tunMen('Másteres','docencia/masteres.html',null,0,100)
	
	Op_3_3 = new tunMen('Otros Cursos','docencia/otrosCursos.html',null,0,100)
	Op_3_4 = new tunMen('Innovación Docente','docencia/innovacion.html',null,0,100)
	Op_3_5 = new tunMen('Organización Docente','docencia/orgDocente.html',null,0,100)
	

Op_4 = new tunMen('Investigación',null,null,5,200)
	Op_4_0 = new tunMen('Grupo y laboratorios de investigación','investigacion/grupos.html',null,0,150)
	Op_4_1 = new tunMen('Líneas de investigación','investigacion/lineas.html',null,0,100)
	Op_4_2 = new tunMen('Servicios y tecnologías ofertadas a empresas y entidades','investigacion/servicios.html',null,0,100)
	Op_4_3 = new tunMen('Áreas UNESCO','investigacion/areas.html',null,0,100)
	Op_4_4 = new tunMen('Tesis doctorales','investigacion/tesis.html',null,0,100)

Op_5 = new tunMen('Contrato Programa',null,null,3,200)
	Op_5_0 = new tunMen('Contrato Programa 2009','http://www.ugr.es/~geoptica/contratoprograma/contrato.html',null,0,100)
	Op_5_1 = new tunMen('Contrato Programa 2010','http://www.ugr.es/~geoptica/contratoprograma10/contrato10.html',null,0,100)
	Op_5_2 = new tunMen('Contrato Programa 2011','http://www.ugr.es/~geoptica/contratoprograma11/contrato11.html',null,0,100)

Op_6 = new tunMen('Guías Docentes',null,null,3,200)
	Op_6_0 = new tunMen('Curso 2009-10','http://www.ugr.es/~geoptica/guiasdocentes/guias_docentes_asignaturas.htm',null,0,100)
	Op_6_1 = new tunMen('Curso 2010-11','http://www.ugr.es/~geoptica/guiasdocentes10/guias_docentes_asignaturas10.htm',null,0,100)
	Op_6_2 = new tunMen('Curso 2011-12','http://www.ugr.es/~geoptica/guiasdocentes11/guias_docentes_asignaturas11.htm',null,0,100)

Op_7 = new tunMen('Atención al Usuario','http://www.ugr.es/~geoptica/contratoprograma/cp_documentos/CP_DOUGR_OC2_quejas_sugerencias.htm',null,0,100)
Op_8 = new tunMen('Enlaces de Interés','enlaces/enlaces.html',null,0,100)
Op_9 = new tunMen('Acceso Restringido','acceso.html',null,0,100)






/* 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 = 15
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
