//	ll_.js



function chkDel(regnum) {
	if (confirm("Seguro que quieres borrar todas las huellas de esta foto?")) {
		var locAss = "http://"+location.hostname+"/inc/ll_fotos.php?s=g_bor&r="+regnum;
		window.location.assign(locAss);
	}
	else {
		return false;
	}
}

function f_chkTop() {
	//../foto_0042.html to ../archifot.html?foto_0042.html before loading
	if (window.top == window.self) {
		if (location.search != "?p") {
			var locAss = "http://"+location.hostname+"/archifot.html?"+location.pathname.slice(1);
			window.location.assign(locAss);
		}
		else {
			document.write('<style> div#print { display: none; } </style>"');
		}
	}
}
function f_ifrm() {
//	../archifot.html?foto_0042.html
	if (location.search != "") {
		document.getElementById('ifrm').src = location.search.slice(1);
	}
}

function v_chkTop() {
	//../vid_0001.html to ../archivid.html?vid_0001.html before loading
	if (window.top == window.self) {
		if (location.search != "?p") {
			var locAss = "http://"+location.hostname+"/archivid.html?"+location.pathname.slice(1);
			window.location.assign(locAss);
		}
		else {
			document.write('<style> div#print { display: none; } </style>"');
		}
	}
}
function v_ifrm() {
//	../archivid.html?vid_0001.html
	if (location.search != "") {
		document.getElementById('ifrm').src = location.search.slice(1);
	}
}
function showHW() {
//	Photo section	
	var avH = 0;											// 	Available Height
	var avW = 0;											// 	Available Width
	if ( typeof( window.innerWidth ) == 'number' ) {
		avH = window.innerHeight;							//	Non-IE
		avW = window.innerWidth;
	} 
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		avH = document.documentElement.clientHeight;		//	IE 6+ in 'standards compliant mode'
		avW = document.documentElement.clientWidth;
	} 
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		avH = document.body.clientHeight;					//	IE 4 compatible
		avW = document.body.clientWidth;
	}
	alert("AvH: "+avH+" AvW: "+avW);
}
function f_hW() {
//	Photo section	
	var avH = 0;											// 	Available Height
	var avW = 0;											// 	Available Width
	if ( typeof( window.innerWidth ) == 'number' ) {
		avH = window.innerHeight;							//	Non-IE
		avW = window.innerWidth;
	} 
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		avH = document.documentElement.clientHeight;		//	IE 6+ in 'standards compliant mode'
		avW = document.documentElement.clientWidth;
	} 
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		avH = document.body.clientHeight;					//	IE 4 compatible
		avW = document.body.clientWidth;
	}
//	Height calculations:						//	No real need for a max or min	
	var iHa_ = avH - 12-10;
	var iHb_ = iHa_ - 2;
	var iHb_min = iHb_ - 70;			// 	b_nav: 35 + b_dt: 35
	
//	Width calculations:
	//var iWa_ = avW - 12-10;				//	Min 1000 needed to avoid floated box dropping. Max no bad idea to stop it looking silly but we can leave that up to the user for now
	//if (iWa_ > 1000) {
	var	iWa_ = 1000;
	//}
	var iWc_ = iWa_ - 5-1-160-1-1-5;
	
	if (!document.getElementById("a_")) {
		document.write("<style>");
		document.write("div#a_ { height: "+iHa_+"px; width: "+iWa_+"px; }");
		document.write("div#b_ { height: "+iHb_+"px;}");
		document.write("div#b_b_min { height: "+iHb_min+"px;}");
		document.write("div#c_ { height: "+(iHb_ -42)+"px; width: "+iWc_+"px; }");
		document.write("div#nav_2 { width: "+(iWc_ - 1)+"px; }");
		document.write("</style>");
	}
	else {
		document.getElementById("a_").style.height = iHa_+"px";
		document.getElementById("b_").style.height = iHb_+"px";
		document.getElementById("b_b_min").style.height = iHb_min+"px";
		document.getElementById("c_").style.height = (iHb_ -42)+"px";
		document.getElementById("a_").style.width = iWa_+"px";
		document.getElementById("c_").style.width = iWc_+"px";
		document.getElementById("nav_2").style.width = (iWc_ - 1)+"px";
	}
}

