var sliderId = 'merken';
var sliderImages;
var currentSlide;
var previousSlide;


/* functions */

function slideInit() {
	if (document.getElementById) {
		var slider = document.getElementById(sliderId);
		sliderImages = new Array;
		var node = slider.firstChild;
		/* instead of using childNodes (which also gets empty nodes and messes up the script later)
		we do it the old-fashioned way and loop through the first child and its siblings */
		while (node) {
			if (node.nodeType==1) {
				sliderImages.push(node);
			}
			node = node.nextSibling;
		}
		for(i=0;i<sliderImages.length;i++) {
			/* loop through all these child nodes and set up their styles */
			sliderImages[i].style.position='absolute';
			sliderImages[i].style.top=0;
			sliderImages[i].style.left=0-(i*116) + 'px';
			sliderImages[i].style.zIndex=100;
		}
		/* make the list visible again */
		slider.style.visibility = 'visible';
		/* initialise a few parameters to get the cycle going */
		sliding = 116;
		currentSlide=0;
		previousSlide=sliderImages.length-1;
		/* start the whole crossfade process after a second's pause */
		window.setTimeout("slide(116)", 2500);
	}
}

function slide(sliding) {
		if (sliding < 116) {
			sliderImages[currentSlide].style.left = 115 - sliding + "px";
			sliderImages[previousSlide].style.left = -1 - sliding + "px";
			sliding += 11.6;
			window.setTimeout("slide("+sliding+")", 30);
		} else {
			previousSlide=currentSlide;
			currentSlide+=1;
			if (currentSlide>=sliderImages.length) {
				/* start over from first image if we cycled through all images in the list */
				currentSlide=0;
			}
			/* make sure the current image is on top of the previous one */
			/* and start the crossfade after a second's pause */
			sliding=0;
			window.setTimeout("slide("+sliding+")", 2500);
		}		
}
addEvent(window,'load',slideInit)
