// JavaScript thumbshower - based on mootools 1.2


var Thumbshower = new Class({
    container: null,
	bigimg: null,
	bigimgcontainer: null,
	loadfirst: false,
	
	initialize: function(container, bigimg, bigimgcontainer, loadfirst) {
		
		this.container = $(container);
		this.bigimg = $(bigimg);
		this.bigimgcontainer = $(bigimgcontainer);
		if(this.container == null || this.bigimg == null) {
			return false;
		}
		this.loadfirst = loadfirst;
		counter = 0;
		this.container.getChildren().each(function(el) {
			if(el.get('tag') == "a" && el.get('href')) {
				hrefval = el.get('href').toLowerCase();
				if(hrefval.contains('.png') || hrefval.contains('.gif')|| hrefval.contains('.jpg') || hrefval.contains('.jpeg')) {
					el.addEvent('click', function() {
						$(bigimg).fade('hide');
						$(bigimgcontainer).addClass('thumbshower_loading');
						img = new Asset.image(el.get('href'), {
							onload: function() {
								$(bigimg).set('src', el.get('href'));		
								$(bigimg).set('width', this.width);
								$(bigimg).set('height', this.height);
								$(bigimg).fade('in');
								$(bigimgcontainer).removeClass('thumbshower_loading');
							}
						});
						return false;
					});
				}
			if(loadfirst && counter == 0)
				el.fireEvent('click');
			counter++;
			}
		});
	}
});

			
window.addEvent('domready', function() { var mythumb = new Thumbshower("imgcontainer", "imbigpic", "bigimgcontainer", true); });
			
