﻿d = new Date();
t_stamp = d.getTime();

dir = top.document.location.href
arrayDir = dir.split("&");
if (arrayDir.length > 1) {
	etpBruto = arrayDir[1];
	anio = arrayDir[0].substr(arrayDir[0].indexOf("=", 0)+1, arrayDir[0].length - arrayDir[0].indexOf("=", 0));
	etp = arrayDir[1].substr(arrayDir[1].indexOf("=", 0)+1, arrayDir[1].length - arrayDir[1].indexOf("=", 0));
} else {
	etpBruto = arrayDir[0];
	anio = "2008";
}
etp = etpBruto.substr(etpBruto.indexOf("=", 0)+1, etpBruto.length - etpBruto.indexOf("=", 0));
//alert(etp +" - "+anio)

//dir = top.document.location.href
//pos = dir.indexOf("?", 0)
//etp = dir.substr(pos+3, 2);
//etp = parent.etapa
if (!(isNaN(etp))) {
	etpnum = parseInt(etp);
	if (etpnum >= 1 && etpnum <=21) {
		etpm = etp
	} else {
		etp = "1"
		etpm = "1"
	}
} else {
	if ((etp == "p") || (etp == "d1") || (etp == "d2")) {
		if (etp == "p") etpm = "1"
		if (etp == "d1") etpm = "9"
		if (etp == "d2") etpm = "15"
	} else {
		etp = "1"
		etpm = "1"
	}
}

if (dir.indexOf("espanol/") != -1) {
	textoRemplazar = "espanol/"
} else {
	if (dir.indexOf("ingles/") != -1) {
		textoRemplazar = "ingles/"
	} else {
		textoRemplazar = "frances/"
	}	
}

enlaceing = dir.replace(textoRemplazar, "ingles/");
enlacefra = dir.replace(textoRemplazar, "frances/");
enlaceesp = dir.replace(textoRemplazar, "espanol/");
enlaceing = enlaceing.replace("cat", "");// para que no se vaya a catalan en ingles
enlacefra = enlacefra.replace("cat", "");// para que no se vaya a catalan en frances
enlaceing = enlaceing.replace("val", "");// para que no se vaya a valenciano en ingles
enlacefra = enlacefra.replace("val", "");// para que no se vaya a valenciano en frances

function pagina(anio){
	if (anio!=0){
		anio_actual=anio
		cadena="index.html?a="+anio+"&e="+etp
		top.location=cadena;
	}
}


function ocultarMenus(n) {
	for(i=1;i<=n;i++) {
		obj = eval("document.getElementById('m"+i+"')");
		obj.style.display = "none";
	}
}
function ocultarContenidos(n) {
	for(i=1;i<=n;i++) {
		obj = eval("document.getElementById('contenido"+i+"')");
		obj.style.display = "none";
	}
}

function activarMenu(menu, pagina, profundidad) {
	$("#menu_cont a").eq(mactivo).removeClass();
	$("#menu_cont a").eq(menu).addClass("activo");
	mactivo = menu;
//	$("#pag").hide().after('<div id="cargando" style="height:800px"><img src="../../imagenes/cargando.gif" vspace=20/></div>').load(pagina, function() {$("#cargando").remove();$(this).fadeIn("slow")});
	obj = document.getElementById("historia_fr");
	obj.src = pagina;
}



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function resize_contenedor(){
	h=(document.body.scrollHeight)
//	if (h > top.document.body.offsetHeight-150) h = top.document.body.offsetHeight-150
	a=parent.document.getElementById("historia_fr")
	if (h < 270) h = 300;
	a.height=h+30+"px"
}

imagen = '';
tituloi = '';
extrasi = '';

function abrirImg(foto,titulo,copyright){
	imagen=foto;
	tituloi=titulo;
	copyrighti=copyright;
	features = "width=500,height=550";
	var newWindow = window.open("../../imagenes.html","imagenes",features);
	var ServerURL = self.location.href;

	var Position = ServerURL.indexOf("/");
	var Actual_Server = ServerURL.substring(Position,ServerURL);
	newWindow.location=Actual_Server+"../../imagenes.html"
	newWindow.focus()
}



function init(n) {
	numero_capas=n;
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	ns6 = (document.getElementById)? true:false
	if (ns4) {
		menu = document.menuDiv;
		for(i=1;i<=n;i++)
			eval("clas"+i+" = document.clas"+i+"Div;")
		anchoven = window.innerWidth-16;
		}
	if (ns6) {
		menu = document.getElementById("menuDiv").style;
		clas1 = document.getElementById("clas1Div").style;
		for(i=1;i<=n;i++)
			eval("clas"+i+" = document.getElementById('clas"+i+"Div').style;")

		anchoven = document.body.clientWidth;
		} else { 
			if (ie4) {
			menu = menuDiv.style;
			for(i=1;i<=n;i++)
				eval("clas"+i+" = clas"+i+"Div.style;")
			anchoven = document.body.clientWidth;
			}
		}
	if ((ns6) && (! ie4)){
		anchoven = window.innerWidth-16;
		}
// quitar esta línea si queremos centrarlo con respecto a la página
//anchoven = 590;
anchoven += 140
altura=10;
	menu.left = ((anchoven-135)/2)-252+"px";
	menu.top = altura
	for(i=1;i<=n;i++){
		eval("clas"+i+".left = '"+((anchoven-380)/2)+"px'");
		eval("clas"+i+".top = altura;")
//		alert("clas"+i+".left" + ": " + eval("clas"+i+".left"));
	}
	mostrarObjeto(menu);
	mostrarObjeto(clas1);
	for(i=2;i<=n;i++)
		eval("ocultarObjeto(clas"+i+");")


	}

function mostrarObjeto(obj) {
	if (ns4) obj.visibility = "show"
	else obj.visibility = "visible"
}


function ocultarObjeto(obj) {
	if (ns4) obj.visibility = "hide"
	else obj.visibility = "hidden"
}


function recalcular() {
	if (ns4) {
		anchoven = window.innerWidth-16;
	}
	if (ie4) {
		anchoven = document.body.clientWidth;
	}
	if ((ns6) && (! ie4)){
		anchoven = window.innerWidth-16;
	}
	menu.left = ((anchoven-135)/2)-187;
	for(i=1;i<=n;i++)
		eval("clas"+i+".left = ((anchoven-380)/2)+65;")
}


function mostrar(n){
	for (i=1;i<=numero_capas;i++)
		eval("ocultarObjeto(clas"+i+")")
	eval("mostrarObjeto(clas"+n+")")
}