function goTop() {
	if (parent.frames.length) { 
		top.location.href= document.location;
	}	
}

function redir(pg) {
	var url = "http://www.lalosa.es/"+pg+".html";
	window.location.href = url;
}

function fotLst(sTo) {
	var aLs = document.getElementById('flst').getElementsByTagName("li"); 
	var sFrom = document.getElementById('flst').className;
	switch(sTo) {
	case 'txt':
		for (var i = 0; i < aLs.length; i++ ) { 
		//	Cambiar de miniatura a texto:
			if (sFrom == "min") {
				if (aLs[i].className == "di") {
					aLs[i].className = "bg";
				}
				else {
					aLs[i].className = "dn";
				}
			}
			else {}
		}
	break;
	case 'mtx':
		alert(sTo);
	break;
	case 'min':
	//	Mostrar solo miniaturas:
		for (var i = 0; i < aLs.length; i++ ) { 
			//alert(aLs[i].className);
			if (sFrom == "txt") {
			//	Cambiar de texto a miniatura:
				if (aLs[i].className == "dn") {
					aLs[i].className = "di";
				}
				else {
					aLs[i].className = "dn";
				}
			}
			else {}
		}
	break;
	}
	document.getElementById('flst').className = sTo;
}

function cuentame(pg) {
//	Cuenta visitas y controla los cookies si hace falta
	if (pg == "xxxxxindex") {
		var sWlcm = cookieGet('intro');
		if (sWlcm == null) {
			cookieSet('intro', 'mostrar', 365);
			intro();			
		}
		else if (sWlcm == "mostrar") {
			intro();			
		}
		else {
			cookieSet('intro', 'esconder', 365);			
		}
	}
//	Contador
	document.getElementById('ifrm').src = "inc/cuentame.php?pg="+pg+"&rf="+document.referrer;
	
	//$url = 'http://username:password@hostname/path?arg=value#anchor';

	//print_r(parse_url($url));
	
	
}
function intro() {
	var navLang, navLangs, intro, trgt, pNode, pEl;
	var navLangs = "de en es fr pt";
	if (navigator.appVersion.indexOf("MSIE") != -1){
        navLang = navigator.browserLanguage.slice(0,2).toLowerCase();
    }
    else {
        navLang = navigator.language.slice(0,2).toLowerCase();
    }
	if (navLangs.indexOf(navLang) != -1) {
		intro = "intro_"+navLang;
		trgt = document.getElementById(intro);
		pEl = lang_txtHide(navLang,intro);
		//txtNode = document.createTextNode(txtHide);
		//pEl = document.createElement("p");
		//pEl.appendChild(pNode);
		trgt.appendChild(pEl);
		trgt.style.display = "block";
	}
}
function lang_txtHide(lng,intro) {
	var txt, atxt, aEl;
//	Best to have complete line with href and all	
	switch(lng) {
		case "de": 	pTxt = "Yavoll "; 
					aTxt = "hier"; 
					break;
		case "en": 	pTxt = "To hide this little message now and on future visits, please click "; 
					aTxt = "here";
					break;
		case "es": 	pTxt = "Esconder "; 
					aTxt = "aquí";
					break;
		case "fr": 	pTxt = "Montrer "; 
					aTxt = "ici";
					break;
		case "pt": 	pTxt = "Esconder "; 
					aTxt = "aqui";
					break;
	}
	pTxt = document.createTextNode(pTxt);
	pEl = document.createElement("p");
	pEl.appendChild(pTxt);
	aTxt = document.createTextNode(aTxt);
	aEl = document.createElement("a");
	aEl.className = "here";
	aEl.href = "#";
	aEl.onclick = function(){introHide(intro); return false;};
	//aEl.onclick = function(){introHide(intro)};
	aEl.appendChild(aTxt);
	pEl.appendChild(aEl);
	pEl.appendChild(document.createTextNode("."));
	return pEl;
}
function introHide(intro) {
	document.getElementById(intro).style.display = "none";
	cookieSet('intro', 'esconder', 365);
}
function chkHWn(iHCab) {
	//alert("a: "+iHCab);
	if (document.getElementById("a_borde")) {
		iHCab = parseInt(document.getElementById('c_cabeza').className.slice(3));
		//alert("b: "+iHCab);
	}

	var avH = 0;											// Available Height
	var avW = 0;											// Available Width
	iHBSub = 22;
	iWBSub = 22;
	if ( typeof( window.innerWidth ) == 'number' ) {
		avH = window.innerHeight;							//	Non-IE
		avW = window.innerWidth;
		//alert("nonIE");
	} 
	else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		avH = document.documentElement.clientHeight;		//	IE 6+ in 'standards compliant mode'
		avW = document.documentElement.clientWidth;
		//alert("IE6");
		iHBSub = 32;
		iWBSub = 42;
	} 
	else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		avH = document.body.clientHeight;					//	IE 4 compatible
		avW = document.body.clientWidth;
		//alert("IE4");
		iHBSub = 32;
		iWBSub = 42;
	}
	//alert("avH: "+avH+" avW: "+avW);
	var iHBorde	= avH-iHBSub;						//	Body 5+5p Borde 2b
	var iWBorde	= avW-iWBSub;						//	Body 5+5p Borde 5p + 5p + 2b
