wSH = screen.height/1024; //proporción
var Cph=15; //cons: paso de pixel horizontal
Cpv=30; //cons: paso de pixel vertical
var Ctime=2; //cons: intervalo de tiempo
var CW=parseInt(1200*wSH); //cons: frame ancho
var CH=parseInt(700*wSH); //cons: frame alto
var CMH=parseInt(22*wSH); //cons: margen horiz. capa texto
var CWM=parseInt(210*wSH); //cons: menu ancho
var CWT=parseInt(CW-CMH-CWM); //cons: capa texto ancho visible
var CHT=parseInt(460*wSH); //cons: capa texto alto visible
var CTT=parseInt(160*wSH); //cons: capa texto top
var CBT=parseInt(CH-CHT-CTT); //cons: capa texto bottom
var CWTC=parseInt(400*wSH); //cons: col.txt ancho
var CMVTC=parseInt(30*wSH); //cons: col.txt margen vert.
var CMHTC=parseInt(35*wSH); //cons: col.txt margen horiz.
var CHTC=parseInt(CHT-(CMVTC*2)); //cons: col.txt alto
var CWLM=parseInt(103*wSH); //cons: logo menu ancho
var CHLM=parseInt(116*wSH); //cons: logo menu alto
var CWSCR=parseInt(20*wSH); //cons: col.scroll ancho
var CHSCR=parseInt(10*wSH);//const:  img.scrollbar alto
var CWSCRT=parseInt(10*wSH); //cons: tilde scrollbar ancho
var CHSCRT=parseInt(32*wSH); //cons: tilde scrollbar alto
var CWE=parseInt(35*wSH);//cons: ancho escudos
var CHE=parseInt(56*wSH);//cons: alto escudos

var Ain = new Array(); //array: punteros de setInterval
var Aid = new Array(); //array: capas que se pliegan
var AcoordF = CTT+CHT; //array: coordenadas finales
var AcoordA = new Array(); //array: coordenadas actuales

var AopcI = new Array(); //array:num de opc
var AopcF = new Array(); //array:flecha de opc
var AopcA = new Array(); //array:<a> de opc
var AopcP = new Array(); //array:persiana desplegada

var Ao = new Array(); //array: opciones de menú
var Amin = "vacio"; //array: punteros de setInterval para menus
var Am = new Array(); //array: menús
var Ama = new Array(); //array: indicativo menús abierto
var AmcoordF = 0; //array: coordenadas finales
var AmcoordA = 0; //array: coordenadas actales

var Ahist = new Array(40);//array: hist.
var histP = -1;//puntero hist.
//var histI = 0;//inserción hist.
var histL = -1;//últ.elem.hist.

var wPinchado=false;
var wDesplegado=false;
var wDesplegando=false;
var wPlegandoTexto=false;
var wItemAnt=""; //item seleccionado anterior
var wItemSel=""; //item seleccionado
var wSubopSel="";
var wInScroll=null; // puntero de SetInterval para scroll
var wImgPath="../images/";
var elFrame;
var elMenu;
var X=0;
var Y=0;

var wTam;
if (screen.width>1024) wTam="1280";
else if (screen.width>800) wTam="1024";
else wTam="800";

