elementoActivo = 'accesoGeneracionK';

window.onload = function()
{
	cargarBarraEstado();
	mostrarLoader();
	redimancionarContenedores();
	agregarEventos();
	$("accesoGeneracionK").onmouseover = function(){}
	
	$('accesoLineaEcologica').onclick = function()
	{
		window.document.location.href = 'esp/index.php?option=com_content&view=article&id=3&Itemid=124';
	}
    
    $('accesoGeneracionK').onclick = function()
	{
		window.document.location.href = 'esp/index.php?option=com_content&view=article&id=6&Itemid=125';
	}
    
    $('accesoLineaEstandar').onclick = function()
	{
		window.document.location.href = 'esp/index.php?option=com_content&view=article&id=1&Itemid=128';
	}
    
    if($('vtnMensaje'))
    {
    	setTimeout("cerrarVentanaMensaje()",2000);
    
    }
}

function cerrarVentanaMensaje()
{    
    new Effect.Fade(
   'vtnMensaje', { 
      from: 1, 
      to: 0,
      duration: 0.5
   });
    
}

window.onresize = function()
{
	mostrarLoader();
	redimancionarContenedores();
}

function cargarDisegno()
{
	
}

function redimancionarContenedores()
{	
	/*
	tamagnoActivo = (document.viewport.getWidth()/2);
	tamagnoInactivo = (document.viewport.getWidth()/4);
	
	$("accesoLineaEcologica").style.height = document.viewport.getHeight() + "px";
	$("accesoGeneracionK").style.height = document.viewport.getHeight() + "px";
	$("accesoLineaEstandar").style.height = document.viewport.getHeight() + "px";
	
	elementos = new Array('accesoLineaEcologica', 'accesoGeneracionK', 'accesoLineaEstandar');
	imagenes = new Array('acceso_linea_ecologica','acceso_generacion_k','acceso_linea_estandar');
	
	for(c=0; c < elementos.length; c++)
	{
		if(elementos[c] == elementoActivo)
		{
			if(elementos[c] == 'accesoGeneracionK')
			{
				$(elementos[c]).style.width = (tamagnoActivo-10) + "px";
			}
			else
			{
				$(elementos[c]).style.width = (tamagnoActivo-5) + "px";
			}
		}
		else
		{
			if(elementos[c] == 'accesoGeneracionK')
			{
				$(elementos[c]).style.width = (tamagnoInactivo-10) + "px";
			}
			else
			{
				$(elementos[c]).style.width = (tamagnoInactivo-5) + "px";
			}
		}
		$(elementos[c]).style.backgroundImage = 'url(img/img_acceso/' + imagenes[c] + '_' + ((parseInt( tamagnoActivo /100))*100) + '.jpg)';
	}	
	*/
    
    tamagnoActivo = (document.viewport.getWidth()/2);
	tamagnoInactivo = (document.viewport.getWidth()/4);
	
	$("accesoLineaEcologica").style.height = document.viewport.getHeight() + "px";
	$("accesoGeneracionK").style.height = document.viewport.getHeight() + "px";
	$("accesoLineaEstandar").style.height = document.viewport.getHeight() + "px";
	
	elementos = new Array('accesoLineaEcologica', 'accesoGeneracionK', 'accesoLineaEstandar');
	imagenes = new Array('acceso_linea_ecologica','acceso_generacion_k','acceso_linea_estandar');
	
	for(c=0; c < elementos.length; c++)
	{
		if(elementos[c] == elementoActivo)
		{
			if(elementos[c] == 'accesoGeneracionK')
			{
				$(elementos[c]).style.width = (tamagnoActivo-10) + "px";
			}
			else
			{
				$(elementos[c]).style.width = (tamagnoActivo-5) + "px";
			}
		}
		else
		{
			if(elementos[c] == 'accesoGeneracionK')
			{
				$(elementos[c]).style.width = (tamagnoInactivo-10) + "px";
			}
			else
			{
				$(elementos[c]).style.width = (tamagnoInactivo-5) + "px";
			}
		}
		$(elementos[c]).style.backgroundImage = 'url(img/img_acceso/' + imagenes[c] + '_' + ((parseInt( document.viewport.getHeight() /100)+1)*100) + '.jpg)';
	}	
    
}

function removerEventos()
{
	$("accesoLineaEcologica").onmouseover = function(){}
	
	$("accesoGeneracionK").onmouseover = function(){}
	
	$("accesoLineaEstandar").onmouseover = function(){}
	
	$("accesoLineaEcologica").onmousemove = function(){}
	
	$("accesoGeneracionK").onmousemove = function(){}
	
	$("accesoLineaEstandar").onmousemove = function(){}
}