//	Limits to size: 							//	Up to 1280 x 1024
	if (avH > 1000) {							//	Max height
		iHBorde = 1000-12;
	}
	if (avW > 1280) {							//	Max header width = 320x3 = 960 ojo
		iWBorde = 1280-22;						//	Pics nav max 320 x 640
	}
	if (avH < 500) {							//	Min height
		iHBorde = 500-12;
	}
	if (avW < 880) {							//	Min width
		iWBorde = 880-22;
	}
	//alert(iHBorde);
	//alert(iWBorde);
//	Widths as % of borde: Borde 5+5
	//var iWCont = (iWBorde-10)*75/100;
	var iWNav = (iWBorde-5-1-2-2-1-5)*21/100;
	var iWCont = (iWBorde-5-5)-(iWNav);
	var iHPrincipal = iHBorde-5-1-iHCab-1-3-3-20-5;
	var iHNav = 1+iHCab+1+3+iHPrincipal+1;
	if (!document.getElementById("a_borde")) {
		//alert("new");
		document.write("<style>");
		document.write("div#a_borde { height: "+iHBorde+"px; width: "+iWBorde+"px; }");
		document.write("div#b_cont { width: "+iWCont+"px; }");
		document.write("div#d_principal { height: "+iHPrincipal+"px; }");
		document.write("div#e_nav { height: "+iHNav+"px; width: "+iWNav+"px; }");
		document.write("</style>");
	}
	else {
		//alert("Go on then resize the bloody thing");
		document.getElementById("a_borde").style.height = iHBorde+"px";
		document.getElementById("a_borde").style.width = iWBorde+"px";
		document.getElementById("b_cont").style.width = iWCont+"px";
		document.getElementById("d_principal").style.height = iHPrincipal+"px";
		document.getElementById("e_nav").style.height = iHNav+"px";
		document.getElementById("e_nav").style.width = iWNav+"px";
	}
}