function onload_() {
	var oTag;
	var oElem,oElem2;
	elFrame = document.getElementById("c_frame");
	elMenu = document.getElementById("c_menu");
	absOb(elFrame);
	dim(elFrame,CW,CH);
	absOb(elMenu);
	oTag = elMenu.getElementsByTagName("p");
	for (var i=0;i<oTag.length;i++){
		oElem = oTag[i];
		var vId = oElem.getAttribute("id");
		oElem.style.display= (vId.length==3) ? "block":"none";
	}
	dim(elMenu,CWM,CHT+CTT);
	elMenu.style.left=0;
	elMenu.style.top=CTT+"px";
	oElem = document.getElementById("c_fondo");
	absOb(oElem);
	dim(oElem,CW,CH);
	oElem = document.getElementById("c_imgfondo");
	absOb(oElem);
	dim(oElem,CW,CH);
	oElem=document.getElementById("imgfondo");
	oElem.src=wImgPath+"fondo.jpg";
	dim(oElem,CW,CH);
	oElem = document.getElementById("c_fondosup");
	absOb(oElem);
	dim(oElem,CWM+CWT-CMHTC,CTT);
	oElem.style.left=CMHTC+"px";
	oElem.getElementsByTagName("img")[0].style.width=CWLM+"px";
	oElem.getElementsByTagName("img")[1].style.width=parseInt(CHLM*602/396)+"px";
	oElem.getElementsByTagName("img")[0].style.height=oElem.getElementsByTagName("img")[1].style.height= CHLM+"px";
	oElem = document.getElementById("c_fondoinf");
	oElem.style.position="absolute";
	absOb(oElem);
	dim(oElem,CW-CWM-CMH,CBT);
	oElem.style.left=CWM+"px";
	oElem.style.top=parseInt(CH-CBT)+"px";
	oElem.getElementsByTagName("img")[2].style.width = parseInt(235*wSH)+"px";
	oElem.getElementsByTagName("img")[2].style.height = parseInt(55*wSH)+"px";
	oElem.getElementsByTagName("img")[3].style.width = parseInt(123*wSH)+"px";
	oElem.getElementsByTagName("img")[3].style.height = parseInt(62*wSH)+"px";
	oTag = elMenu.getElementsByTagName("p");
	for (var i=0;i<oTag.length;i++){
		oElem = oTag[i];
		var vId = oElem.getAttribute("id");
		oElem.style.marginRight = (vId.length-3)*15+"px";
		if (parseInt(vId.charAt(2))>4) oElem.style.fontSize ="13px";
		else oElem.style.fontSize = (17-vId.length)+"px"
		AopcI[i] = vId;
		AopcA[i] = oElem.getElementsByTagName("a")[0];
		if (document.getElementById(vId+"1")) {
			AopcF[i] = oElem.getElementsByTagName("a")[0];
		} else {
			AopcF[i]="";
		}
		AopcA[i].href = "javascript:pinchar('" + vId + "','');";
		AopcP[i]=false;
		var hMapa = document.getElementById("colI8").appendChild(document.createElement("h"+(vId.length-2)));
		var aMapa = hMapa.appendChild(document.createElement("a"));
		aMapa.innerHTML = AopcA[i].innerHTML;
		//aMapa.onclick = new Function("pinchar('" + vId + "','');");
		aMapa.href = "javascript:pinchar('" + vId + "','');";
	}

	var j=0;
	oTag = document.getElementById("c_textos").childNodes;
	for (var i=0;i<oTag.length;i++){
		oElem = oTag[i];
		if (oElem.className == "item") {
			absOb(oElem);
			j=Ain.length;
			Ain[j]="vacio";Aid[j]=oElem.getAttribute("id");
			dim(oElem,CW,CH);
			oElem.style.clip = "rect("+CTT+"px,"+(CWT+CWM)+"px,"+(CTT+CHT)+"px,"+CWM+"px)";
			var oElem2 = oElem.appendChild(document.createElement("img"));
			oElem2.src = wImgPath+"fondoc.jpg";
			dim(oElem2,CW,CH);
			cerrarTexto(j);
			oElem2 = document.getElementById("colI"+Aid[j].substring(2,Aid[j].length)) || null;
			if (oElem2 != null) {
				absOb(oElem2);
				dim(oElem2,CWTC,CHTC);
				pos(oElem2,CTT + CMVTC,CWM+CMHTC);
			}
			oElem2 = document.getElementById("colD"+Aid[j].substring(2,Aid[j].length)) || null;
			if (oElem2 != null) {
				absOb(oElem2);
				dim(oElem2,CWTC,CHTC);
				pos(oElem2,CTT + CMVTC,(CMHTC*2)+CWM+CWTC+CWSCR);
			}
		}
	}
	for (var i=0;i<40;i++) Ahist[i]="";
	oElem=document.getElementById("imgHistAtras");
	oElem.style.width = oElem.style.height = (CWLM*0.4)+"px";
	oElem.onclick=histAtras;
	oElem=document.getElementById("imgHistAdelante");
	oElem.style.width = oElem.style.height = (CWLM*0.4)+"px";
	oElem.onclick=histAdelante;
	centrar();
	window.onresize=centrar;
	document.getElementById("c_imgfondo").style.visibility="visible";
	elFrame.style.visibility="visible";
	document.getElementById("c_fondosup").style.visibility=document.getElementById("c_fondoinf").style.visibility="visible";
	for (var i=0;i<40;i++) Ahist[i]="";
	var vCol="D";
	while (vCol != "") {
		var vId="scroll"+vCol;
		oElem=document.getElementById(vId);
		absOb(oElem);
		//oElem.style.visibility = "hidden";
		dim(oElem,CWSCR,CHTC);
		if (vId.charAt(6)=="I") {
			pos(oElem,CTT + CMVTC,CWM+(CMHTC*1.5)+CWTC);
		} else {
			pos(oElem,CTT + CMVTC,CWM+(CMHTC*2.5)+(CWTC*2)+CWSCR+10);
		}
		var oElem2 = document.getElementById("barra"+vId);
		absOb(oElem2);
		oElem2.style.top = CHSCR + "px";
		dim(oElem2,CWSCR,CHTC - (CHSCR*2));
		document.getElementById("tilde"+vId).style.position = "relative";
		document.getElementById("tilde"+vId).style.left = parseInt((CWSCR - CWSCRT)/2) +"px";
		dim(document.getElementById("imgtilde"+vId),CWSCRT,CHSCRT);
		oElem2.onclick = scrollP;
		var vDir = "up";
		while (vDir != "") {
			document.getElementById("img"+vDir+vId).style.width = parseInt(CWSCR)+"px";
			document.getElementById("img"+vDir+vId).style.height= parseInt(CHSCR)+"px";
			oElem2 = document.getElementById(vDir+vId);
			absOb(oElem2);
			dim(oElem2,CWSCR,CHSCR);
			oElem2.style.left = "0px";
			if (vDir == "up") oElem2.style.top = "0px";
			else oElem2.style.top = (CHTC - CHSCR) + "px";
			oElem2.onmouseover = new Function("{scroll('"+ vId.charAt(6) + "','"+ vDir + "');}");
			oElem2.onmouseout = scrollOff;
			if (vDir == "up") vDir = "down"; else vDir = "";
		}
		if (vCol == "D") vCol = "I"; else vCol = "";
	}
	pinchar("_O0","");
	cargarEventosDia();
	setTimeout("onload2()",1);
}
function onload2() {
	var oElem; var oTag; var oElem2;
	j=0;
	var Afotos = new Array();
	Afotos[j++] = new Array("fpeana.jpg",380,538,"Cartel de Artes no Camiño");
	Afotos[j++] = new Array("ilogo.gif",120,140,"Artes no Camiño");
	Afotos[j++] = new Array("itit.gif",213,140,"Artes no Camiño");
	Afotos[j++] = new Array("iarsactus.gif",150,150,"ArsactuS");
	Afotos[j++] = new Array("ixacobeo.gif",300,164,"www.xacobeo.es");
	Afotos[j++] = new Array("ixuntain.gif",300,68,"http://www.xunta.es/consellerias");
	Afotos[j++] = new Array("isaludarte.gif",200,200,"saludarte");
	Afotos[j++] = new Array("ionce.gif",400,79,"FUNDACIÓN ONCE");
	Afotos[j++] = new Array("farsc.jpg",400,283,"Ars Combinatoria");
	Afotos[j++] = new Array("fcanc.jpg",176,268,"Canco López");
	Afotos[j++] = new Array("fentorno.jpg",400,268,"Sarria");
	Afotos[j++] = new Array("fcebr.jpg",300,193,"O Cebeiro");
	Afotos[j++] = new Array("fsamo.jpg",400,268,"Samos");
	Afotos[j++] = new Array("ftria.jpg",400,268,"Triacastela");
	Afotos[j++] = new Array("fsarr.jpg",400,319,"Sarria");
	Afotos[j++] = new Array("fparadela.jpg",172,268,"Paradela");
	Afotos[j++] = new Array("fportomarin.jpg",201,268,"Portomarín");
	Afotos[j++] = new Array("fmonterroso.jpg",179,268,"Monterroso");
	Afotos[j++] = new Array("ffonsagrada.jpg",201,268,"A Fonsagrada");
	Afotos[j++] = new Array("flugo.jpg",300,158,"Lugo");
	Afotos[j++] = new Array("ffoz.jpg",300,225,"Foz");
	Afotos[j++] = new Array("flourenza.jpg",225,184,"Lourenzá");
	Afotos[j++] = new Array("fmondonedo.jpg",300,214,"Mondoñedo");
	Afotos[j++] = new Array("fvilalba.jpg",290,290,"Vilalba");
	Afotos[j++] = new Array("fclau.jpg",232,300,"Claudio Astronio");
	Afotos[j++] = new Array("fjuan.jpg",144,200,"Juan Carlos Asensio");
	Afotos[j++] = new Array("fflauta.jpg",200,150,"");
	Afotos[j++] = new Array("fraul.jpg",223,291,"Raúl Prieto");
	Afotos[j++] = new Array("fruben.jpg",225,300,"Rubén Pérez");
	Afotos[j++] = new Array("fcharo.jpg",309,300,"Charo Pita");
	Afotos[j++] = new Array("fsego.jpg",225,215,"");
	Afotos[j++] = new Array("fbarbara.jpg",213,300,"Barbara Hendricks");
	Afotos[j++] = new Array("ffach.jpg",300,225,"Abadía de Samos");
	Afotos[j++] = new Array("f2006.jpg",300,200,"");
	Afotos[j++] = new Array("fcompaniay.jpg",198,268,"Compañía Y");
	Afotos[j++] = new Array("ftriomorelia.jpg",400,266,"Trío Morelia");
	Afotos[j++] = new Array("fondo.jpg",300,200,"");
	Afotos[j++] = new Array("fnenos.jpg",201,268,"");
	Afotos[j++] = new Array("fartistas.jpg",400,267,"");
	Afotos[j++] = new Array("fmielgo.jpg",200,268,"Pablo Mielgo");
	Afotos[j++] = new Array("fholger.jpg",400,258,"Holger Falk");
	Afotos[j++] = new Array("felena.jpg",300,225,"Elena Sancho");
	Afotos[j++] = new Array("fsabine.jpg",201,300,"Sabine Garrone");
	Afotos[j++] = new Array("falain.jpg",201,300,"Alain Damas");
	Afotos[j++] = new Array("fgbertagnolli.jpg",338,225,"Gemma Bertagnolli");
	Afotos[j++] = new Array("fanouschka.jpg",216,300,"Anouschka Lara");
	Afotos[j++] = new Array("fivan.jpg",198,300,"Iván García");
	Afotos[j++] = new Array("fgreg.jpg",300,225,"Curso de Canto Gregoriano 2006");
	Afotos[j++] = new Array("facad.jpg",300,225,"Academia bandArt");
	Afotos[j++] = new Array("fband.jpg",300,226,"bandArt");
	Afotos[j++] = new Array("feduc.jpg",400,301,"");
	Afotos[j++] = new Array("fnovaorq.jpg",400,300,"Nova Orquestra Galega das Artes");
	Afotos[j++] = new Array("fmocidade.jpg",400,267,"");
	Afotos[j++] = new Array("fgordan.jpg",400,267,"Gordan Nikolic");
	Afotos[j++] = new Array("flaura.jpg",196,300,"Laura F. Alcalde");
	Afotos[j++] = new Array("fartesendanza.jpg",400,273,"");
	Afotos[j++] = new Array("fartesnenos.jpg",400,300,"");
	Afotos[j++] = new Array("fgresi.jpg",400,262,"");
	Afotos[j++] = new Array("fcaricia.jpg",400,295,"A Caricia da Serpe");
	Afotos[j++] = new Array("fantonioortiz.jpg",191,300,"Antonio Ortiz");
	Afotos[j++] = new Array("fslide.jpg",400,303,"Slide Brass Quartet");
	Afotos[j++] = new Array("fanade.jpg",400,298,"Fundación Ánade");
	Afotos[j++] = new Array("ffartes.jpg",400,233,"");
	Afotos[j++] = new Array("fsocial.jpg",400,300,"");
	Afotos[j++] = new Array("fartistica.jpg",400,268,"");
	Afotos[j++] = new Array("flino.jpg",180,241,"Lino Braxe");
	Afotos[j++] = new Array("fmatute.jpg",196,288,"Águeda Matute");
	Afotos[j++] = new Array("felsa.jpg",276,320,"Elsa Ferrer");
	Afotos[j++] = new Array("famigo.jpg",137,300,"Carlos G. Amigo");
	Afotos[j++] = new Array("fjczahera.jpg",160,120,"Juan Carlos Zahera");
	Afotos[j++] = new Array("fpareja.jpg",400,267,"Parella aberta");
	Afotos[j++] = new Array("falexis.jpg",316,300,"Alexis Delgado");
	Afotos[j++] = new Array("ffortes.jpg",150,200,"Antón Fortes");
	Afotos[j++] = new Array("fluengo.jpg",400,259,"Francisco Luengo");
	Afotos[j++] = new Array("fcaminando.jpg",137,300,"Camiñando");
	Afotos[j++] = new Array("fteatronovo.jpg",400,247,"");
	Afotos[j++] = new Array("fsarabela.jpg",194,300,"Sarabela");
	Afotos[j++] = new Array("felenaglez.jpg",229,220,"Elena González");
	Afotos[j++] = new Array("festeve.jpg",139,184,"Esteve Ferrer");
	Afotos[j++] = new Array("fpazos.jpg",226,300,"Sergio Pazos");
	Afotos[j++] = new Array("fvilas.jpg",266,300,"Manuel Vilas");
	Afotos[j++] = new Array("fcoroleon.jpg",400,300,"Voces blancas Ciudad de León");
	Afotos[j++] = new Array("fconreal.jpg",400,300,"Los ConCiertos Reales");
	Afotos[j++] = new Array("falfonso.jpg",200,300,"Alfonso Morán");
	Afotos[j++] = new Array("fdacosta.jpg",300,227,"Fernando Dacosta");
	Afotos[j++] = new Array("fdavidq.jpg",179,280,"David Quiggle");
	oTag=document.getElementsByTagName("img");
	for(var i=0;i<oTag.length;i++){
		var oI=oTag[i];
		var o=oI.getAttribute("name") || "";
		if(!oI.src) oI.src=wImgPath+o;
		if (o!="") {
			if (o.indexOf("e_")==0) {
				oI.style.width=CWE+"px";
				oI.style.height=CHE+"px";
				oI.alt="escudo";
			} else for(var j=0;j<Afotos.length;j++){
				if(Afotos[j][0]==o){
					oI.style.width=(Afotos[j][1]*wSH)+"px";
					oI.style.height=(Afotos[j][2]*wSH)+"px";
					oI.alt=Afotos[j][3];
					break;
				}
			}
		}
	}
	oTag = document.getElementsByTagName("a");
	for (var i=0;i<oTag.length;i++){
		oElem = oTag[i];
		var vName = oElem.getAttribute("name") || "";
		vName=vName.substring(1,vName.length);
		if (vName.indexOf("bol")==0) {
			var vLink = vName;
			oElem.href= 'javascript:open("'+vName+'","","width='+(700*wSH)+',height='+(780*wSH)+',scrollbars=yes").focus();';
		} else if (vName!="") {
			if (vName.charAt(0) == "_")
				oElem.href="javascript:pinchar('_O"+vName.substring(1,vName.length)+"','');";
			else {
				oElem.href="javascript:pincharDentro('"+vName+"');";
			}
		}
	}
	oTag = document.getElementById("c_textos").getElementsByTagName("area");
	for (var i=0;i<oTag.length;i++){
		oElem = oTag[i];
		var vName = oElem.getAttribute("name") || "";
		if (vName!="") {
			oElem.onclick = new Function("{pinchar('_O"+vName+"','');}");
		}
	}
	if (location.href.indexOf("#_")!=-1){
		var opcUrl;
		Cph=Cpv=100;
		if (document.getElementById(opcUrl="_O"+location.href.substring(location.href.indexOf("#_")+2,location.href.length))) pinchar(opcUrl,'');
	}

}
//pinchar: muestra el item correspondiente
function pinchar (eId,subOp,h) {
	if (wPinchado) return;
	var nuevoId = eId.substring(2,eId.length);
	subOp = subOp || "";
	if (wItemSel == nuevoId) {
		if (subOp == wSubopSel) return;
		else if (subOp!="") {
			wSubopSel=subOp;
			pincharDentro(subOp,h);
		} else if (document.getElementById("TT"+nuevoId+"0")) {
			subOp="TT"+nuevoId+"0";
			pincharDentro(subOp,h);
		}
		return;
	}
	wPinchado=true;
	var actTT,antTT;
	if (wItemSel=="") antTT="";
	else if (document.getElementById("TT"+wItemSel)) antTT = wItemSel;
	else antTT="v";
	if (document.getElementById("TT"+nuevoId)) actTT=nuevoId;
	else actTT="v";
	wItemAnt=wItemSel;
	wItemSel=nuevoId;
 	//alert(subOp+":"+"TT"+nuevoId+"0");
	if (subOp==""&&document.getElementById("TT"+nuevoId+"0")) {
		subOp="TT"+nuevoId+"0";
		pincharDentro(subOp,h);
	}
	completar("TT"+actTT);
	if (wDesplegado) plegarYSwap("TT"+antTT,"TT"+actTT,subOp);
	else swapTexto("TT"+antTT,"TT"+actTT,subOp);
	for (var i=0;i<AopcI.length;i++){
		opcNum = AopcI[i].substring(2,AopcI[i].length);
		if (opcNum.length==1) {
				document.getElementById(AopcI[i]).style.display="block";//alert(AopcI[i]+" se muestra por 1");
		} else if (opcNum==actTT) {
				document.getElementById(AopcI[i]).style.display="block";//alert(AopcI[i]+" se muestra por S");
		} else if (opcNum.length<actTT.length && actTT.indexOf(opcNum)==0) {
				document.getElementById(AopcI[i]).style.display="block";//alert(AopcI[i]+" se muestra por p");
		} else if (opcNum.length==(actTT.length+1) && opcNum.indexOf(actTT)==0) {
				document.getElementById(AopcI[i]).style.display="block";//alert(AopcI[i]+" se muestra por hi");
		} else if (opcNum.length==actTT.length && (opcNum.substring(0,opcNum.length-1)==actTT.substring(0,actTT.length-1))) {
				document.getElementById(AopcI[i]).style.display="block";//alert(AopcI[i]+" se muestra por he "+ opcNum.substring(0,opcNum.lenght) +":"+ actTT.substring(0,actTT.lenght));
		} else if (opcNum.length==2&&opcNum.substring(0,1)==actTT.substring(0,1)) {
				document.getElementById(AopcI[i]).style.display="block";
		} else if (opcNum.length==3&&opcNum.substring(0,2)==actTT.substring(0,2)) {
				document.getElementById(AopcI[i]).style.display="block";
		} else if (opcNum.length==4&&opcNum.substring(0,3)==actTT.substring(0,3)) {
				document.getElementById(AopcI[i]).style.display="block";
		} else if (opcNum.length==5&&opcNum.substring(0,4)==actTT.substring(0,4)) {
				document.getElementById(AopcI[i]).style.display="block";
		} else if (opcNum.length==6&&opcNum.substring(0,5)==actTT.substring(0,5)) {
				document.getElementById(AopcI[i]).style.display="block";
		} else {
			document.getElementById(AopcI[i]).style.display="none";
		}
	}
	if (h!="hist") histIns(eId,subOp);
}
function completar(eId) {
	var oElem; var oTag; var oElem2;
	oTag=document.getElementById(eId).getElementsByTagName("span");
	for (var i=0;i<oTag.length;i++){
		oElem = oTag[i];
		var vId = oElem.getAttribute("id") || "";
		if (vId.charAt(0)=="_" && document.getElementById(vId.substring(1,vId.length))) {
			oElem.appendChild(document.getElementById(vId.substring(1,vId.length)));
		}
	}
}

