/*******************************************************************************
	EasyWEB	5

	@Copyright 	Synerway Sp. z o. o. http://www.synerway.pl/
			All rights reserved

	@Author		Antoni Jakubiak <a.jakubiak@synerway.pl>


	@Description	
			Modul galerii zdjec
*******************************************************************************/

/**
 * Zdjecie wkladane do galleri
 */
function GalleryPhoto( smallUrl, bigUrl ) {
	this.smallUrl = smallUrl;
	this.bigUrl   = bigUrl;
}



/**
 * Galeria ze zdjeciami
 */
function Gallery() {
	this.photos = new Array();
}

/**
 * Dodaje zdjecie do galeri zdjec
 */
Gallery.prototype.attachPhoto = function( smallUrl, bigUrl ) {
	this.photos.push( new GalleryPhoto( smallUrl, bigUrl ) );
}

/**
 * uruchomienie galeri zdjec na jakim tam elemencie
 */
Gallery.prototype.run = function( containerId ) {
	this.element = document.getElementById( containerId );
	this.buttonNext = document.getElementById( containerId + "nextButton" );
	var oThis = this;
	this.buttonNext.onclick = function() {
		oThis.showNextPhoto();
	}
	this.nextPhotoId = 0;	
	this.showNextPhoto();
}

Gallery.prototype.showNextPhoto = function( id ) {
	var p = this.photos[ this.nextPhotoId ];
	if(!p) {
		this.nextPhotoId = 0;
		p = this.photos[ this.nextPhotoId ];
		if(!p) {
			return;
		}
	}
	this.element.style.backgroundImage = "url("+p.smallUrl+")";
	var oThis = this;
	this.nextPhotoId = this.nextPhotoId + 1;
}

 