﻿document.getElementsByClassName = function(cl, sTagName) {  
	var retnode = [];  
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName((sTagName===""||sTagName===null)?"*":sTagName);  
	for (var i = 0; i < elem.length; i++) {  
		var classes = elem[i].className;  
		if (myclass.test(classes)) retnode.push(elem[i]);  
	}  
	return retnode;  
}; 

function abrirPop(destino,anchura,altura,barras){
	var ancho, alto, posx, posy, ventana;
	ancho = anchura + 50;
	alto = altura + 100;
	posx = (screen.width-ancho)/2;
	posy = (screen.height-alto)/2;
	ventana = window.open(destino,"pop_up","width=" + ancho + ",height=" + alto + ",top=" + posx + ",left=" + posy + ",scrollbars=" + barras + ",statusbar=" + barras +",menubar=" + barras + ",resizable=" + barras + ",toolbar=" + barras + ",location=" + barras);
}
function popsAccesibles(){
	if(!document.getElementsByTagName) return false;
	
	mapaImg = document.getElementById("mapa");
	if(mapaImg){
		areas = mapaImg.getElementsByTagName("area");
		areas_num = areas.length;
		for(var i=0;i<areas_num;i++){
			areas[i].onclick = function(){
				abrirPop(this.getAttribute("href"),450,200);
				return false;
			}
		}
	}

	enlaces = document.getElementsByTagName("a");
	for(i=0;i<enlaces.length;i++){
		title = enlaces[i].getAttribute("title");
		destino = enlaces[i].getAttribute("href");
		if(title && title.indexOf("Nueva ventana") > -1){
			enlaces[i].onclick = function(){
				spanmedidas = this.getElementsByTagName("span")[0];
				if(spanmedidas){
					arrMedidas = spanmedidas.firstChild.nodeValue.split("x");
					abrirPop(this.getAttribute("href"),parseInt(arrMedidas[0]),parseInt(arrMedidas[1]));
					return false;
				}
				imageninterior = this.getElementsByTagName("img")[0];
				if(imageninterior){
					abrirPop(this.getAttribute("href"),this.ancho,this.alto);
					return false;
				}
			}
		}
		if(title && title.indexOf("Nueva_ventana") > -1){
			enlaces[i].onclick = function(){
				abrirPop(this.getAttribute("href"),750,400,"yes");
				return false;
			}
		}
	}
}

function tablasGRI(){
	tablasgri = document.getElementsByClassName("indicador_gri","table")[0];
	if(!tablasgri) return false;

	itemsgri = document.getElementsByClassName("tr_item","tr");
	for(i=0;i<itemsgri.length;i++){
		itemsgri[i].className += "tr_item gri_ocultar";
	}

	spansgri = tablasgri.getElementsByTagName("span");
	for(i=0;i<spansgri.length;i++){
		if(spansgri[i].parentNode.parentNode.className.indexOf("tr_item") == -1){
			spansgri[i].style.cursor = "pointer";
			spansgri[i].onclick = function(){
				trs_arr = tablasgri.rows;
				trpadre = this.parentNode.parentNode;
				var rowIndexPadre = trpadre.rowIndex;
				var totalRows = tablasgri.rows.length;
				rowIndexPadre++;
				while(trs_arr[rowIndexPadre].className.indexOf("tr_item") > -1)
				{
					trs_arr[rowIndexPadre].className = trs_arr[rowIndexPadre].className=="tr_item gri_mostrar" ? "tr_item gri_ocultar" : "tr_item gri_mostrar";
					rowIndexPadre++;
					if(rowIndexPadre==totalRows)
						break;
				}
				var total_trs = trs_arr.length;
			}
		}
	}

	var a_gri = tablasgri.getElementsByTagName("a");
	var a_gri_long = a_gri.length;
	var posiciones = [];
	for(var i=0;i<a_gri_long;i++){
		var enlace = a_gri[i];
		if(enlace.href.indexOf("#") > -1){
			posiciones.push(enlace);
		}
	}

	if(posiciones.length>0)
	{
		var totalPosiciones = posiciones.length;
		for(var j=totalPosiciones-1;j>=0;j--)
		{
			var parrafo = document.createElement("p");
			var enlace = posiciones[j];
			var a_texto = enlace.firstChild.nodeValue;
			a_texto = a_texto.replace("CO2", "CO<sub>2</sub>");
			a_texto = a_texto.replace("SO2", "SO<sub>2</sub>");
			a_texto = a_texto.replace("SOx", "SO<sub>x</sub>");
			a_texto = a_texto.replace("N2O", "N<sub>2</sub>O");
			a_texto = a_texto.replace("NOX", "NO<sub>X</sub>");
			a_texto = a_texto.replace("1st", "1<sup>st</sup>");
			a_texto = a_texto.replace("2nd", "2<sup>nd</sup>");
			var a_padre = enlace.parentNode;
			haySpan = a_padre.getElementsByTagName("span")[0];
			if(haySpan) a_padre.removeChild(a_padre.getElementsByTagName("span")[0]);
			parrafo.innerHTML = a_texto;
			a_padre.removeChild(enlace);
			a_padre.appendChild(parrafo);
			if(haySpan) a_padre.appendChild(haySpan);
		}
	}
}