function mn() { 
//	Called on load
//	Adds the same onclick function to all open/close (o/c) type LI elements in the menu
//	Type is defined in the fourth letter of the class: 
//	o = open, c = close, a = anchor 
//	H = highlighted anchor but does not need to change here
	var uMn = document.getElementById("mn");
	var aLs = uMn.getElementsByTagName("li"); 
	for (var i = 0; i < aLs.length; i++ ) { 
		var liType = aLs[i].className.slice(3,4);
		if (liType == "o" || liType == "c") {
		//	Add the onclick function
			aLs[i].onclick = function(e) {
			//	The function loops through ALL the LI elements
			//	Get details about the o/c that has been clicked:
				var eiLevel = parseInt(this.className.slice(1,3));		//	level as integer 1
				var eType = this.className.slice(3,4);					//	type "o" or "c"
				var eId = this.id;										//	id e.g. "Ayun_01"
				var eSection = eId.slice(0,4);							//	section eg "Ayun" or "Serv" etc.
				var uMn = document.getElementById("mn");
				var aLs = uMn.getElementsByTagName("li"); 
				switch(eType) {
				//	Hides or shows the element (fifth letter of class: h = hide, s = show)
				//	depending on which open/close o/c element has been clicked
					case "o":
						for (var i = 0; i < aLs.length; i++ ) {
							var liType = aLs[i].className.slice(3,4);
							var liLevel = parseInt(aLs[i].className.slice(1,3));
							var liId = aLs[i].id;
							var liSection = aLs[i].id.slice(0,4);
						//	alert(liId.slice(0,eId.length));
						//	Always show level 1:	
							if (liLevel == 1) {
							//	alert("Always show level 1");
								aLs[i].className = aLs[i].className.replace("h","s");
							}
							else {
							//	If the section is the same as that clicked:
								if (liSection == eSection) {
								//	Show all that are at the same level or less
									if (liLevel <= eiLevel) {
									//	alert("Same section - Same level or less, so show");
										aLs[i].className = aLs[i].className.replace("h","s");
									}
								//	Show all that are one level above and begin with the same id:
									else if (liLevel == eiLevel+1 && liId.slice(0,liId.length-3) == eId) {
									//	alert("Same section - One level above - id match OK, so show");
										aLs[i].className = aLs[i].className.replace("h","s");
									}
									else {
									//	alert("Same section but hide");
										aLs[i].className = aLs[i].className.replace("s","h");
									}
								}
							//	Always hide and/or set open to close if the sections are different:
								else {
								//	alert("Different sections, so hide");
									aLs[i].className = aLs[i].className.replace("s","h");
								}
							}
						//	Plus or minus for the open/close type?
							if (liType == "c" && liSection != eSection) {
							//	alert("Type c, not same section, so set to open")
								aLs[i].title = "Abre con un clic";
								aLs[i].className = aLs[i].className.replace("c","o");
							}
							if (liType == "c" && liSection == eSection && liLevel == eiLevel) {
							//	alert("Type c, same section, same level, so set to open")
								aLs[i].title = "Abre con un clic";
								aLs[i].className = aLs[i].className.replace("c","o");
							}							
							this.title = "Cierra con un clic";
							this.className = this.className.replace("o","c");
						}	
					break;
					case "c":
					//	Close and hide any part of a section with id longer than itself
						this.title = "Abre con un clic";
						this.className = this.className.replace("c","o");
						for (var i = 0; i < aLs.length; i++ ) {
						//	Hide the next level for that section:
							if (aLs[i].id.slice(0,4) == eSection && aLs[i].id.length >= eId.length+3) {
								aLs[i].className = aLs[i].className.replace("s","h");
							//	make necessary changes to the class and title if needed:	
								if (aLs[i].className.slice(3,4) == "c" && aLs[i].id.length >= eId.length+3) {
									aLs[i].title = "Abre con un clic";
									aLs[i].className = aLs[i].className.replace("c","o");
								}
							}
						}	
					break;
				}
				//alert("Menu height: "+document.getElementById("e_menu").clientHeight);
			}
		}
	}
}

function shw(base,trgt) {
	//alert("show");
	document.getElementById(trgt).style.display = "block";
	base.className = "minus";
	base.onclick = function() {hd(base, trgt);};

}
function shwr(base,trgt) {
	//alert("show");
	document.getElementById(trgt).style.display = "block";
	base.className = "minusr";
	base.onclick = function() {hdr(base, trgt);};

}
function tiempo() {
//	ojo con IE 
	var ifrm, trgt, hBef;
	ifrm = document.createElement("iframe");
	ifrm.frameborder = "0";
	ifrm.id = "tiempo";
	ifrm.marginheight = "0";
	ifrm.marginwidth = "0";
	ifrm.scrolling = "no";
	ifrm.src = "inc/tiempo.html";
	ifrm.title = 'Haz clic para más detalles desde www.eltiempo.es';
	trgt = document.getElementById("index");
	if (document.getElementById("emrg")) {
		hBef = document.getElementById("emrg");
	}
	else if (document.getElementById("noti")) {
		hBef = document.getElementById("noti");
	}
	else {
		hBef = document.getElementById("noti1");
	}
	trgt.insertBefore(ifrm,hBef);
	setTimeout("document.getElementById('tiempo').style.display = 'block';", 1000);
}
function hd(base,trgt) {
	//alert("hide");
	document.getElementById(trgt).style.display = "none";
	base.className = "plus";
	base.onclick = function() {shw(base, trgt);};

}
function hdr(base,trgt) {
	//alert("hide");
	document.getElementById(trgt).style.display = "none";
	base.className = "plusr";
	base.onclick = function() {shwr(base, trgt);};

}

