window.addEvent('domready',function() { 
	var scroll = new Fx.Scroll($('gallery'), {
		wait: false,
		duration: 900,
		wheelStops:true,
		offset: {'x': 0, 'y':0},
		transition: Fx.Transitions.Back.easeOut
	});
	$('gal_prev').addEvent('click',function(event){
		var active = $('gallery').getElement('.active_image');
		var prev = active.getPrevious();
		if (prev) {
			scroll.toElement(prev);
			prev.addClass('active_image');
			active.removeClass('active_image');
		} else {
			prev = active.getParent().getLast();
			scroll.toElement(prev);
			prev.addClass('active_image');
			active.removeClass('active_image');
		}	
		return false;						
	});	
	$('gal_next').addEvent('click',function(event){
		var active = $('gallery').getElement('.active_image');
		var next = active.getNext();
		if(next){
			scroll.toElement(next);
			next.addClass('active_image');
			active.removeClass('active_image');
		} else {
			next = active.getParent().getFirst();
			scroll.toElement(next);
			next.addClass('active_image');
			active.removeClass('active_image');
		}		
		return false;	
			
		
						
	});	
	//var gallery = $("gallery");
//	var pos = gallery.getPosition();
//	$('images').addEvent('mousemove',function(event){
//		e = new Event(event);
//		relY = e.page.y - pos.y;
//		
//		if(relY > 200 && relY < 400) {
//			console.log(relY);
//			relX = e.page.x - pos.x;
//			if(relX < 200) {
//				$('gal_prev').show();
//				return;	
//			} else if (relX > 400) {
//				$('gal_next').show();
//				return;	
//			}
//		}		
//		$('gal_prev').hide();
//		$('gal_next').hide();
//		return false;	
//	});	
	
	
});

	