function cargarEventosDia() {
	var fec = new Date();
	var hoyD = "0"+fec.getDate();
	hoyD = hoyD.substr(hoyD.length - 2,2); 
	var hoyM = "0"+(fec.getMonth()+1);
	hoyM = hoyM.substr(hoyM.length - 2,2);
	var oTag = document.getElementById("c_datos").getElementsByTagName("div");
	fec.setDate(fec.getDate()+1);
	var maD = "0"+fec.getDate();
	maD = maD.substr(maD.length - 2,2); 
	var maM = "0"+(fec.getMonth()+1);
	maM = maM.substr(maM.length - 2,2);
	var enco = false;
	for (var i=0;i<oTag.length;i++) {
		var oElem = oTag[i];
		var eId = oElem.getAttribute("id") || "";
		if (eId.indexOf("ev"+ hoyM + hoyD)==0 || eId.indexOf("ev"+ maM + maD)==0) {
			if (!enco) {
				enco = true;
				document.getElementById("colI0").innerHTML = "";
			}
			document.getElementById("colI0").appendChild(document.getElementById(eId));
		}
	}
}

function mostrarOpc() {
	for (var i=0;i<AopcI.length;i++){
		oElem=document.getElementById(AopcI[i]);
		var opcNum = oElem.getAttribute("id");
		opcNum = opcNum.substring(2,opcNum.length);
		var mostrar = false;var resaltar=false;
		if (opcNum.length < wItemSel.length) {
			if(wItemSel.indexOf(opcNum) == 0) {
				mostrar = true;
				resaltar=true;
			} else if(wItemSel.indexOf(opcNum.substring(0,opcNum.length-1))==0) mostrar = true;
		} else if (opcNum.length == (wItemSel.length + 1)  && (opcNum.indexOf(wItemSel) == 0)) mostrar = true;
		else if (opcNum == wItemSel) {
			mostrar = true;
			resaltar=true;
		} else if (opcNum.length == wItemSel.length && wItemSel.substring(0,wItemSel.length-1) == opcNum.substring(0,opcNum.length-1)) mostrar = true;
		if (mostrar) {
			oElem.style.display = "block";
			oElem.className = (resaltar)?"opcSel":"";
			if (AopcF[i]!="") {
				//AopcF[i].src = wImgPath+"imenu" + ((resaltar)?"ss":"nn" )+ ".gif";
				AopcP[i]=resaltar;
			} else AopcP[i]=false;
		} else {
			oElem.style.display = "none";
			AopcP[i]=false;
		}
	}
}
function histIns(eId,subOp) {
	if(eId=="_Ov")  return;
	var txtElem=eId+"&"+(subOp||"");
	var iins=-1;
	for (var i=0;i<histL;i++) {
		if (txtElem==Ahist[i]) {
			for (var j=i;j<histL;j++) {
				Ahist[j]=Ahist[j+1];
				if (histP>i) histP--;
				Ahist[histL--]="";
			}
		}
		break;
	}
	if (histP==39) {
		for(var i=0;i<39;i++) Ahist[i]=Ahist[i+1];
		Ahist[i]==txtElem;
	} else {
		Ahist[++histP]=txtElem;
		histL=histP;
	}
	if (document.getElementById("imgHistAdelante")) document.getElementById("imgHistAdelante").style.display="inline";
	if (document.getElementById("imgHistAtras")) document.getElementById("imgHistAtras").style.display="inline";
}
function histAtras() {
	if (wPinchado || wDesplegando){return;}
	if (histP>0) {
		histP--;
		pinchar(Ahist[histP].substring(0,Ahist[histP].indexOf("&")),Ahist[histP].substring(Ahist[histP].indexOf("&")+1,Ahist[histP].length),"hist");
	}
}
function histAdelante() {
	if (wPinchado || wDesplegando) return;
	if (histP<histL) {
		histP++;
		pinchar(Ahist[histP].substring(0,Ahist[histP].indexOf("&")),Ahist[histP].substring(Ahist[histP].indexOf("&")+1,Ahist[histP].length),"hist");
	}
}