function galeriaFotos(){
	fotos_contenedor = document.getElementById("fotos");
	if(!fotos_contenedor) return false;
	
	fotos_div = document.createElement("div");
	fotos_p1 = document.createElement("p");
	fotos_a1 = document.createElement("a");
	fotos_p1img = document.createElement("img");
	fotos_p2 = document.createElement("p");
	fotos_a1.setAttribute("href","../pops/0721_pop.html");
	fotos_a1.ancho = 600;
	fotos_a1.alto = 400;
	fotos_a1.setAttribute("title","Nueva ventana");
	fotos_p1img.setAttribute("src","../../../imgs/interiores/fotografias/miniaturas/54_movimiento.jpg");
	fotos_p1img.setAttribute("width","648");
	fotos_p1img.setAttribute("height","300");
	fotos_p1img.setAttribute("alt","");

	var idioma = document.documentElement.lang;
	if(idioma == "es"){
		fotos_p2.appendChild(document.createTextNode("Movimiento - Javier Maeso Díaz - Oficina 2978"));
	}else{
		fotos_p2.appendChild(document.createTextNode("Movement - Javier Maeso Díaz - Branch 2978"));
	}



	fotos_p2.className = "texto";
	fotos_a1.appendChild(fotos_p1img);
	fotos_p1.appendChild(fotos_a1);
	fotos_div.appendChild(fotos_p1);
	fotos_div.appendChild(fotos_p2);

	fotos_ul = fotos_contenedor.getElementsByTagName("ul")[0];
	enlaces_ul = fotos_ul.getElementsByTagName("a");
	for(i=0;i<enlaces_ul.length;i++){
		enlaces_ul[i].onclick = function(){
			imgint = this.firstChild;
			destinoinicial = imgint.getAttribute("src");
			destinoprevio = destinoinicial.substring(0,destinoinicial.length-7);
			destinoprevio += ".jpg"
			fotos_p1img.setAttribute("src",destinoprevio);
			destinopop = this.getAttribute("href");
			fotos_p2.firstChild.nodeValue = this.firstChild.alt;
			fotos_a1.setAttribute("href",destinopop);

			span_texto = this.lastChild.firstChild.nodeValue;
			span_medida = span_texto.split("x");
			fotos_a1.ancho = parseInt(span_medida[0]);
			fotos_a1.alto = parseInt(span_medida[1]);

			imgint_srcnueva = destinoinicial.substring(0,destinoinicial.length-7);
			imgint_srcnueva += "_cl.jpg";
			imgint.setAttribute("src",imgint_srcnueva);

			return false;

		}
		enlaces_ul[i].onmouseover = function(){
			imgint = this.firstChild;
			destinoinicial = imgint.getAttribute("src");

			imgint_srcnueva = destinoinicial.substring(0,destinoinicial.length-7);
			imgint_srcnueva += "_cl.jpg";
			imgint.setAttribute("src",imgint_srcnueva);

		}
		enlaces_ul[i].onmouseout = function(){
			imgint.setAttribute("src",destinoinicial);
		}
	}

	fotos_contenedor.insertBefore(fotos_div,fotos_ul);
}

