var Gallery = {
	lowres : null,
	thumbnail : null,
	container : null,
	
	init : function(lowres,thumbnail) {		
		window.addEvent('load', function(){
			Gallery._init(lowres,thumbnail);
		});
		
		return;
	},
	
	_init : function (lowres,thumbnail) {
		this.lowres = $$(lowres);
		this.thumbnail = $$(thumbnail);
		
		if (!this.lowres || !this.thumbnail) return false;
		
		if (this.thumbnail.length > 0) {
			var obj = this;
			
			this.thumbnail.forEach(function(item,index) {
				item.index = index;
				item.addEvent('click',function(event) {
										if (!window.ie) {
											event = new Event(event);
											event.preventDefault();
										}else {
										    event.cancelBubble = true;
										    event.returnValue = false;
										}
									}
				);
				item.addEvent('mouseenter',function(event) {
										obj.swarpImage(index);
									}.bindWithEvent(obj)
				);
			});
		}
	},
	
	swarpImage : function(index) {
		this.lowres.forEach(function(item,itemIndex) {
			if (index == itemIndex) {
				item.setStyles({'display' : 'block'});
			}else {
				item.setStyles({'display' : 'none'});
			}
		});
	}
};

Gallery.init('#big_img div','#thumb_img a');
