function AktionsWebPage() {
	this.photos = [];
	this.containers = [];
	this.currentIndex = 0;
	this.numVisiblePhotos = 3;
	
	this.waitUntilLoaded();
}
AktionsWebPage.prototype = {
	waitUntilLoaded: function() {
		var lthis = this;
		var arrowRight = document.getElementById('webpagePhotoArrowR');
		if (arrowRight == null) {
			window.setTimeout(function() { lthis.waitUntilLoaded(); }, 50);
			return;
		}
		
		var arrowLeft = document.getElementById('webpagePhotoArrowL');		
		arrowLeft.onclick = function() { lthis.movePhotos(-lthis.numVisiblePhotos); };
		arrowRight.onclick = function() { lthis.movePhotos(lthis.numVisiblePhotos); };
		

		for (var i = 0; true; i ++) {
			var container = document.getElementById('photoContainer' + i);
			if (container == null) break;
			container.onclick = function() { lthis.photoClicked(this.id.substr(14) - 0); };
			this.containers.push(container);
			var image = container.getElementsByTagName('img')[0];
			var beschreibung = getNodeContent(container.getElementsByTagName('div')[1]);
			this.photos.push([image.getAttribute('realSrc'), beschreibung]);
		}
	},
	
	movePhotos: function(delta) {
		var index = this.currentIndex + delta;
		if (index >= this.photos.length || index < 0) return;
		
		var i;
		for (i = this.currentIndex; i < this.currentIndex + this.numVisiblePhotos && i < this.containers.length; i ++) {
			this.containers[i].style.display = 'none';
		}
		for (i = index; i < index + this.numVisiblePhotos && i < this.containers.length; i ++) {
			this.containers[i].style.display = 'block';
		}
		
		this.currentIndex = index;
	},

	photoClicked: function(index) {
		var lthis = this;
		myLightbox.start(this.photos, index, function(activeImage) { lthis.lightboxEnded(activeImage); });
	},
	
	lightboxEnded: function(activeImage) {
		this.movePhotos(Math.floor(activeImage / 3) * 3 - this.currentIndex);
	},
	
	playVideo: function(url, beschreibung, width, height) {
		/* flv-player.net */
		var player = document.createElement('object');
		player.type = 'application/x-shockwave-flash';
		player.data = '/flvplayer.swf';
		player.width = width - 0;
		player.height = height - 0;
		var param = document.createElement('param');
		param.name = 'movie';
		param.value = '/flvplayer.swf';
		player.appendChild(param);
		param = document.createElement('param');
		param.name = 'allowFullScreen';
		param.value = 'true';
		player.appendChild(param);
		param = document.createElement('param');
		param.name = 'FlashVars';
		param.value = 'flv=' + url + '&autoplay=1&autoload=1';
		player.appendChild(param);
		
		myLightbox.start([[player, beschreibung]], 0);
		
	}
	
	
}

var aktionsWebPage = new AktionsWebPage();
