
function ge(id) {

	return document.getElementById(id);

}

var carrouselCurrScroll = 0;
var carrouselScrollDistance = 960;


/* 	function spinCarrouselForward
		carrousel vooruit
*/

function spinCarrouselForward() {
	
	var aantalProjecten = $$('.projectenitem');
	var breedteProjecten = (283 * (aantalProjecten.length));
	
	if((carrouselCurrScroll + carrouselScrollDistance) < breedteProjecten) {
			carrouselCurrScroll += carrouselScrollDistance;
			scrollExample = new Fx.Scroll($('projecten'), {
				wait: false,
				duration: 500,
				transition: Fx.Transitions.Expo.easeOut
			});
			scrollExample.scrollTo(carrouselCurrScroll, 0);
	}

}

/* 	function spinCarrouselBack
		carrousel terug
*/

function spinCarrouselBack() {
	
	if((carrouselCurrScroll - carrouselScrollDistance)>=0) {
		carrouselCurrScroll -= carrouselScrollDistance;
		scrollExample = new Fx.Scroll($('projecten'), {
			wait: false,
			duration: 500,
			transition: Fx.Transitions.Expo.easeOut
		});

		scrollExample.scrollTo(carrouselCurrScroll, 0);
	}

}

window.addEvent('domready', function() {

	/* alsosee caroussel op homepagina */
	var knopverder = document.getElementById('pijlverder');
	if (knopverder) {
		knopverder.onclick = function() {
				
				spinCarrouselForward();
		}
	}

	var knopterug = document.getElementById('pijlterug');
	if (knopterug) {
		knopterug.onclick = function() {
				spinCarrouselBack();
		}
	}
	
	/* mouseover voor bg */
	var sfEls = document.getElementById("hoofdmenu").getElementsByTagName("li");
	for (var i = 0; i < sfEls.length; i++) {

		/* mouseover */
		sfEls[i].onmouseover = function() {

			this.className+= ' sfhover';
			if (this.getElementsByTagName("LI").length > 0) {
				ge('b').className = 'mouseover';

				var submenu = this.getElementsByTagName("ul");
				if (submenu.length > 0) {
					if (submenu[0].className == 'menuright') {
						var submenuW = 0 - this.offsetWidth - 10;
						var submenuitems = this.getElementsByTagName("LI");

						for (var j = 0; j < submenuitems.length; j++) {
							submenuW += submenuitems[j].offsetWidth;
						}

						submenu[0].style.left = (this.offsetLeft - submenuW) + 'px';

					}
				}

			}
		}

		/* mouseout */
		sfEls[i].onmouseout = function() {

			ge('b').className = '';
			this.className = '';

			var submenu = this.getElementsByTagName("ul");
				if (submenu.length > 0) {
					if (submenu[0].className == 'menuright') {
						submenu[0].style.left = '-999em';
					}
				}

			}

		}

	
	
});




/* NIEUWS CARROUSEL */

var nieuwscarrouselCurrScroll = 0;
var nieuwscarrouselScrollDistance = 250;



/* 	function spinCarrouselForward
		carrousel vooruit
*/

function nieuwsCarrouselForward() {
	
	var aantalNieuws = $$('.nieuwsitem2');
	var breedteNieuws = (250 * (aantalNieuws.length));
		
		if((nieuwscarrouselCurrScroll + nieuwscarrouselScrollDistance) < breedteNieuws) {
			
			nieuwscarrouselCurrScroll += nieuwscarrouselScrollDistance;
			scrollExample2 = new Fx.Scroll($('nieuws'), {
				wait: false,
				duration: 500,
				transition: Fx.Transitions.Expo.easeOut
			});
			scrollExample2.scrollTo(nieuwscarrouselCurrScroll, 0);
			
		}else{
			nieuwscarrouselCurrScroll = 0;
			scrollExample2 = new Fx.Scroll($('nieuws'), {
				wait: false,
				duration: 500,
				transition: Fx.Transitions.Expo.easeOut
			});
			scrollExample2.scrollTo(nieuwscarrouselCurrScroll, 0);
	}

}



window.addEvent('domready', function() {

	/* alsosee caroussel op homepagina */
	var knopvolgende = document.getElementById('volgende');
	if (knopvolgende) {
		knopvolgende.onclick = function() {
				nieuwsCarrouselForward();
		}
	}
	

});

//function initSlides() {
//	
//	var slides;
//	var slideNr = 0;
//	var aantalSlides;
//	var sliderInt = null;
//	
//	
//	// alle slides in een array stoppen
//	slides = $$('div#slider div.slide');
//	
//	var prev = document.getElementById('prevslide');
//	prev.onclick = function() {
//		if (slideNr == '0') {
//			volgendeSlide = slideNr;
//			slideNr = aantalSlides-1;
//		}
//		else {
//			volgendeSlide = slideNr;
//			slideNr = slideNr - 1;
//		}
//		
//		slides.each(function(element) {
//			element.style.display = 'none';
//		});
//		
//		slides[volgendeSlide].style.display = 'block';
//		slides[volgendeSlide].style.zIndex = '0';
//		slides[slideNr].style.zIndex = '9';
//		slides[slideNr].style.marginLeft = '-250px';
//		slides[slideNr].style.display = 'block';
//		var fx = new Fx.Styles(slides[slideNr], {duration:1000, wait:true, transition: Fx.Transitions.Expo.easeInOut});
//		fx.start({
//			'margin-left': '0px'
//		});
//		
//		clearInterval(sliderInt);
//	}
//	
//	var nxt = document.getElementById('nextslide');
//	nxt.onclick = function() {
//		if (slideNr < (aantalSlides-1)) {
//			vorigeSlide = slideNr;
//			slideNr = slideNr + 1;
//		}
//		else {
//			vorigeSlide = aantalSlides-1;
//			slideNr = 0;
//		}
//		
//		
//		slides.each(function(element) {
//			element.style.display = 'none';
//		});
//		
//		
//		slides[vorigeSlide].style.display = 'block';
//		slides[vorigeSlide].style.zIndex = '0';
//		slides[slideNr].style.zIndex = '9';
//		slides[slideNr].style.marginLeft = '250px';
//		slides[slideNr].style.display = 'block';
//		var fx = new Fx.Styles(slides[slideNr], {duration:1000, wait:true, transition: Fx.Transitions.Expo.easeInOut});
//		fx.start({
//			'margin-left': '0px'
//		});
//		clearInterval(sliderInt);
//	}
//	
//	
//	// beginnen met de eerste slide
//	slides[slideNr].style.display = 'block';
//	
//	aantalSlides = slides.length;
//	
//	sliderInt = setInterval(function(){
//		if (slideNr < (aantalSlides-1)) {
//			vorigeSlide = slideNr;
//			slideNr = slideNr + 1;
//		}
//		else {
//			vorigeSlide = aantalSlides-1;
//			slideNr = 0;
//		}
//		
//		
//		slides.each(function(element) {
//			element.style.display = 'none';
//		});
//		
//		
//		slides[vorigeSlide].style.display = 'block';
//		slides[vorigeSlide].style.zIndex = '0';
//		slides[slideNr].style.zIndex = '9';
//		slides[slideNr].style.marginLeft = '250px';
//		slides[slideNr].style.display = 'block';
//		var fx = new Fx.Styles(slides[slideNr], {duration:1000, wait:true, transition: Fx.Transitions.Expo.easeInOut});
//		fx.start({
//			'margin-left': '0px'
//		});
//	},2000);
//}