function popsGri(){
	var docgri = document.getElementById("gri");
	if(!docgri) return;
	var enlaces_gri = docgri.getElementsByTagName("a");
	enlaces_gri_long = enlaces_gri.length;
	for(i=0;i<enlaces_gri_long;i++){
		if(enlaces_gri[i].target=="_blank"){
			enlaces_gri[i].onclick = function(){
				window.open(this.href,"nuevodoc");
				return false;
			}
		}
	}
}

function selectGri(){
	var docgri = document.getElementById("gri");
	if(!docgri) return;

	/*Div y h3 con label*/
	divselec = document.createElement("div");
	divselec.setAttribute("id","seleccionador");
	h3selec = document.createElement("h3");
	labelselec = document.createElement("label");
	labelselec.setAttribute("for","indicador");

	var idioma = document.documentElement.lang;
	if(idioma == "es"){
		labeltxt = document.createTextNode("Seleccione indicador");
	}else{
		labeltxt = document.createTextNode("Select indicator");
	}

	labelselec.appendChild(labeltxt);
	h3selec.appendChild(labelselec);
	divselec.appendChild(h3selec);

	/*Select*/
	comboselec = document.createElement("select");
	comboselec.setAttribute("name","indicador");
	comboselec.setAttribute("id","indicador");

	var arrOpts = [
			   {texto:labeltxt.nodeValue,valor:"0"},
   			   {texto:"1.1",valor:"../12_gri/1211_estrategia.html"},
   			   {texto:"1.2",valor:"../12_gri/1211_estrategia.html"},
			   {texto:"2.1",valor:"../12_gri/1212_perfil.html"},
   			   {texto:"2.2",valor:"../12_gri/1212_perfil.html"},
   			   {texto:"2.3",valor:"../12_gri/1212_perfil.html"},
			   {texto:"2.4",valor:"../12_gri/1212_perfil.html"},
   			   {texto:"2.5",valor:"../12_gri/1212_perfil.html"},
   			   {texto:"2.6",valor:"../12_gri/1212_perfil.html"},
			   {texto:"2.7",valor:"../12_gri/1212_perfil.html"},
   			   {texto:"2.8",valor:"../12_gri/1212_perfil.html"},
   			   {texto:"2.9",valor:"../12_gri/1212_perfil.html"},
			   {texto:"3.1",valor:"../12_gri/12131_perfil.html"},
   			   {texto:"3.2",valor:"../12_gri/12131_perfil.html"},
   			   {texto:"3.3",valor:"../12_gri/12131_perfil.html"},
			   {texto:"3.4",valor:"../12_gri/12131_perfil.html"},
   			   {texto:"3.5",valor:"../12_gri/12132_alcance.html"},
   			   {texto:"3.6",valor:"../12_gri/12132_alcance.html"},
			   {texto:"3.7",valor:"../12_gri/12132_alcance.html"},
   			   {texto:"3.8",valor:"../12_gri/12132_alcance.html"},
   			   {texto:"3.9",valor:"../12_gri/12132_alcance.html"},
			   {texto:"3.10",valor:"../12_gri/12132_alcance.html"},
   			   {texto:"3.11",valor:"../12_gri/12132_alcance.html"},
   			   {texto:"3.12",valor:"../12_gri/12133_indice.html"},
			   {texto:"3.13",valor:"../12_gri/12134_verificacion.html"},
   			   {texto:"4.1",valor:"../12_gri/12141_gobierno.html"},
   			   {texto:"4.2",valor:"../12_gri/12141_gobierno.html"},
			   {texto:"4.3",valor:"../12_gri/12141_gobierno.html"},
   			   {texto:"4.4",valor:"../12_gri/12141_gobierno.html"},
   			   {texto:"4.5",valor:"../12_gri/12141_gobierno.html"},
			   {texto:"4.6",valor:"../12_gri/12141_gobierno.html"},
   			   {texto:"4.7",valor:"../12_gri/12141_gobierno.html"},
   			   {texto:"4.8",valor:"../12_gri/12141_gobierno.html"},
			   {texto:"4.9",valor:"../12_gri/12141_gobierno.html"},
   			   {texto:"4.10",valor:"../12_gri/12141_gobierno.html"},
   			   {texto:"4.11",valor:"../12_gri/12142_compromisos.html"},
			   {texto:"4.12",valor:"../12_gri/12142_compromisos.html"},
   			   {texto:"4.13",valor:"../12_gri/12142_compromisos.html"},
   			   {texto:"4.14",valor:"../12_gri/12143_participacion.html"},
			   {texto:"4.15",valor:"../12_gri/12143_participacion.html"},
   			   {texto:"4.16",valor:"../12_gri/12143_participacion.html"},
   			   {texto:"4.17",valor:"../12_gri/12143_participacion.html"},
			   {texto:"EC0",valor:"../12_gri/1220_enfoques.html"},
   			   {texto:"EC1",valor:"../12_gri/1221_economico.html"},
   			   {texto:"EC2",valor:"../12_gri/1221_economico.html"},
			   {texto:"EC3",valor:"../12_gri/1221_economico.html"},
   			   {texto:"EC4",valor:"../12_gri/1221_economico.html"},
   			   {texto:"EC5",valor:"../12_gri/1222_presencia.html"},
			   {texto:"EC6",valor:"../12_gri/1222_presencia.html"},
   			   {texto:"EC7",valor:"../12_gri/1222_presencia.html"},
   			   {texto:"EC8",valor:"../12_gri/1223_impactos.html"},
			   {texto:"EC9",valor:"../12_gri/1223_impactos.html"},
   			   {texto:"EN0",valor:"../12_gri/1230_enfoques.html"},
   			   {texto:"EN1",valor:"../12_gri/1231_materiales.html"},
			   {texto:"EN2",valor:"../12_gri/1231_materiales.html"},
   			   {texto:"EN3",valor:"../12_gri/1232_energia.html"},
   			   {texto:"EN4",valor:"../12_gri/1232_energia.html"},
			   {texto:"EN5",valor:"../12_gri/1232_energia.html"},
   			   {texto:"EN6",valor:"../12_gri/1232_energia.html"},
   			   {texto:"EN7",valor:"../12_gri/1232_energia.html"},
			   {texto:"EN8",valor:"../12_gri/1233_agua.html"},
   			   {texto:"EN9",valor:"../12_gri/1233_agua.html"},
   			   {texto:"EN10",valor:"../12_gri/1233_agua.html"},
			   {texto:"EN11",valor:"../12_gri/1234_bio.html"},
   			   {texto:"EN12",valor:"../12_gri/1234_bio.html"},
   			   {texto:"EN13",valor:"../12_gri/1234_bio.html"},
			   {texto:"EN14",valor:"../12_gri/1234_bio.html"},
   			   {texto:"EN15",valor:"../12_gri/1234_bio.html"},
   			   {texto:"EN16",valor:"../12_gri/1235_emisiones.html"},
   			   {texto:"EN17",valor:"../12_gri/1235_emisiones.html"},
			   {texto:"EN18",valor:"../12_gri/1235_emisiones.html"},
   			   {texto:"EN19",valor:"../12_gri/1235_emisiones.html"},
   			   {texto:"EN20",valor:"../12_gri/1235_emisiones.html"},
			   {texto:"EN21",valor:"../12_gri/1235_emisiones.html"},
   			   {texto:"EN22",valor:"../12_gri/1235_emisiones.html"},
   			   {texto:"EN23",valor:"../12_gri/1235_emisiones.html"},
			   {texto:"EN24",valor:"../12_gri/1235_emisiones.html"},
   			   {texto:"EN25",valor:"../12_gri/1235_emisiones.html"},
   			   {texto:"EN26",valor:"../12_gri/1236_productos.html"},
			   {texto:"EN27",valor:"../12_gri/1236_productos.html"},
   			   {texto:"EN28",valor:"../12_gri/1237_cumplimiento.html"},
   			   {texto:"EN29",valor:"../12_gri/1238_transporte.html"},
			   {texto:"EN30",valor:"../12_gri/1239_general.html"},
			   {texto:"LA0",valor:"../12_gri/12410_enfoques.html"},
			   {texto:"LA1",valor:"../12_gri/12411_empleo.html"},
			   {texto:"LA2",valor:"../12_gri/12411_empleo.html"},
			   {texto:"LA3",valor:"../12_gri/12411_empleo.html"},
			   {texto:"LA4",valor:"../12_gri/12412_relaciones.html"},
			   {texto:"LA5",valor:"../12_gri/12412_relaciones.html"},
			   {texto:"LA6",valor:"../12_gri/12413_salud.html"},
			   {texto:"LA7",valor:"../12_gri/12413_salud.html"},
			   {texto:"LA8",valor:"../12_gri/12413_salud.html"},
			   {texto:"LA9",valor:"../12_gri/12413_salud.html"},
			   {texto:"LA10",valor:"../12_gri/12414_formacion.html"},
			   {texto:"LA11",valor:"../12_gri/12414_formacion.html"},
			   {texto:"LA12",valor:"../12_gri/12414_formacion.html"},
			   {texto:"LA13",valor:"../12_gri/12415_diversidad.html"},
			   {texto:"LA14",valor:"../12_gri/12415_diversidad.html"},
			   {texto:"HR0",valor:"../12_gri/12420_enfoques.html"},
			   {texto:"HR1",valor:"../12_gri/12421_practicas.html"},
			   {texto:"HR2",valor:"../12_gri/12421_practicas.html"},
			   {texto:"HR3",valor:"../12_gri/12421_practicas.html"},
			   {texto:"HR4",valor:"../12_gri/12422_nodiscriminacion.html"},
			   {texto:"HR5",valor:"../12_gri/12423_libertad.html"},
			   {texto:"HR6",valor:"../12_gri/12424_explotacion.html"},
			   {texto:"HR7",valor:"../12_gri/12425_trabajos.html"},
			   {texto:"HR8",valor:"../12_gri/12426_seguridad.html"},
			   {texto:"HR9",valor:"../12_gri/12427_indigenas.html"},
			   {texto:"SO0",valor:"../12_gri/12430_enfoques.html"},
			   {texto:"SO1",valor:"../12_gri/12431_comunidad.html"},
			   {texto:"SO2",valor:"../12_gri/12432_corrupcion.html"},
			   {texto:"SO3",valor:"../12_gri/12432_corrupcion.html"},
			   {texto:"SO4",valor:"../12_gri/12432_corrupcion.html"},
			   {texto:"SO5",valor:"../12_gri/12433_politica.html"},
			   {texto:"SO6",valor:"../12_gri/12433_politica.html"},
			   {texto:"SO7",valor:"../12_gri/12434_comportamiento.html"},
			   {texto:"SO8",valor:"../12_gri/12435_cumplimiento.html"},
			   {texto:"PR0",valor:"../12_gri/12440_enfoques.html"},
			   {texto:"PR1",valor:"../12_gri/12441_salud.html"},
			   {texto:"PR2",valor:"../12_gri/12441_salud.html"},
			   {texto:"PR3",valor:"../12_gri/12442_etiquetado.html"},
			   {texto:"PR4",valor:"../12_gri/12442_etiquetado.html"},
			   {texto:"PR5",valor:"../12_gri/12442_etiquetado.html"},
			   {texto:"PR6",valor:"../12_gri/12443_comunicaciones.html"},
			   {texto:"PR7",valor:"../12_gri/12443_comunicaciones.html"},
			   {texto:"PR8",valor:"../12_gri/12444_privacidad.html"},
			   {texto:"PR9",valor:"../12_gri/12445_cumplimiento.html"},
			   {texto:"RSC1",valor:"../12_gri/1251_gestion.html"},
			   {texto:"RSC2",valor:"../12_gri/1251_gestion.html"},
			   {texto:"RSC3",valor:"../12_gri/1251_gestion.html"},
			   {texto:"RSC4",valor:"../12_gri/1251_gestion.html"},
			   {texto:"RSC5",valor:"../12_gri/1251_gestion.html"},
			   {texto:"RSC6",valor:"../12_gri/1251_gestion.html"},
			   {texto:"INT1",valor:"../12_gri/1252_interno.html"},
			   {texto:"INT2",valor:"../12_gri/1252_interno.html"},
			   {texto:"INT3",valor:"../12_gri/1252_interno.html"},
			   {texto:"INT4",valor:"../12_gri/1252_interno.html"},
			   {texto:"INT5",valor:"../12_gri/1252_interno.html"},
			   {texto:"INT6",valor:"../12_gri/1252_interno.html"},
			   {texto:"INT7",valor:"../12_gri/1252_interno.html"},
			   {texto:"SOC1",valor:"../12_gri/1253_sociedad.html"},
			   {texto:"SOC2",valor:"../12_gri/1253_sociedad.html"},
			   {texto:"SUP1",valor:"../12_gri/1254_proveedores.html"},
			   {texto:"RB1",valor:"../12_gri/1255_minorista.html"},
			   {texto:"RB2",valor:"../12_gri/1255_minorista.html"},
			   {texto:"RB3",valor:"../12_gri/1255_minorista.html"},
			   {texto:"IB1",valor:"../12_gri/1256_inversion.html"},
			   {texto:"IB2",valor:"../12_gri/1256_inversion.html"},
			   {texto:"IB3",valor:"../12_gri/1256_inversion.html"},
			   {texto:"AM1",valor:"../12_gri/1257_activos.html"},
			   {texto:"AM2",valor:"../12_gri/1257_activos.html"},
			   {texto:"AM3",valor:"../12_gri/1257_activos.html"},
			   {texto:"INS1",valor:"../12_gri/1258_seguros.html"},
			   {texto:"INS2",valor:"../12_gri/1258_seguros.html"},
			   {texto:"INS3",valor:"../12_gri/1258_seguros.html"},
			   {texto:"INS4",valor:"../12_gri/1258_seguros.html"}
];

	var arrOpts_length = arrOpts.length;
	for(var i=0;i<arrOpts_length;i++){
		var opt = document.createElement("option");
		opt.setAttribute("value",arrOpts[i].valor);
		opt.innerHTML = arrOpts[i].texto;
		comboselec.appendChild(opt);
	}

	comboselec.onchange = function(){ if(this.value != 0 ) window.location = this.value;}
	divselec.appendChild(comboselec);

	var divpreambulo = document.getElementById("preambulo");
	if(!divpreambulo) return;
	divpreambulo.appendChild(divselec);

}

