function ImageGallery(pageSize, maxPage, movement){
	// pagination
	this.pageSize = pageSize;
	this.currentPage = 1;
	this.maxPage = maxPage;
	
	// image gallery scrolling div
	this.scrollingDivId = 'imageGalleryScroller';
	this.scrollingDiv = document.getElementById( this.scrollingDivId );
	this.scrollingDiv.style.position = 'relative';
	
	// scroll position
	this.scrollPosition = this.scrollingDiv.style.top;
	
	// movement for each click
	this.movement = movement;
	
	// image gallery div
	this.imageGalleryDivId = 'imageGallery';
	this.imageGalleryDiv = document.getElementById( this.imageGalleryDivId );
};


ImageGallery.prototype.previousPage = function(){
	if(this.currentPage < 2) return;
	this.currentPage--;
	this.scrollPosition += this.movement;
	Effect.MoveBy(this.scrollingDiv, this.movement, 0, {
		beforeStart: function(){ imageGallery.disbaleButtons() },
		afterFinish: function(){ imageGallery.enableButtons() }
	});
};

ImageGallery.prototype.nextPage = function(){
	if(this.currentPage >= this.maxPage) return;
	this.currentPage++;
	this.scrollPosition -= this.movement;
	Effect.MoveBy(this.scrollingDiv, -this.movement, 0, {
		beforeStart: function(){ imageGallery.disbaleButtons() },
		afterFinish: function(){ imageGallery.enableButtons() }
	});
};

ImageGallery.prototype.disbaleButtons = function(){
	var previous = document.getElementById('previous');
	previous.className = 'disabled';
	var next = document.getElementById('next');
	next.className = 'disabled';
};

ImageGallery.prototype.enableButtons = function(){
	var previous = document.getElementById('previous');
	if(this.currentPage >= 2)
		previous.className = '';
	else
		previous.className = 'disabled';	
	var next = document.getElementById('next');
	if(this.currentPage < this.maxPage)
		next.className = '';
	else
		next.className = 'disabled';	
};

function showImage(source){

	var source = source;
	new Effect.Opacity('photo',
    { 
      duration: 1.0, 
      from: 1.0, to: 0.0,
      afterFinish: function(){changeSource(source)}
    });
};

function changeSource(source){
	document.getElementById('photo').src = source; 
};

function fadeIn(){

	new Effect.Opacity('photo',
    { 
      duration: 1.0, 
      from: 0.0, to: 1.0
    });
}