function callEmilio(n,m,a) {
	var d = new Date();
	var yyyy = d.getFullYear();
	var aEmilios = new Array;
	aEmilios[0] = ['ayuntamiento'];
	aEmilios[1] = ['webmaster'];
	aEmilios[2] = ['noticias'];
	aEmilios[3] = ['biblioteca'];
	var sEmilio = aEmilios[n]+'.'+yyyy+a+'lalosa'+'.'+'e';
	var sEmilio = '<a class="em" href="'+m+'lto'+':'+sEmilio+'s">'+sEmilio+'s</a>';
	if (n == 0){
		var sEmilio = '<a class="em" href="'+m+'lto'+':aytolalosa@terra.es">aytolalosa@terra.es</a>';
	}
	document.getElementById("e"+n).innerHTML = sEmilio;
}
function randomImg() {
//	Uses a random number (favourites) to pick a photo to show as a background on the left of the main content under the menu
	var rN = Math.floor(Math.random()*6);
	var rF = new Array;
	rF[0] = ['flor_001_f'];
	rF[1] = ['expo_08_21_f'];
	rF[2] = ['muestra_01'];
	rF[3] = ['muestra_02'];
	rF[4] = ['muestra_03'];
	rF[5] = ['muestra_04'];
	var bckImg = rF[rN]+".jpg";
	return bckImg;
	//document.getElementById('foto').style.backgroundImage = bckImgUrl;
}
function randomBack_() {
//	Uses a random number (favourites) to pick a photo to show as a background on the left of the main content under the menu
	var rN = Math.floor(Math.random()*7);
	var rF = new Array;
	rF[0] = ['flor_001_f'];
	rF[1] = ['expo_08_21_f'];
	rF[2] = ['hermita_cruz_f'];
	rF[3] = ['muestra_01'];
	rF[4] = ['muestra_02'];
	rF[5] = ['muestra_03'];
	rF[6] = ['muestra_04'];
	var bckImgUrl = "url(fotos/fav/"+rF[rN]+".jpg)";
	//document.getElementById('foto').style.backgroundImage = bckImgUrl;
}

function mnHL(u,v) {
	// Muestra donde estás en el menú(Menu HighLight)
	// u es el id del menu e.g. entorno (ento)
	// v es el valor de la secci?n del men?  e.g. flora (flor)
	// Segundo nivel:
	
	var uShw = document.getElementById(u);
	uShw.style.display = "block";
	// Mostrar el tercer nivel si hace falta subiendo por el DOM:
	if (uShw.parentNode.parentNode.parentNode.className == "oc") {
		uShw.parentNode.parentNode.style.display = "block";
	}
	// Resaltar el link en el menu para que sepa el usuario donde se encuentra:
	var aLis = uShw.getElementsByTagName('li');
	for (var i = 0; i <aLis.length; i++) {
		//if (aLis[i].firstChild.firstChild.nodeValue.slice(0,5).toLowerCase() == v) {
		if (aLis[i].firstChild.firstChild.nodeValue.toLowerCase() == v) {
			//aLis[i].style.backgroundColor = "#f5f5f5";
			aLis[i].style.fontWeight = "bold";
			//aLis[i].firstChild.style.backgroundColor = "#f5f5f5";
			//aLis[i].firstChild.style.textDecoration = "underline";
			aLis[i].style.paddingTop = "1ex";
			aLis[i].style.paddingBottom = "1ex";
			// Does not work for some reason ...
			//aLis[i].style.background = "url(../pics/arrwrght.gif) repeat 0px 3px;"
		}
	}
	// good place for the counter
	document.getElementById('mess').firstChild.nodeValue = v;
}