function persiana(vId) {
	var opcSel = vId.substring(2,vId.length);
	for (var j=0;j<AopcI.length;j++){
		if (AopcI[j]==vId) break;
	}
	AopcP[j] = (!AopcP[j]);
	//var wImg = AopcF[j].src.substring(0,AopcF[j].src.lastIndexOf('.')-1);
	//wImg = wImg + ((AopcP[j])?"s":"n");
	//wImg = wImg + AopcF[j].src.substring(AopcF[j].src.lastIndexOf('.'),AopcF[j].src.length);
	//AopcF[j].src = wImg;
	for (var i=0;i<AopcI.length;i++){
		opcNum = AopcI[i].substring(2,AopcI[i].length);
		if (!AopcP[j]) {
			if (opcNum.length > opcSel.length && opcNum.indexOf(opcSel)==0) {
				document.getElementById(AopcI[i]).style.display="none";
			}
		} else {
			if (opcNum.length == (opcSel.length +1) && opcNum.indexOf(opcSel)==0) {
				document.getElementById(AopcI[i]).style.display="block";
				if (AopcF[i] != "") {
					//var wImg = AopcF[i].src.substring(0,AopcF[i].src.lastIndexOf('.')-1);
					//wImg = wImg + "n";
					//wImg = wImg + AopcF[i].src.substring(AopcF[i].src.lastIndexOf('.'),AopcF[i].src.length);
					//AopcF[i].src = wImg;
					AopcP[i] = false;
				}
			}
		}
	}
}
//plegar menu: pliega sucesivamente los menús correspondientes
function plegarMenu() {
	wDesplegando = true;
	Amin=setInterval("plegarMenu2()",Ctime);
}
function plegarMenu2() {
	if (AmcoordA - Cph < AmcoordF - CWM) {
		clearInterval(Amin);
		ocultarOb(elMenu);
		wDesplegando = false; wDesplegado=false;
	} else {
		AmcoordA=AmcoordA - Cph;
		posLeft(elMenu,AmcoordA);
	}
}

