// JavaScript Document

function createImageSlider() {
	
	window.addEvent('domready', function() {
		
		var imgWidth = $('horizontal_slide').getElements('img');
		var total = $('horizontal_slide').getElements('img').length;

		var pos = -312;
		var counter = 0;

		var slide = new Fx.Tween('horizontal_slide', {property: 'left', duration: 750}); 
		var txt = "Bilder " + (counter * 2 + 1) +  "/" + (counter * 2 + 2) +  "<br /> von " + total;
		
		if (imgWidth[0].width > 154) {
			txt = "Bild " + (counter + 1) +  "<br /> von " + total;
		}
		
		$('status').set('html', txt);
		
		slide.addEvent('start', function() {
			txt = "Bilder " + (counter * 2 + 1) +  "/" + (counter * 2 + 2) +  "<br /> von " + total;
			if (counter >= (total / 2) - 1 && (total % 2)) {
				txt = "Bild " + (counter * 2 + 1) + "<br /> von " + total;
			}
			
			if (imgWidth[0].width > 154) {
				txt = "Bild " + (counter + 1) + "<br /> von " + total;
			}
		
			$('status').set('html', txt);
		});
		
		$('btnLeft').addEvent('click', function(event) {
			if (counter > 0) {
				counter--;		
				slide.start(pos * counter);
			}
			
			event.stop();
		});
		
		$('btnRight').addEvent('click', function(event) {
			if (imgWidth[0].width > 154) {
				if (counter < total - 1) {
					counter++;
					slide.start(pos * counter);
				}
			} else {
				if (counter < (total / 2) - 1) {
					counter++;
					slide.start(pos * counter);
				}
			}
			
			event.stop();
		});

	});	
	
}

function createVerticalSlider(id) {
	
	window.addEvent('domready', function() {
		
		var total = $('vertical_slide' + id).getElements('img').length;
		var pos = -70;
		var counter = 0;
		var minItems = 4;
		
		if (total == 0) {			
			total = $('vertical_slide' + id).getElements('a').length - 1;
			pos = -65;
			minItems = 4;
			$('slideWrapper' + id).style.height = "195px";
			total = total / 2;
		}
		
		if (total < minItems) {
			$('btnTop'+id).style.display = "none";
			$('btnDown'+id).style.display = "none";
		}
		
		var slide = new Fx.Tween('vertical_slide' + id, {property: 'top', duration: 750}); 
		
		$('btnTop'+id).addEvent('click', function(event) {
			if (counter > 0) {
				counter--;		
				slide.start(pos * counter);
			}
			event.stop();
		});
		
		$('btnDown'+id).addEvent('click', function(event) {
			if (counter < total - 3) {
				counter++;
				slide.start(pos * counter);
			}
			event.stop();
		});

	});		
}





 

