var galleryElements = Array();
var curphoto = null;
var aktualFoto = 0;

function initializeG(element) {
	galleryElements = populateGallery(element);
}

function populateGallery(element) {
	var data = Array();
	element.getElements('a').each(function(el) {
		data.push(el);
 	});
	return data;
}

function prevItem(){
	aktualFoto = aktualFoto - 1;
	if ( aktualFoto <= -1 ) {
		aktualFoto = galleryElements.length - 1;
	}
	eval( galleryElements[aktualFoto].getProperty('href') );
}

function nextItem(){
	aktualFoto = aktualFoto + 1;
	if ( aktualFoto >= galleryElements.length ) {
		aktualFoto = 0;
	}
	eval(galleryElements[aktualFoto].getProperty('href'));		
}

function big_foto(path, nr)
{
	aktualFoto = nr;
	curphoto = path;
	preload(curphoto);
	photo_hide();

	var t = setTimeout(function(){preloadStart('photo_show()', 'alert("Wystąpił błąd przy ładowaniu obrazków.\nNie obejrzysz mojej prezentacji.")');}, 1000);
}

function photo_hide()
{
	var myFx1 = new Fx.Style('bigphoto', 'opacity', {duration:1000}).custom(1,0); //will make it immediately transparent
}

function photo_show()
{
	var bigphoto = $('bigphoto');
	bigphoto.src = curphoto;
	var myFx2 = new Fx.Style('bigphoto', 'opacity', {duration:1000}).custom(0,1); //will make it immediately transparent
}

function check_is_number(obj)
{
	if(isNaN(obj.value)) {
		obj.value = '';
		return false;
	}
}