function plegarYSwap(antId,nuevoId,subOp) {
	wDesplegando = true;
	Amin=setInterval("plegarYSwap2('"+antId+"','"+nuevoId+"')",Ctime);
}
function plegarYSwap2(antId,nuevoId) {
	if (AmcoordA - Cph < AmcoordF - CWM) {
		clearInterval(Amin);
		//ocultarOb(elMenu);
		wDesplegando = false;  wDesplegado=false;
		swapTexto(antId,nuevoId);
	} else {
		AmcoordA=AmcoordA - Cph;
		//posLeft(elMenu,AmcoordA);
	}
}

//swap texto: sucesivamente, pliega el texto anterior, despliega el actual y pliega el menu
function swapTexto(antId,nuevoId,subOp) {
	var iAnt=-1; var iNuevo=-1;
	for (var i = 0;i < Aid.length;i++) {
		if(Aid[i] == nuevoId) iNuevo=i;
		else if(antId!="" && Aid[i] == antId) iAnt=i;
	}
	if (iNuevo==-1) {alert("error en la página:"+nuevoId);return;}
	wPlegandoTexto = (iAnt!=-1);
	if (iAnt==-1) {
		wPlegandoTexto=false;
		mostrar(nuevoId);
	} else
		wPlegandoTexto=true;
	Ain[iNuevo]=setInterval("swapTexto2('"+iAnt+"','"+iNuevo+"')",Ctime);
}

