var gebruikt = 1;
var group = 'nieuw';
var duration = 5000;
var nieuw = 1;
var timer;

function nooteboomPrev(groep, durationOverride)
{
	if(groep == 'nieuw')
		counter = nieuw - 1;
	if(groep == 'gebruikt')
		counter = gebruikt - 1;
	
	if(counter > 0)
	{
		if(groep == 'nieuw')
			nieuw = counter;
		if(groep == 'gebruikt')
			gebruikt = counter;
		hideNiceAll(groep + '-voertuig', groep+'-voertuig-button'); show(groep+'-voertuig-'+counter);
		
		$(groep + "-voertuig-button-" + counter).addClass('toggle-active');
		$(groep + "-voertuig-button-" + counter).removeClass('toggle-inactive');
		
		doTimer(durationOverride);
	}
}

function nooteboomNext(groep, durationOverride)
{
	if(groep == 'nieuw')
		counter = nieuw + 1;
	if(groep == 'gebruikt')
		counter = gebruikt + 1;
	
	if(counter <= 7)
	{
		if(groep == 'nieuw')
			nieuw = counter;
		if(groep == 'gebruikt')
			gebruikt = counter;
			
		hideNiceAll(groep + '-voertuig', groep+'-voertuig-button'); show(groep+'-voertuig-'+counter);
		
		if($(groep + "-voertuig-button-" + counter) != null)
		{
			$(groep + "-voertuig-button-" + counter).addClass('toggle-active');
			$(groep + "-voertuig-button-" + counter).removeClass('toggle-inactive');
		}
		doTimer(durationOverride);
	}
}

function slideShow()
{
	if(group == 'nieuw')
	{
		if(nieuw >= 7)
		{
			gebruikt = 0;
			group = 'gebruikt';
			
			hideNiceAll('voertuig-blok', 'voertuig-blok-button'); 
			showNice('voertuig-blok-gebruikt', $('voertuig-tab-gebruikt'));
		}
	}
	else
	{
		if(gebruikt >= 7)
		{
			nieuw = 0;
			group = 'nieuw';
			
			hideNiceAll('voertuig-blok', 'voertuig-blok-button'); 
			showNice('voertuig-blok-nieuw', $('voertuig-tab-nieuw'));
		}
	}
	
	nooteboomNext(group, duration);
}

function doTimer(durationOverride)
{
	$clear(timer);
	timer = setTimeout(new closure(this,"slideShow"), durationOverride);
}

function closure(context, func){
		return (function(){
			context[func]();
		});
   }


