//                                          _                 _                   _     _      
//__   _____ _ __ ___   ___ _ __  _   _  __| | ___  ___ _ __ | | ___  __ _  __ _ | |__ | | ___ 
//\ \ / / __| '_ ` _ \ / _ \ '_ \| | | |/ _` |/ _ \/ __| '_ \| |/ _ \/ _` |/ _` || '_ \| |/ _ \
// \ V / (__| | | | | |  __/ | | | |_| | (_| |  __/\__ \ |_) | |  __/ (_| | (_| || |_) | |  __/
//  \_/ \___|_| |_| |_|\___|_| |_|\__,_|\__,_|\___||___/ .__/|_|\___|\__, |\__,_||_.__/|_|\___|
//                                                     |_|           |___/   v1.0 
//Una librería de alberto viñuela - voet cranf - http://voet.cranf.net - septiembre 2006
//prohibido su empleo comercial - aficionados e iniciativas no lucrativas usadlo libremente
//las empresas NO pueden vender o usar esta librería
//compatible con explorer 5.5+ y firefox 1.0+

var VCMimagen="iconos/menuboton.gif"; //gráfico que dispara la aparición del menú
var VCMtitular; //de uso opcional, una vez definido puede usarse como título de la página actual

//EJEMPLO DE CONSTRUCCIÓN DEL ÁRBOL DE MENÚ
/*
menuprincipal=new VCMmenuItem('','');
menu11=new VCMmenuItem("presentación","inic.html");
menu12=new VCMmenuItem("geografía","");
	menu12_1=new VCMmenuItem("localización y mapas","geog.html");
	menu12_2=new VCMmenuItem("los montes del valle de buiza","mont.html");
menuprincipal.ad(menu11,menu12);
	menu12.ad(menu12_1,menu12_2);
*/

//           _   _ _           
//  ___  ___| |_(_) | ___  ___ 
// / _ \/ __| __| | |/ _ \/ __|
//|  __/\__ \ |_| | | (_) \__ \
// \___||___/\__|_|_|\___/|___/
document.write('<style>');
document.write('.vcmcol_table {padding:0px;margin:0px;}');

//estilos de texto
document.write('.vcmcol_td,.vcmcol_tdurl {vertical-align:top;padding:0px;margin:0px;border:0px;font-family:verdana;font-size:10px;cursor:default;}'); //sin url
document.write('.vcmcol_tdurl {cursor:pointer;cursor:hand;}'); // en caso de url

//estilos de los menuitems
document.write('.vcmcol_div,.vcmcol_divup,.vcmcol_divurl {vertical-align:top;display:block;margin:1px;padding:0px;padding-left:6px;padding-right:6px;padding-bottom:3px;font-family:verdana; font-size:10px;line-height:11px;background-color:#E6EADB;}'); //menuitem con url
document.write('.vcmcol_div {background-color:#CFD2C5;}'); //menuitem sin url
document.write('.vcmcol_divup {background-color:#EAE726}'); //menuitem con url con raton
//estilos del fondo del menú
document.write('.vcmfondo, .vcmfondo2{position:absolute;border:0px;padding-right:4px;padding-top:4px;}');//comunes
document.write('.vcmfondo{z-index:9000;background-color:#727240;filter: alpha(opacity=80);-moz-opacity:0.8; opacity:0.8;}');//fondo transparente
document.write('.vcmfondo2{z-index:9001}');//contenedor
document.write('</style>');

//                  __ _           
//  __ _ _ __ __ _ / _(_) ___ ___  
// / _` | '__/ _` | |_| |/ __/ _ \ 
//| (_| | | | (_| |  _| | (_| (_) |
// \__, |_|  \__,_|_| |_|\___\___/ 
// |___/ 
// coloca el gráfico que dispara el menú: debe ser llamado desde el HTML
function VCMcuadromenu()
{
return menuprincipal.muestraLlavesColumnas()+'<img src="'+VCMimagen+'" id=VCMgraficomenu border=0 onmouseover="document.getElementById(&quot;VCMmenu&quot;).style.display=&quot;&quot;;document.getElementById(&quot;VCMmenu2&quot;).style.display=&quot;&quot;" >';
}

//                 _             
// _ __ ___   ___ | |_ ___  _ __ 
//| '_ ` _ \ / _ \| __/ _ \| '__|
//| | | | | | (_) | || (_) | |   
//|_| |_| |_|\___/ \__\___/|_|   
//***************
function VCMmenuAd() {for(q=0;q<arguments.length;q++) this.colgantes.push(arguments[q])}

//***************
function VCMsalta(q) {location.href=q}

//***************
function VCMbloquellaves()
{
qmenu=this.llavesrec(1,this.profundidad(),0);
q='<div class=vcmfondo style="display:none;" id="VCMmenu"><table class=vcmcol_table cellspacing=0><tr>'+qmenu+'</table></div>';
q+='<div class=vcmfondo2 style="display:none;" id="VCMmenu2"><table class=vcmcol_table cellspacing=0><tr>'+qmenu+'</table></div>';
return q;
}

