//<![CDATA[
var horizontal;
var scrollTimer = null;

window.addEvent('domready',function(){

	if( $( 'q' ) ){
		$( 'q' ).addEvent( 'focus' , function( e ){
			if( this.value == 'Typ hier uw zoekopdracht' ) this.value = '';
		} ).addEvent( 'blur' , function( e ){
			if( this.value == '' ) this.value = 'Typ hier uw zoekopdracht';
		} );
	}

	/*
	NEW CAROUSEL
	*/

	// Count the slides
	var slidescontainer = $( 'horizontal' ).getChildren()[ 0 ];
	var numberOfSlides = slidescontainer.getChildren().length;

	// Scrolling is only nessesary when there are more then 4 slides
	if( numberOfSlides > 4 ){
		horizontal = new Fx.Scroll.Carousel('horizontal',{
			mode: 'horizontal',
			onComplete: function(){ scrollTimer = setTimeout( function(){ horizontal.toNext(); } , 4000 ); }
		});
		scrollTimer = setTimeout( function(){ horizontal.toNext(); } , 4000 );

		$('next').addEvent('click', function(){
			clearTimeout( scrollTimer );
			horizontal.toNext();
		});

		$('previous').addEvent('click', function(){
			clearTimeout( scrollTimer );
			horizontal.toPrevious();
		});
	}else{
		slidescontainer.setStyle( 'width' , 'auto' );
	}

	/*
	$('loopOnScrollEnd').addEvent('change',function(){
		var bool = (this.value == 'true') ? true : false;
		horizontal.options.loopOnScrollEnd = bool;
	});
	*/

	/*
	MEGA MENU
	*/

	var menu = new Megamenu( {
		container: 		'megamenu',
		activator:		'mouseover',
		deactivator:	'mouseout',
		hideTimeout:	0
	} );
	menu.Init();

	/*
	CAROUSEL STUFF
	*/
	/*
	var duration = 200,
	links = $$( 'div#slide_container a' ),
	tab = new Carousel.Extra( {
		container:	'slide',
		interval:	110,
		scroll:		2,
		circular:	true,
		current:	0,
		previous:	links.shift(),
		next:		links.pop(),
		onChange:	function( index ){
			links.each( function( el , off ){
				el[ off == index ? 'addClass' : 'removeClass' ]( 'selected' );
			} )
		},
		fx: { duration: duration }
	} );
	links.each( function( el , index ){
		el.addEvent( 'click' , function( e ){
			e.stop();
			tab.move( index );
		} );
	} );
	*/
} );
//]]>