function agregarEventos()
{
	$("accesoLineaEcologica").onmouseover = function()
	{
		if (elementoActivo != 'accesoLineaEcologica')
		{
			removerEventos();
			new Effect.Parallel(
			[
			  new Effect.Morph('accesoLineaEcologica', {style: 'width: ' + ((document.viewport.getWidth()/2)-5) + 'px;'}), 
			  new Effect.Morph(elementoActivo, {style: 'width: ' + ((document.viewport.getWidth()/4)-10) + 'px;'}) 
			], 
			{ 
			  duration: 0.6,
			  afterFinish: agregarEventos
			});
			elementoActivo = 'accesoLineaEcologica';
		}
	}
	
	$("accesoGeneracionK").onmouseover = function()
	{
		if (elementoActivo != 'accesoGeneracionK')
		{
			removerEventos();
			new Effect.Parallel(
			[
			  new Effect.Morph('accesoGeneracionK', {style: 'width: ' + ((document.viewport.getWidth()/2)-10) + 'px;'}), 
			  new Effect.Morph(elementoActivo, {style: 'width: ' + ((document.viewport.getWidth()/4)-5) + 'px;'}) 
			], 
			{ 
			  duration: 0.6,
			  afterFinish: agregarEventos
			});
			elementoActivo = 'accesoGeneracionK';
		}
	}
	
	$("accesoLineaEstandar").onmouseover = function()
	{
		if (elementoActivo != 'accesoLineaEstandar')
		{
			removerEventos();
			new Effect.Parallel(
			[
			  new Effect.Morph('accesoLineaEstandar', {style: 'width: ' + ((document.viewport.getWidth()/2)-5) + 'px;'}), 
			  new Effect.Morph(elementoActivo, {style: 'width: ' + ((document.viewport.getWidth()/4)-10) + 'px;'}) 
			], 
			{ 
			  duration: 0.6,
			  afterFinish: agregarEventos
			});
			elementoActivo = 'accesoLineaEstandar';
		}
	}
	
	$("accesoLineaEcologica").onmousemove = function()
	{
		if (elementoActivo != 'accesoLineaEcologica')
		{
			removerEventos();
			new Effect.Parallel(
			[
			  new Effect.Morph('accesoLineaEcologica', {style: 'width: ' + ((document.viewport.getWidth()/2)-5) + 'px;'}), 
			  new Effect.Morph(elementoActivo, {style: 'width: ' + ((document.viewport.getWidth()/4)-10) + 'px;'}) 
			], 
			{ 
			  duration: 0.6,
			  afterFinish: agregarEventos
			});
			elementoActivo = 'accesoLineaEcologica';
		}
	}
	
	$("accesoGeneracionK").onmousemove = function()
	{
		if (elementoActivo != 'accesoGeneracionK')
		{
			removerEventos();
			new Effect.Parallel(
			[
			  new Effect.Morph('accesoGeneracionK', {style: 'width: ' + ((document.viewport.getWidth()/2)-10) + 'px;'}), 
			  new Effect.Morph(elementoActivo, {style: 'width: ' + ((document.viewport.getWidth()/4)-5) + 'px;'}) 
			], 
			{ 
			  duration: 0.6,
			  afterFinish: agregarEventos
			});
			elementoActivo = 'accesoGeneracionK';
		}
	}
	
	$("accesoLineaEstandar").onmousemove = function()
	{
		if (elementoActivo != 'accesoLineaEstandar')
		{
			removerEventos();
			new Effect.Parallel(
			[
			  new Effect.Morph('accesoLineaEstandar', {style: 'width: ' + ((document.viewport.getWidth()/2)-5) + 'px;'}), 
			  new Effect.Morph(elementoActivo, {style: 'width: ' + ((document.viewport.getWidth()/4)-10) + 'px;'}) 
			], 
			{ 
			  duration: 0.6,
			  afterFinish: agregarEventos
			});
			elementoActivo = 'accesoLineaEstandar';
		}
	}
	
}

function mostrarLoader()
{
	new Effect.Appear(
   'vtnModal', { 
      from: 0, 
      to: 1,
      duration: 0.5,
	  afterFinish: temporalizadorCargador
   });
}

function temporalizadorCargador()
{
	setTimeout("ocultarLoader()",2000);
}

function ocultarLoader()
{
	new Effect.Fade(
   'vtnModal', { 
      from: 1, 
      to: 0,
      duration: 0.5
   });
}