//***************
function VCMbloqueprofundidad(prof)
{
if(prof==null) var prof=1;

var i;
var maxprof=0;
var c=this.colgantes.length;
if(c>0)
	{
	prof+=1;
	for(i=0;i<c;i++)
		if(this.colgantes[i].profundidad(prof)>maxprof)
			maxprof=this.colgantes[i].profundidad(prof);
	if(maxprof>0) prof=maxprof;
	}
return prof;
}

//***************
function VCMbloquedivisiones(l)
{
if(!l) {l=1};
var i;
var c=this.colgantes.length;
if(c>0) l+=c-1;
	for(i=0;i<c;i++)
		l=this.colgantes[i].divisiones(l);
return l;
}

//***************
function VCMbloquellavesrec(nivel,ancho,posicion)
{
var i;
var c=this.colgantes.length;
var cols=ancho-nivel+1;
var cp="";
if(c==0)
	if(cols>0) cp="colspan="+(cols*2-1);

var conurl=(this.url!=""?true:false);
if(conurl&&location.href.indexOf(this.url)!=-1)	VCMtitular=this.texto;
var paginactual=(location.href.indexOf(this.url)!=-1 && conurl?true:false);

var q="<td nowrap "+(conurl&&!paginactual? "class=vcmcol_tdurl onmouseover='this.firstChild.className=&quot;vcmcol_divup&quot;'  onmouseout='this.firstChild.className=&quot;vcmcol_divurl&quot;'onclick=VCMsalta('"+this.url+"')":"class=vcmcol_td" )+" height=100% rowspan="+this.divisiones()+" "+cp+" style='padding-bottom:"+posicion+"px'>"+(this.texto!=null?"<div "+(conurl?"class=vcmcol_divurl":"class=vcmcol_div")+" >"+(paginactual?"<b>":"")+this.texto+(paginactual?"</b>":"")+"</div>":"")+"</td>";


if(c>0)
	{
	q+='<td class=vcmcol_td rowspan='+this.divisiones()+' height=100%><table class=vcmtable cellspacing=0 height=100%>'+(c>1?'<tr><td class=vcmcol_td style="vertical-align:bottom" ><img src="vcmimage/vcmcresta.gif"></td></tr>':'')+'<tr><td class=vcmcol_td height=100% '+(c>1?'style="background-image:url(vcmimage/vcmlinea.gif)"':'')+'><img src="vcmimage/vcmpico.gif"></td></tr>'+(c>1?'<tr><td class=vcmcol_td style="vertical-align:top"><img src="vcmimage/vcmrabo.gif"></td></tr>':'')+'<tr><td class=vcmtab><img src="vcmimage/spacer.gif" width=4 height=4></td></tr></table></td>';
		for(i=0;i<c;i++) 
		{
		q+=(i>0?"<tr height=100%>":"")
		q+=this.colgantes[i].llavesrec(nivel+1,ancho,(i==c-1?5:0));
		}
	}
	else q+="</tr>";
return q;
}

//***************
function VCMquitadiv(e)
{
if(!document.getElementById("VCMmenu")) return;
if(document.getElementById("VCMmenu").style.display=="none") return;
var elemento;
if(document.all) elemento=event.srcElement;	else elemento=e.target;

sobremenu=false;
if(elemento.id=="VCMmenu2" || elemento.id=="VCMgraficomenu") sobremenu=true;
while(elemento.parentNode)
	{
	elemento=elemento.parentNode;
	if(elemento.id=="VCMmenu2") sobremenu=true;
	}
if(!sobremenu) {document.getElementById("VCMmenu").style.display="none";
				document.getElementById("VCMmenu2").style.display="none";}
}

//**************CONSTRUCTOR del menuitem
function VCMmenuItem(texto,url)
{
//atributos
	this.texto=texto;
	this.url=url;
	this.colgantes=new Array();

//atributos globales
	itemNumero=0;

//métodos públicos
	this.ad=VCMmenuAd; //añade a la jerarquía
	this.muestraLlavesColumnas=VCMbloquellaves; //devuelve HTML del árbol
//métodos privados
	this.divisiones=VCMbloquedivisiones;
	this.llavesrec=VCMbloquellavesrec;
	this.profundidad=VCMbloqueprofundidad;
}

//                      _            
//  _____   _____ _ __ | |_ ___  ___ 
// / _ \ \ / / _ \ '_ \| __/ _ \/ __|
//|  __/\ V /  __/ | | | || (_) \__ \
// \___| \_/ \___|_| |_|\__\___/|___/

if (!document.all)
{document.addEventListener('mousemove', VCMquitadiv, false);}
else
{document.attachEvent('onmousemove', VCMquitadiv);}
