﻿// Se ejecuta cuando se carga la página maestra
function CargarPagina()
{	
	// Asocio un handler al evento onload (que sucede cuando se ha cargado la página)
	window.onload = EstirarPanelLateral;
	PonerEfectoRollOverMenu();
}


/* Esta funcion iguala la altura del panel lateral al div más alto que se encuentre dentro 
del contenido y que tenga un atributo name='contenido' */

function EstirarPanelLateral()
{
	var Contenido = document.getElementById('contenido');
	var PanelLateral = document.getElementById('restoPanel');
	var maximaAltura = 0;
	
	if (Contenido.offsetHeight < PanelLateral.offsetHeight)
	{
		maximaAltura = PanelLateral.offsetHeight;
	}
	else
	{
		maximaAltura = Contenido.offsetHeight;
	}
	document.getElementById('restoPanel').style.height = Math.max((maximaAltura+12),300) + "px";
}

// Funcion para rollover del menu (Funciones en MooTools.js))
function PonerEfectoRollOverMenu(){
	var listaElementosMenu = $$('#menu a');
	var listaElementosMenuSecundario = $$('#menuInferior a');
	
	listaElementosMenu.each(function(element) {var fx = new Fx.Styles(element, {duration:500, wait:false});
		element.addEvent('mouseenter', function(){
			fx.start({'color':'#FFF'});
		});
		element.addEvent('mouseleave', function(){
			fx.start({'color':'#999'});
		});
	});
		
	listaElementosMenuSecundario.each(function(element) {var fx = new Fx.Styles(element, {duration:300, wait:false});
		element.addEvent('mouseenter', function(){
			fx.start({'color':'#CCC'});
		});
		element.addEvent('mouseleave', function(){
			fx.start({'color':'#222'});
		});
	});	
}

function PonerEfectoDegradadoFotos(){
	var listaFotos = $$('.fotosTransicion img');
	listaFotos.each(function(element) { 
		var fx = new Fx.Styles(element, {duration:500, wait:false});
		
		element.addEvent('mouseenter', function(){
			fx.start({'opacity':.2});
		});
	 
		element.addEvent('mouseleave', function(){
			fx.start({'opacity':1});
		});
	});
}


// Funcion para efecto de degradado
function PonerEfectoDegradadoFotosModa(){
	var listaFotos = $$('.fotosTransicion img');
	listaFotos.each(function(element) { 
		var fx = new Fx.Styles(element, {duration:500, wait:false});
				
		element.addEvent('mouseenter', function(){
			fx.start({'opacity':.2});
		});
	 
		element.addEvent('mouseleave', function(){
			if (element.className != 'seleccionada')
			{
				fx.start({'opacity':1});
			}
		});
		
		element.addEvent('click', function(){
			QuitarEfectoDegradadoFotos(element);
			element.className = 'seleccionada';			
		});
	});
}

function QuitarEfectoDegradadoFotos(elemento)
{
	var listaFotos = $$('.fotosTransicion img');
	listaFotos.each(function(element) {
		if (element != elemento)
		{
			var fx = new Fx.Styles(element, {duration:50, wait:false});
			element.className = '';
			fx.start({'opacity':1});
		}
	});
}


function PonerEfectoAmpliarEnFotos(){
    var listaFotos = $$('td.ampliar');
    listaFotos.each(function(element) { 
        var fx = new Fx.Styles(element, {duration:300, wait:false});
     
        element.addEvent('mouseenter', function(){
	        fx.start({'opacity':.2});
        });
     
        element.addEvent('mouseleave', function(){
	        fx.start({'opacity':1});
        });
    });
}



function CapturarEnter(btn,event)
{
    if (document.all)
    {
        if (event.keyCode == 13)
        {
            event.returnValue=false;
            event.cancel=true;
            document.getElementById("ctl00_cphContenido_lkbBuscarTexto").click();
        }
    }
    else if (document.getElementById)
    {
        if (event.keyCode == 13)
        {
            event.returnValue=false;
            event.cancel=true;
            WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cphContenido$lkbBuscarTexto", "", true, "Busqueda", "", false, true))
        }
    }
    else if (document.layers)
    {
        if (event.which==13)
        {
            event.returnValue=false;
            event.cancel=true;
            btn.click();
        }
    }
}