function showAll(a) {
	var aUls = document.getElementsByTagName('ul');
	for (var u = 0; u <aUls.length; u++) {
		aUls[u].style.display = "block";
	}
	a.childNodes[0].nodeValue = "Esconder todo";
	a.onclick = function() {
		hideAll(this);
		this.blur();
		return false;
	};
}
function hideAll(a) {
	//var aUls = document.getElementsByTagName('ul');
	//for (var u = 0; u <aUls.length; u++) {
	//	aUls[u].style.display = "none";
	//	a.childNodes[0].nodeValue = "Mostrar todo";
	//	
	//}
	a.onclick = function() {
		showAll(this);
		this.blur();
		return false;
	};
	chk();
}

function cookieSet(sName,sValue,dExpiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate()+dExpiredays);
	document.cookie = sName+" = "+escape(sValue)+((dExpiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function cookieSet_(sName, sValue, oExpires, sPath, sDomain, bSecure) {
	var sCookie = sName + "=" + encodeURIComponent(sValue);
	if (oExpires) {
		sCookie += "; expires=" + oExpires.toGMTString();
	}
	if (sPath) {
		sCookie += "; path=" + sPath;
	}
	if (sDomain) {
		sCookie += "; domain=" + sDomain;
	}
	if (bSecure) {
		sCookie += "; secure";
	}
	document.cookie = sCookie;
}

function cookieGet(sName) {
	var sRE = "(?:; )?" + sName + "=([^;]*);?";
	var oRE = new RegExp(sRE);
	if (oRE.test(document.cookie)) {
		return decodeURIComponent(RegExp["$1"]);
	}
	else {
		return null;
	} 
}
function x_chkWlcm(pg) {
	var sWlcm = cookieGet('welcome');
	if (sWlcm == null) {
		//document.getElementById('mess').firstChild.nodeValue = "!Bienvenido!";
		setCookie('welcome', 'done');	
	}
//	Contador
	//alert(p);
	document.getElementById('ifrm').src = "../php/snips/cuentame.php?pg="+pg+"&rf="+document.referrer;
}



function timeStart() {
	var today,h,m,s,t;
	today = new Date();
	h = today.getHours();
	m = today.getMinutes();
	s = today.getSeconds();
// 	add a zero in front of numbers < 10
	m = timeCheck(m);
	s = timeCheck(s);
	// <div id="f">Fun</div>
	
	if (!document.getElementById("f")) {
		var trgt = document.getElementById("cabecera");
		var ib = document.getElementById("h");
		var d	= document.createElement("div");
		d.id = "f";
		var p	= document.createElement("p");
		p.id = "js";
		d.appendChild(p);
		trgt.insertBefore(d,ib);
	}
	document.getElementById('js').innerHTML = h+":"+m+":"+s;
	t = setTimeout('timeStart()',500);
}
function timeCheck(i) {
	if (i < 10) {
		i = "0"+i;
	}
	return i;
}
function weather() {
	var d,h,a1,a2,s;
	var trgt = document.getElementById('TT_9gW4q9Z7ArY7sypS4');
	//d	= document.createElement("div");
	//d.id = "TT_9gW4q9Z7ArY7sypS4";
	h	= document.createElement("h2");
	a1	= document.createElement("a");
	a1.href = "http://www.tutiempo.net/Tiempo-Espana.html";
	a1.appendChild(document.createTextNode("El Tiempo"));
	h.appendChild(a1);
	trgt.appendChild(h);
	a2	= document.createElement("a");
	a2.href = "http://www.tutiempo.net/Tiempo-La-Losa-E40404.html";
	a2.appendChild(document.createTextNode("El tiempo en La Losa"));
	trgt.appendChild(a2);
	//trgt.appendChild(d);
	//s	= document.createElement("script");
	//s.type = "text/javascript";
	document.getElementById('wthr').src = "http://www.tutiempo.net/TTapi/9gW4q9Z7ArY7sypS4";
	//trgt.appendChild(s);
}
function mnHL_(u,v) {
	// Muestra donde estás en el menú (Menu Highlight)
	// u es el id del menu principal en el que se encuentra e.g. entorno (ento)
	// v es el valor de la sección del menú  e.g. flora (flor)
	// Segundo nivel:
	
	var uShw = document.getElementById(u);
	uShw.style.display = "block";
	// Mostrar el tercer nivel si hace falta subiendo por el DOM:
	if (uShw.parentNode.parentNode.parentNode.className == "oc") {
		uShw.parentNode.parentNode.style.display = "block";
	}
	// Resaltar el link en el menu para que sepa el usuario donde se encuentra:
	var aLis = uShw.getElementsByTagName('li');
	for (var i = 0; i <aLis.length; i++) {
		//if (aLis[i].firstChild.firstChild.nodeValue.slice(0,4).toLowerCase() == v) {
		if (aLis[i].firstChild.firstChild.nodeValue.toLowerCase() == v) {
			aLis[i].style.backgroundColor = "LightBlue";
			aLis[i].style.fontWeight = "bold";
			// Does not work for some reason ...
			//aLis[i].style.background = "url(../pics/arrwrght.gif) repeat 0px 3px;"
		}
	}
	// good place for the counter
	document.getElementById('mess').firstChild.nodeValue = v;
}

function emRev() {
	var emId,i,emId,trgt,emb2f,em,t,a;
//	loop:	
	for (i = 1; i < 12; i++) {
		emId = "em"+i;
		if (document.getElementById(emId)) {
			trgt = document.getElementById(emId);
			t = trgt.childNodes[0].nodeValue;
			trgt.childNodes[0].nodeValue = "";
			emb2f = trgt.className;
			trgt.className = "em";
			trgt.title = "Enviar un correo";
			em = strrev(emb2f);
			em = em.replace("#1","@");
			em = em.replace("#2",".");
			em = em.replace("#3","_");
			em = em.replace("#4","-");
		//	&nbsp;
			if ( t == '\xa0') {
				t = document.createTextNode(em);
			}
			else {
				t = document.createTextNode(t);
			}
			a = document.createElement("a");
			a.href = "mailto:"+em;
			a.appendChild(t);
			trgt.appendChild(a);
		}
		else {
			return;
		}
	}
}	

function strrev(string) {
    // Reverse a string  
    // 
    // version: 912.1315
    // discuss at: http://phpjs.org/functions/strrev    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   reimplemented by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: strrev('Kevin van Zonneveld');
    // *     returns 1: 'dlevennoZ nav niveK'    // *     example 2: strrev('a\u0301haB') === 'Baha\u0301'; // combining
    // *     returns 2: true
    // *     example 3: strrev('A\uD87E\uDC04Z') === 'Z\uD87E\uDC04A'; // surrogates
    // *     returns 2: true
    string = string+''; 
    // Performance will be enhanced with the next two lines of code commented
    //      out if you don't care about combining characters
    // Keep Unicode combining characters together with the character preceding
    //      them and which they are modifying (as in PHP 6)    // See http://unicode.org/reports/tr44/#Property_Table (Me+Mn)
    // We also add the low surrogate range at the beginning here so it will be
    //      maintained with its preceding high surrogate
    var grapheme_extend = /(.)([\uDC00-\uDFFF\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065E\u0670\u06D6-\u06DC\u06DE-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0901-\u0903\u093C\u093E-\u094D\u0951-\u0954\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C01-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C82\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D02\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F90-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B6-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAA\u1C24-\u1C37\u1DC0-\u1DE6\u1DFE\u1DFF\u20D0-\u20F0\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA67C\uA67D\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA926-\uA92D\uA947-\uA953\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uFB1E\uFE00-\uFE0F\uFE20-\uFE26])/g;
    string = string.replace(grapheme_extend, '$2$1'); // Temporarily reverse 
    return string.split('').reverse().join('');
}