function ultarjetas(){
	var tarjetas = document.getElementById("tarjetas");
	if(!tarjetas) return;
	var tarjetas_a = tarjetas.getElementsByTagName("a");
	var num_enlaces = tarjetas_a.length;
	for(var i=0;i<num_enlaces;i++){
		tarjetas_a[i].onclick = function(){
			abrirPop(this.href, 450, 300);
			return false;
		}
	}
}

function insertarPico(){
	divs = document.getElementsByTagName("div");
	divs_total = divs.length;
	for(var i=0;i<divs_total;i++){
		div_actual = divs[i];
		if(div_actual.className.indexOf("menu_local") > -1){
			elementos = div_actual.getElementsByTagName("li");
			elementos_total = elementos.length;
			for(var j=0;j<elementos_total;j++){
				elemento_actual = elementos[j];
				if(elemento_actual.className.indexOf("actual") > -1){
					spanTag = document.createElement("span");
					elemento_actual.appendChild(spanTag);
					break;
				}
			}
			break;
		}
	}
}
function ocultarCanales(){
	var canalesInfo = document.getElementsByClassName("dvcanales","div");
	var canalesInfo_num = canalesInfo.length;
	for(var i = 0;i<canalesInfo_num;i++){
		canalesInfo[i].style.position = "absolute";
		canalesInfo[i].className = "dvcanales ocultar_tipo2";
	}	
}
function canales(){
	//Preparamos botones de cerrar
	var canales_p = document.getElementsByClassName("cerrar","p");
	var canales_p_num = canales_p.length;
	for(var i=0;i<canales_p_num;i++){
		var canales_a = canales_p[i].firstChild;
		canales_a.onclick = function(){
			var contenedor = this.parentNode.parentNode;
			contenedor.className = "dvcanales ocultar_tipo2";
			return false;
		}
	}
	//Ocultar canales
	ocultarCanales();
	//Mostrar/ocultar cada info de los canales
	var canales = document.getElementsByClassName("canal","div");
	var canales_num = canales.length;
	for(var i = 0;i<canales_num;i++){
		var enlaces = canales[i].getElementsByTagName("a");
		var enlaces_num = enlaces.length;
		for(var j = 0;j<enlaces_num;j++){
			enlaces[j].onclick = function(e) {
				//Detectamos posicion del raton
				if (!e) var e = window.event;
				var posx = 0;
				var posy = 0;
				if (!e) var e = window.event;
				if (e.pageX || e.pageY) 	{
					posx = e.pageX;
					posy = e.pageY;
				}
				else if (e.clientX || e.clientY) 	{
					posx = e.clientX + document.body.scrollLeft
						+ document.documentElement.scrollLeft;
					posy = e.clientY + document.body.scrollTop
						+ document.documentElement.scrollTop;
				}
				posx = (posx-300) + "px";
				posy = (posy+25) + "px";
				//Posicionamos el elemento
				ocultarCanales();
				//this.parentNode.style.background = "url(../../imgs/interiores/canales_item_over.gif) 0px 4px no-repeat";
				titulo = this.href.substring(this.href.indexOf("#")+1);
				if(titulo=="sociedad10"){
					posx = "110px";
				}

				elemento = document.getElementById(titulo);

				if(elemento){
					if(elemento.className == "dvcanales ocultar_tipo2"){
						elemento.className = "dvcanales";
						elemento.style.top = posy;
						elemento.style.left = posx;
					}else{
						elemento.className = "dvcanales ocultar_tipo2";
					}
				}
				return false;
			}
		}
	}

}

