﻿function boton(ob,im2,Tcolor) {var im1=ob.src, textobj=document.getElementById("ayuda")
	var texto=ob.alt
	ob.src=im2; ob.alt=""
	textobj.style.color=Tcolor
	textobj.innerHTML=texto
	ob.onmouseout=function() {ob.src=im1; ob.alt=texto; textobj.innerHTML=""}
}
//FUNCIONES MENU:   var m=new menu(x,y)
function menu(x,y) {
	this.cabeza=document.createElement("DIV"); document.body.appendChild(this.cabeza)
	this.items=document.createElement("DIV"); document.body.appendChild(this.items)
	this.foto=document.createElement("DIV"); 
	this.foto.innerHTML='<img id="F" src="../jscss/AQ.jpg" alt="" />'
	with(this.foto.style) {height="87px"; marginTop="10px"; cursor="default";
	}	
	this.cabeza.its=this.items; this.items.cab=this.cabeza;
	with(this.cabeza.style) {position="absolute"; left=x+"px"; top=y+"px"; background="white url(../jscss/minilogo2.jpg) 0 7px no-repeat";
		height="42px"; width="97px"; zIndex="2"; textAlign="center"; fontFamily="sans-serif,Arial"; fontSize="12px"; borderLeft="1px solid #000";
	}
	this.cabeza.innerHTML="&nbsp;&nbsp;&nbsp;series";
	this.cabeza.onmouseover=function() {this.its.style.visibility="visible"}
	this.cabeza.onmouseout=function() {this.its.style.visibility="hidden"}
	with(this.items.style) {
	position="absolute"; left=x+10+"px"; top=y+35+"px"; border="1px solid orange"; visibility="hidden"; zIndez="2";
	width="96px"; cursor="pointer"; backgroundColor="white"; zIndex="2";opacity="0.9";
	}
	this.items.onmouseover=function() {this.style.visibility="visible"}
	this.items.onmouseout=function() {this.style.visibility="hidden";document.getElementById("F").src="../jscss/AQ.jpg"}	
	this.seriestit=new Array("Niágara","Queiles","Riglos","Yesa","Keops","Moncayo","Teruel","Jiloca","Jalón","Duero","Ordesa","Aragón","Ebro","Canfranc","Termost.")
	this.seriesurl=new Array("niagara","","","","","","","","jalon","","","aragon","","","termostaticas")
	this.seriesimgs=new Array("n","q","r","y","k","m","t","ji","ja","du","o","a","e","c","l")

	for(var i=0; i<this.seriestit.length; i++) {
	var is="../jscss/i"+this.seriesimgs[i]+".jpg"
	eval("this.it"+i+"=new item('"+this.seriestit[i]+"','"+is+"','"+this.seriesurl[i]+"')")	//crea aquane.it0.tit,img y href
	eval("this.items.appendChild(this.it"+i+".a)");
	}
	this.items.appendChild(this.foto);
}
function item(tit,imgsrc,url) {
	this.tit=tit;
	this.a=document.createElement("DIV")
	this.a.href=(url)?"../"+url+"/index.html":"../"+tit.toLowerCase()+"/index.html"
	this.a.img=new Image(); this.a.src=imgsrc;
	this.a.innerHTML=tit
	this.a.onclick=function() {location.href=this.href}
	this.a.onmouseover=function() {document.getElementById("F").src=this.src; this.style.backgroundColor="#226BD1"; this.style.color="white"}
	this.a.onmouseout=function() {this.style.backgroundColor="white"; this.style.color="black"}

	with(this.a.style) {color="black"; width="96px"; fontFamily="Arial,sans-serif"; fontSize="14px"; textIndent="10px"; height="20px"}
}
aquane=new menu(0,11)

//FUNCIONES CAPA AMPLIAR-IMAGEN
var ampliaimg=document.createElement("DIV"),wd,hd, wv=anchov(),hv=altov(),winload=false
document.body.appendChild(ampliaimg)
window.onload=function() {winload=true}
function muestra(e,obj) {
	if(!winload) return

	with(ampliaimg.style) {
	position="absolute"; border="1px solid #1E1F20"; borderWidth="4px 1px"; backgroundColor="white"; zIndex="2"
	}

	ampliaimg.style.display="block"
	var im=new Image(); im.src=obj.src
	wd=im.width,hd=im.height
	var titulo=obj.alt
	obj.onmouseout=quita
	obj.onmousemove=imgen
	var txt='<img src="'+im.src+'" alt="'+obj.alt+'" />'
	ampliaimg.innerHTML=txt
	imgen(e)
}
function imgen(e) {
	var sy=scrollY(),dx=40,dy=10,xd,yd,px=posX(e),py=posY(e)
	if(document.title.indexOf("Indice")!=-1) {xd=(250-wd)/2+480; yd=400-hd}
	else {	xd=(px+dx+wd+15>=wv)?px-dx-wd:px+dx
		if((py-(hd/2))<=0) yd=sy+dy
		else if((py+(hd/2))>=hv) yd=sy+hv-hd-dy
		else yd=sy+py-(hd/2)
	}
	ampliaimg.style.left=xd+"px"
	ampliaimg.style.top=yd+"px"
}
function quita() {if(ampliaimg) ampliaimg.style.display="none"}

function anchov() {
var ancho=0
if(typeof(window.innerWidth)=='number') ancho=window.innerWidth
else if(document.documentElement.clientWidth) ancho=document.documentElement.clientWidth
else if(document.body.clientWidth) ancho=document.body.clientWidth
return ancho
}
function altov() {
var alto=0
if(typeof(window.innerHeight)=='number') alto=window.innerHeight
else if(document.documentElement.clientHeight) alto=document.documentElement.clientHeight
else if(document.body.clientHeight) alto=document.body.clientHeight
return alto
}
function scrollY() {
var scrolly=0
if(typeof(window.pageYOffset)=='number') scrolly=window.pageYOffset
else if(document.documentElement.scrollTop) scrolly=document.documentElement.scrollTop
else if(document.body.scrollTop) scrolly=document.body.scrollTop

return scrolly
}
function posX(event) {
var x=(window.event)?window.event.clientX:event.clientX
return x
}
function posY(event) {
var y=(window.event)?window.event.clientY:event.clientY
return y
}