/**
 * @author Ontecnia Media Networks S.L.
 * @copyright 2010-2011
 */

$(document).ready(function() {
	ImageGallery.init();
});

ImageGallery = {
	images: [],
	links: [],
	thumbnails: [],
	init: function () {
		// encontrar todas las imágenes y enlaces
		this.images			= $('div.slideshow img');
		this.thumbnails	= $('div.miniatura .borde');
		this.links			= $('div.miniatura .borde > a');
		
		// asociar eventos
		this.links.each(function (index) {
			$(this).click({index:index}, ImageGallery.link_onclick);
		});
	},
	link_onclick: function (e) {
		var i = e.data.index;
		
		ImageGallery.links.each(function (index, element) {
			ImageGallery.thumbnails[index].style.display	= (i == index) ? 'none' : '';
			ImageGallery.images[index].style.display 			= (i != index) ? 'none' : '';
		});
		
		e.preventDefault();
	}
};