function swapTexto2(i,j) {
	if (wPlegandoTexto) {
		if (AcoordA[i]- Cpv > CTT) {
			AcoordA[i] = AcoordA[i]-Cpv;
			document.getElementById(Aid[i]).style.height = AcoordA[i] + "px";
		} else {
			wPlegandoTexto=false;
			cerrarTexto(i);
			mostrar(Aid[j]);
		}
	} else {
		if (AcoordA[j] + Cpv < (CTT+CHT)) {
			AcoordA[j] = AcoordA[j]+Cpv;
		} else {
			AcoordA[j] = CTT+CHT;
			clearInterval(Ain[j]);
			incorporarScroll(Aid[j],"I");
			incorporarScroll(Aid[j],"D");
			Ain[j] = "vacio";
			wPinchado=false;
		}
		document.getElementById(Aid[j]).style.height = AcoordA[j]+ "px";
	}
}

function cerrarTexto(i) {
	document.getElementById(Aid[i]).style.display = "none";
	AcoordA[i]=CTT;
	document.getElementById(Aid[i]).style.height= AcoordA[i] +"px";
}

function pincharDentro(eId,h) {
	if (document.getElementById("colD"+wItemSel)) {
		if (document.getElementById(eId)) {
			completar(eId);
			if (document.getElementById("colD"+wItemSel).getElementsByTagName("div")[0])
				document.getElementById("c_datos").appendChild(document.getElementById("colD"+wItemSel).getElementsByTagName("div")[0])
			document.getElementById("colD"+wItemSel).appendChild(document.getElementById(eId));
			//document.getElementById("colD"+wItemSel).innerHTML = document.getElementById(eId).innerHTML;
			incorporarScroll("TT"+wItemSel,"D");
		} else {
			if (!document.getElementById("colD"+wItemSel)) window.status="error en la página: no existe elemento "+"colD"+wItemSel;
			if (!document.getElementById(eId)) window.status="error en la página: no existe elemento "+eId;
		}
		if (h!="hist"&&eId.substring(0,2)!="TT") histIns("_O"+wItemSel,eId);
		document.getElementById("colD"+wItemSel).scrollTop=0;
	}
}