function bloques_dependientes(){
	var idioma = document.documentElement.lang;
	if(idioma == "es"){
		texto = "Plegar";
		texto2 = "Desplegar";
	}else{
		texto = "Fold";
		texto2 = "Unfold";
	}
	var bloques = document.getElementsByClassName("bloque","div");
	var bloques_num = bloques.length;
	for(var i=0;i<bloques_num;i++){
		bloques[i].style.height = "134px";
		bloques[i].style.overflow = "hidden";
	}
	for(var i=0;i<bloques_num;i++){
		var enlace = bloques[i].getElementsByTagName("a")[0];
		if(!enlace) continue;
		enlace.onclick = function(){
			var divpadre = this.parentNode.parentNode;
			var alto = divpadre.style.height;
			for(var j=0;j<bloques_num;j++){
				if(bloques[j]==divpadre){
					if(document.all){
						if(alto != "1%"){
							divpadre.style.height = "1%";
							divpadre.style.overflow = "visible";
							this.style.background = "black url(../../../imgs/interiores/plegar.gif) 55px 5px no-repeat";
							this.firstChild.nodeValue = texto;
						}else{
							divpadre.style.height = "134px";
							divpadre.style.overflow = "hidden";
							this.style.background = "#007611 url(../../../imgs/interiores/desplegar.gif) 75px 5px no-repeat";
							this.firstChild.nodeValue = texto2;
						}
					}else{
						if(alto != "auto"){
							divpadre.style.height = "auto";
							divpadre.style.overflow = "visible";
							this.style.background = "black url(../../../imgs/interiores/plegar.gif) 55px 5px no-repeat";
							this.firstChild.nodeValue = texto;
						}else{
							divpadre.style.height = "134px";
							divpadre.style.overflow = "hidden";
							this.style.background = "#007611 url(../../../imgs/interiores/desplegar.gif) 75px 5px no-repeat";
							this.firstChild.nodeValue = texto2;
						}
					}
				}else{
					bloques[j].style.height = "134px";
					bloques[j].style.overflow = "hidden";
					enlaceInt = bloques[j].getElementsByTagName("a")[0];
					if(!enlaceInt) continue;
					enlaceInt.style.background = "#007611 url(../../../imgs/interiores/desplegar.gif) 75px 5px no-repeat";
					enlaceInt.firstChild.nodeValue = texto2;
				}
			}
		return false;
		}
	}
}

