document.write('<style>#distributiva {visibility:hidden;}</style>');
//document.getElementById('datos_centrales_interior3').style.visibility = 'hidden';

var url_procede = actualizar_vprocede('TL01');
var ow_contratar =	 '&ow=TL011000';
var ow_contratar_li =	 '&ow=TL011100';
var ow_contratar_lb =	 '&ow=TL011200';
var ow_masinfo =	 '&ow=TL012000';
var ow_vermas =	 '&ow=TL013000';

var pest_selec = 2;
if	(getParametro ("pest", this) != null)
	pest_selec = getParametro ("pest", this);

var max = 0; //pestaņas


function inic_html()
{
	redimensionar_contenido();
	max = calcular_max();
	mostrar_telefonia(pest_selec);
}

function redimensionar_contenido()
{
	var idpuesto = 'parte_central';

	var h_opciones_producto = 0;
	var h_oferta_comun = 0;
	var h_nota_aviso = 0;
	var h_ver_lineas = 0;
	var h_precios_distributiva = 0;
	var h_nota_pie = 0;

	for (var icapa in document.getElementById(idpuesto).getElementsByTagName("div"))
	{		
		if (document.getElementById(idpuesto).getElementsByTagName("div")[icapa].className == 'opc_precios_telefonia')
		{
			var idpuesto2 = document.getElementById(idpuesto).getElementsByTagName("div")[icapa].id;

			for (var icapa2 in document.getElementById(idpuesto2).getElementsByTagName("div"))
			{
				if (document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].className == 'opciones_producto precios_adsl')
				{
					var altura = document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].offsetHeight;
					h_opciones_producto = (altura > h_opciones_producto)? altura : h_opciones_producto;	
				}
				
				if (document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].className == 'oferta_comun')
				{
					var altura = document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].offsetHeight;
					h_oferta_comun = (altura > h_oferta_comun)? altura : h_oferta_comun;	
				}

				if (document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].className == 'precios_distributiva')
				{
					var altura = document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].offsetHeight;
					h_precios_distributiva = (altura > h_precios_distributiva)? altura : h_precios_distributiva;	
				}

				if (document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].className == 'nota_pie')
				{
					var altura = document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].offsetHeight;
					h_nota_pie = (altura > h_nota_pie)? altura : h_nota_pie;	
				}
			}
		}
	}

	for (var icapa in document.getElementById(idpuesto).getElementsByTagName("div"))
	{		
		if (document.getElementById(idpuesto).getElementsByTagName("div")[icapa].className == 'opc_precios_telefonia')
		{
			var idpuesto2 = document.getElementById(idpuesto).getElementsByTagName("div")[icapa].id;

			for (var icapa2 in document.getElementById(idpuesto2).getElementsByTagName("div"))
			{
				if (document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].className == 'opciones_producto precios_adsl')
					document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].style.height = h_opciones_producto + 'px';
				
				/*if (document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].className == 'oferta_comun')
					document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].style.height = h_oferta_comun + 'px';*/
			}
		}
	}

	var h_max = 0;
	for (var icapa in document.getElementById(idpuesto).getElementsByTagName("div"))
	{
		if (document.getElementById(idpuesto).getElementsByTagName("div")[icapa].className == 'opc_precios_telefonia')
		{
			var h_aux = document.getElementById(idpuesto).getElementsByTagName("div")[icapa].offsetHeight;
			h_max = (h_max > h_aux) ? h_max : h_aux;

			var idpuesto2 = document.getElementById(idpuesto).getElementsByTagName("div")[icapa].id;
			for (var icapa2 in document.getElementById(idpuesto2).getElementsByTagName("div"))
			{
				if (document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].className == 'precios_distributiva')
					document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].style.height = h_precios_distributiva + 'px';
				if (document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].className == 'nota_pie')
					document.getElementById(idpuesto2).getElementsByTagName("div")[icapa2].style.height = h_nota_pie + 'px';
			}
		}
	}

	/*
	for (var icapa in document.getElementById(idpuesto).getElementsByTagName("div"))
	{
		if (document.getElementById(idpuesto).getElementsByTagName("div")[icapa].className == 'opc_precios_telefonia')
			document.getElementById(idpuesto).getElementsByTagName("div")[icapa].style.height = h_max + 'px';
	}
	*/

	if	((document.getElementById('comparador_telefonos')) && (document.getElementById('precios_telefonos')))
	{
		var h_max_1 = document.getElementById('precios_telefonos').offsetHeight;
		var h_max_2 = document.getElementById('comparador_telefonos').offsetHeight;

		var dif = parseFloat(h_max_1 - h_max_2);
		if	(dif > 0)
		{
			for (var icapa in document.getElementById('comparador_telefonos').getElementsByTagName("div"))
			{
				if (document.getElementById('comparador_telefonos').getElementsByTagName("div")[icapa].className == 'contenido_producto_tel')
					document.getElementById('comparador_telefonos').getElementsByTagName("div")[icapa].style.height = parseFloat(document.getElementById('comparador_telefonos').getElementsByTagName("div")[icapa].offsetHeight + dif) + 'px';
			}
		}
	}


	document.getElementById('distributiva').style.visibility = 'visible';
}

function calcular_max(max)
{
	max = 0;
	for (var icapa in document.getElementById('pestanias').getElementsByTagName("div"))
	{
		if ((document.getElementById('pestanias').getElementsByTagName("div")[icapa].className == 'pestania_on') ||
			(document.getElementById('pestanias').getElementsByTagName("div")[icapa].className == 'pestania_off'))
		{
			max += 1;
		}
	}
	return max;
}

function mostrar_telefonia(opc)
{	
	for	(var i=0; i<max; i++)
	{
		if	((i+1) == opc)
			document.getElementById('pestania_' + (i+1)).className = 'pestania_on'
		else
			document.getElementById('pestania_' + (i+1)).className = 'pestania_off';
	}

	for (var icapa in document.getElementsByTagName("div"))
	{
		if (document.getElementsByTagName("div")[icapa].className == 'opc_precios_telefonia')
		{
			document.getElementsByTagName("div")[icapa].style.display = 'none';
		}
	}
	document.getElementById("opc_precios_telefonia_" + opc).style.display = 'block';

	switch (opc)
	{
		case 1: document.getElementById("pestana_pulsada").innerHTML = '<img src="/on/io/es/distributivas/telefonia/estadistica-telefonia.html?ow=TLp1e">';break;
		case 2: document.getElementById("pestana_pulsada").innerHTML = '<img src="/on/io/es/distributivas/telefonia/estadistica-telefonia.html?ow=TLp2e">';break;
		case 3: document.getElementById("pestana_pulsada").innerHTML = '<img src="/on/io/es/distributivas/telefonia/estadistica-telefonia.html?ow=TLp3e">';break;
		case 4: document.getElementById("pestana_pulsada").innerHTML = '<img src="/on/io/es/distributivas/telefonia/estadistica-telefonia.html?ow=TLp4e">';break;
	}	
}