function scroll(c,d) {
	if (wInScroll == null) {
		var vId;
		if (c=="c_menu") vId = c;
		else vId = "col"+ c + wItemSel;
		var p = (d=="up")?-10:10;
		wInScroll = setInterval ("scroll2('"+vId+"',"+p+",'"+c+"')",50);
	}
}
function scroll2(vId,p,c) {
	//if (document.getElementById(vId).scrollTop) {
		document.getElementById(vId).scrollTop = document.getElementById(vId).scrollTop + p;
	//} 
	//if (document.getElementById(vId).pageYOffset) {
	//	document.getElementById(vId).pageYOffset = document.getElementById(vId).pageYOffset + p;
	//}
	if (document.getElementById("tildescroll"+c))
		document.getElementById("tildescroll"+c).style.top = parseInt((document.getElementById(vId).scrollTop * (CHTC - (CHSCR*2+CHSCRT))) / (document.getElementById(vId).scrollHeight - CHTC))+"px";
}
function scrollOff() {
	clearInterval(wInScroll);
	wInScroll=null;
}

function incorporarScroll(eId,c) {
	var oElem = document.getElementById(eId);
	var col = "col" + c + eId.substring(2,10);
	if (document.getElementById(col)) if (document.getElementById(col).scrollHeight <= CHTC)
		document.getElementById("scroll"+c).style.visibility = "hidden";
	else {
		document.getElementById(col).scrollTop=0;
		oElem.appendChild(document.getElementById("scroll"+c));
		document.getElementById("tildescroll"+c).style.top = 0;
		document.getElementById("scroll"+c).style.visibility = "visible";
	}
}