function subhomes(){
	var div_pleca,div_contenido;
	div_pleca = document.getElementById("pleca");
	div_pleca.style.position = "absolute";
	div_pleca.style.top = "80px";
	div_pleca.style.left = "0px";
	div_pleca.style.width = "500px";
	div_pleca.style.height = "1800px";
	div_pleca.style.background = "#ffffff";
	div_contenido = document.getElementById("contenido");
	div_contenido.style.position = "absolute";
	div_contenido.style.left = "492px";
	div_contenido.style.width = "290px";
}



function moverContenido(){
	var cont,enc1,div_pleca,cantidad,xActual,anchoActual,marginActual,distanciaActual;
	cont = document.getElementById("contenido");
	enc1 = document.getElementsByTagName("h1")[0];
	div_pleca = document.getElementById("pleca");
	enc1.style.marginLeft = "0px"
	cont.style.left = "492px";
	cont.style.width = "290px";
	cont.style.width = "290px";
	cantidad = 29;
	setInterval(function(){
		if(parseInt(cont.style.left) > 242){
			xActual = parseInt(cont.style.left) - cantidad;
			anchoActual = parseInt(cont.style.width) + cantidad;
			marginActual = parseInt(enc1.style.marginLeft) + 10;
			distanciaActual = parseInt(div_pleca.style.left) + 67;
			cont.style.left = xActual + "px";
			cont.style.width = anchoActual + "px";
			enc1.style.marginLeft = marginActual + "px";
			div_pleca.style.left = distanciaActual + "px";
			cont.style.overflow = "visible";
		}
	},40);
}


window.onload = function(){
	var cuerpo = document.getElementsByTagName("body")[0];
	var clase = cuerpo.className;
	var hayprehome = clase.indexOf("prehome");
	if(hayprehome > -1){
		cargarSWF();
		subhomes();
	}
	if(clase=="home") cargarSWF();
	galeriaFotos();
	tablasGRI();
	popsAccesibles();
	popsGri();
	selectGri();
	ultarjetas();
	insertarPico();
	canales();
	bloques_dependientes();
}