function lightboxInit(){
	$('.onderdelen div a').lightBox({
		fixedNavigation:true,
		imageLoading: '/media/images/lightbox-ico-loading.gif',
		imageBtnClose: '/media/images/lightbox-btn-close.gif',
		imageBtnPrev: '/media/images/lightbox-btn-prev.gif',
		imageBtnNext: '/media/images/lightbox-btn-next.gif',
		imageBlank: '/media/images/lightbox-blank.gif',
		containerResizeSpeed: 200,
		txtImage: 'Foto',
		txtOf: 'van'
	});
}

$(document).ready(function(){
	$('#portfolio h3 a').each(function(){
		$(this).click(function(){
			// bij huidige of tijdens beweging: niets doen
			if ($(this).parents('.categorie').hasClass('huidig') || $('.smooth').length)
				return false;
			// de bewegende tijdelijk een class geven
			$(this).parents('.categorie').addClass('smooth');
			// alle plaatjes op niet actief
			$('#portfolio .categorie:not(.smooth) h3 img').each(function(){
				$(this).attr('src',$(this).attr('src').replace('_1.gif','.gif'));
			});
			smooth(new Date().getTime(),totaaltijd);
			return false;
		});
		$(this).hover(function(){
			// bij huidige, niet nog een keer actief maken
			if ($(this).parents('.categorie').hasClass('huidig') || $(this).parents('.categorie').hasClass('smooth'))
				return false;
			$(this).find('img').attr('src',$(this).find('img').attr('src').replace('.gif','_1.gif'));
		},
		function(){
			// bij huidige of bewegende, actieve status niet weghalen
			if ($(this).parents('.categorie').hasClass('huidig') || $(this).parents('.categorie').hasClass('smooth'))
				return false;
			$(this).find('img').attr('src',$(this).find('img').attr('src').replace('_1.gif','.gif'));
		})
	});
	
	if ($('#portfolio')){
		$("a[class^='portfolio-']").each(function(){
			$(this).click(function(){
				var classname = $(this).attr('class').split('-');
				if (classname[1]>0 && !$('#categorie'+classname[1]).hasClass('huidig'))
					$('#categorie'+classname[1]+' h3 a').click();
				if (classname[2]>0 && !$('#menuproject'+classname[2]).hasClass('huidig'))
					setTimeout("$('#menuproject'+"+classname[2]+"+' a').click();",classname[1]>0 && !$('#categorie'+classname[1]).hasClass('huidig')?700:0);
//				$(this).attr('href','#');
				return false;
			});
		});
	}
});

function colorboxInit(el){
	$('#project'+el+' .hoofdfoto').css('cursor','pointer').click(function(){
		$(this).next().next().click();
	});
	$('#project'+el+' .meerdetails').css('cursor','pointer').click(function(){
		$(this).next().click();
	});
	$("a[rel^='project"+el+"']").colorbox();
}

var totaaltijd = 700;
var breedte = 834;
var smal = 36;
// t: current time, b: begInnIng value, c: change In value, d: duration
function smooth(start,duur){
	var nu = new Date().getTime();
	var waarde = Math.round(jQuery.easing.easeInOutQuint(0,(nu-start),0,breedte-smal,duur));
	$('#portfolio .smooth').css('width',(smal+waarde)+'px');
	$('#portfolio .huidig').css('width',(breedte-waarde)+'px');
	
	// einde
	if (nu-duur >= start){
		$('#portfolio .categorie.huidig').css('width',smal+'px').removeClass('huidig');
		$('#portfolio .smooth').css('width',breedte+'px').addClass('huidig').removeClass('smooth');
		return false;
	}
	setTimeout('smooth('+start+','+duur+');',10);
}

function anderProject(el,i,richting){
	var snelheid = 700;
	if (richting==1)
		$(el).parents('.projecten-inner').animate({'left':'+='+(breedte-smal)+'px'},snelheid,'easeInOutQuint');
	else if (richting==2)
		$(el).parents('.projecten-inner').animate({'left':'-='+(breedte-smal)+'px'},snelheid,'easeInOutQuint');
	else{
		$(el).parents('.projectenmenu').find('li').removeClass('huidig');
		$(el).parent().addClass('huidig');
		$(el).parents('.categorie').find('.projecten-inner').animate({'left':'-'+((i-1)*(breedte-smal))+'px'},snelheid,'easeInOutQuint');
	}
	if (richting){
		$(el).parents('.projecten-wrapper').find('.projectenmenu li').removeClass('huidig').parent().find('li:eq('+(i-1)+')').addClass('huidig');
	}
	return false;
}