function scrollP(e) {
	var targ;var vId;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	vId = targ.getAttribute("id");
	if (vId.indexOf("tilde") != -1) return;
	var posy = 0;
	if (e.pageY) posy = e.pageY;
	else if (e.clientY) posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	posy = posy - parseInt(document.getElementById("c_frame").style.top) - CTT - CMVTC - CHSCR;
	if (posy < parseInt(document.getElementById("tildescroll"+vId.charAt(vId.length-1)).style.top))
		scroll2("col"+ vId.charAt(vId.length-1) + wItemSel,- CHT,vId.charAt(vId.length-1));
	else
		scroll2("col"+ vId.charAt(vId.length-1) + wItemSel,+ CHT,vId.charAt(vId.length-1));
}
function scrollPOff() {
	clearInterval(wInScroll);
	wInScroll=null;
}

//funciones generales
function absId(eId) {document.getElementById(eId).style.position = "absolute";};
function absOb(o) {o.style.position="absolute";};
function ocultarOb(oEl) {oEl.style.display = "none";}
function mostrarOb(oEl) {oEl.style.display = "block";}
function ocultar(eId) {document.getElementById(eId).style.display = "none";}
function mostrar(eId) {document.getElementById(eId).style.display = "block";}
function marginTop (oElem,m) {oElem.style.marginTop = parseInt(m) + "px";}
function dim(oEl,w,h) {oEl.style.width = (w==0)?"":parseInt(w)+"px";oEl.style.height = (h==0)?"":parseInt(h)+"px";}
function pos(oEl,t,l) {oEl.style.top = parseInt(t) +"px";oEl.style.left = parseInt(l) +"px";}
function posLeft(oEl,l) {oEl.style.left = parseInt(l) +"px";}
function centrar(){
	var f=document.getElementById("c_frame");
	if(!f.offsetWidth) return;
	var w=0;
	var h=0;
	if(window.innerWidth){
		w=window.innerWidth;
		h=window.innerHeight;
	}
	else if(document.body.clientWidth){
		w=document.body.clientWidth;
		h=document.body.clientHeight;
	}
	else if(document.documentElement.clientWidth){
		w=document.documentElement.clientWidth;
		h=document.documentElement.clientHeight;
	}
	if(w!=0)
		if (parseInt(f.offsetWidth)<w) f.style.left=parseInt((w-f.offsetWidth)/2)+"px";
		else f.style.left="0px";
		if (parseInt(f.offsetHeight)<h) f.style.top=parseInt((h-f.offsetHeight)/2)+"px";
		else f.style.top="0px";
}

