﻿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="4px"; 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) 1px 4px no-repeat";
		height="39px"; width="98px"; zIndex="0"; textAlign="center"; fontFamily="sans-serif,Arial"; fontSize="12px"; borderBottom="1px solid white"; borderRight="1px solid white";
	}
	
	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+"px"; top=y+38+"px"; border="1px solid white"; visibility="hidden"; zIndez="2";
	width="96px"; cursor="pointer"; backgroundColor="white"
	}
	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="21px"}

	
}
aquane=new menu(800,38)

//Fichas
//S.M.F, Aquane.com
function ficha(capa,pos,direcc) {
	this.ob=document.getElementById(capa); this.ob.firstChild.firstChild.style.border="0px solid white"
	this.n="o"+capa
	this.css=this.ob.style;	this.css.position="absolute"; this.css.zIndex="1"
	this.x=possx[pos.substring(1)];
	this.y=possy[pos.substring(0,1)];
	this.pon=ponEn;		this.pon(this.x,this.y);
	this.tit=document.getElementById("t"+capa.substring(1));
	this.tit.style.left=this.x+"px"; this.tit.style.borderWidth=0;
	this.tit.style.top=this.y+"px"
	this.xf=this.x+96;	this.yf=this.y+87;
	this.xF=this.x-96;	this.yF=this.y-87;
	this.dir=direcc;
	this.mueve=muevelo;	this.mueveono=fmueveono
	this.m=false;		this.v=false;
	this.ob.onmouseover=function() {eval("o"+this.id+".mueveono()")}
}
function fmueveono() { if(!this.m) this.mueve()}
function muevelo() {
	this.m=true;
	if(this.dir=="h") { //ancho 97px= 24pasos*4px + 1corrección
		if(this.x<this.xf) {this.pon(this.x+4); setTimeout(this.n+".mueve()",60)}
		else {this.dir="H"; this.xF+=96; if(this.v) {this.xf+=96; this.xF-=96; this.v=false; this.m=false} else {this.v=true; setTimeout(this.n+".mueve()",3500)}; return}
	}
	if(this.dir=="H") {
		if(this.x>this.xF) {this.pon(this.x-4); setTimeout(this.n+".mueve()",60)}
		else {this.dir="h"; this.xf-=96; if(this.v) {this.xf+=96; this.xF-=96; this.v=false; this.m=false} else {this.v=true; setTimeout(this.n+".mueve()",3500)}}
	}
	if(this.dir=="v") {
		if(this.y<this.yf-4) {this.pon(0,this.y+4); setTimeout(this.n+".mueve()",60)}
		else {this.pon(0,this.y+3); this.dir="V"; this.yF+=87; if(this.v) {this.yf+=87; this.yF-=87; this.v=false; this.m=false} else {this.v=true; setTimeout(this.n+".mueve()",3500)}; return}
	}
	if(this.dir=="V") {
		if(this.y>this.yF+4) {this.pon(0,this.y-4); setTimeout(this.n+".mueve()",60)}
		else {this.pon(0,this.y-3); this.dir="v"; this.yf-=87; if(this.v) {this.yf+=87; this.yF-=87; this.v=false; this.m=false} else {this.v=true; setTimeout(this.n+".mueve()",3500); return}}
	}
}
function ponEn(px,py) {
	if(px) {this.x=px; this.css.left=this.x+"px"}
	if(py) {this.y=py; this.css.top=this.y+"px"}

}
function raya(dir,x,y,lng,clr) {
	var linea=document.createElement("div"); 
	document.body.appendChild(linea)
	with(linea.style) {backgroundColor=clr; lineHeight="1px"; position="absolute"; left=x+"px"; top=y+"px";
		width=(dir=="h")?lng+"px":"1px"; height=(dir=="v")?lng+"px":"1px"; zIndex="2"
	}
	linea.innerHTML=(dir=="h")?"&nbsp;":""
}
	var possy=new Array(429,81,168,255,342)
	var possx=new Array(775,7,103,199,295,391,487,583,679)
	for(var w=0 in possy) raya("h",7,possy[w],769, "white")
	for(var z=0 in possx) raya("v",possx[z],82,347,"white")
	raya("h",110,465,665,"white")

os1=new ficha("s1","11","h")
os2=new ficha("s2","21","v")
os3=new ficha("s3","32","V")
os4=new ficha("s4","42","H")
os5=new ficha("s5","43","h")
os6=new ficha("s6","34","H")
os7=new ficha("s7","25","H")
os8=new ficha("s8","13","v")
os9=new ficha("s9","14","h")
os10=new ficha("s10","27","H")
os11=new ficha("s11","38","H")
os12=new ficha("s12","46","V")
os13=new ficha("s13","45","V")
os14=new ficha("s14","17","H")
os15=new ficha("s15","18","v")
document.getElementById("menu1").style.top="38px"
with(document.getElementById("laq").style) {
left="584px";top="343px";width="192px";height="87px"
}

function muevealgunas() {
	var k=14*Math.round(Math.random())+3
	for(var i=0; i<k; i++) {var n=Math.round(Math.random()*14)+1
		eval("os"+n+".mueveono()")
	}
}