try { console.log('init console... done'); } catch(e) { console = { log: function() {} } }

var app_front = {
  init: function() {
    app_front.activarLiveboxes();
    app_front.activarGaleria();
  },

  activarLiveboxes: function() {
    $$('a.litbox').each(function(el) {
      el.observe('click', function(evento) {
        var elemento = Event.element(evento);
        if (elemento.tagName != "A") elemento = elemento.parentNode;
        new LITBox(elemento.href);
        Event.stop(evento);
      });
    });
  },

  activarGaleria: function() {
    if ($$('ul.carousel-list img')) {
      $$('ul.carousel-list img').each(function(img) {
        img.observe('click', function(e) {
          var new_url = 'http://ventas.redbaluarte.es/do/extranet/recurso?id='+Event.element(e).className;
	        console.log('Url a cargar '+new_url)
          $$('p.image img')[0].src = new_url;
          Event.stop(e);
        });
      });
    }
  }  
}

var promocion_destacada = {
	init: function() {
				
		$$('body#home_page #outstanding_content .content_heading ul li a').each(function(link) {
	      link.observe('click', function(evento) {
			var losers = $$('li.first');
			losers[0].className =" ";
			
			var abuelo = link.parentNode.parentNode;
			abuelo.className += "first";
	      });
	    });
	}
}

var mostrar_login = {
	init: function() {
		e = $('login_link2');
		if (e != null) {
			e.observe('click', function(event){
				Effect.Fade(this);
		  	Effect.BlindDown('login_form');
			});
		}
  }
}

Event.observe(window, 'load', app_front.init);
Event.observe(window, 'load', promocion_destacada.init);
Event.observe(window, 'load', mostrar_login.init);