Cufon.replace('div#top ul li, div#tagcloud a', { fontFamily: 'Unit-LightLF', hover: true });
Cufon.replace('span.listtitle, h1, h2, div#tagcloud strong, aside span.title', { fontFamily: 'Unit-Bold', hover: true });

$(function(){

	$("a[rel^='prettyPhoto']").prettyPhoto();

	$('div#headershadow').cycle({
		fx:			'fade',
		speed:		1000,
		timeout:	6000,
		pager:		'#nav',
		slideExpr:	'div.header',
		cleartype: true,
		cleartypeNoBg: true
	});

	$(".box").each(function(){
		$link = $(this).find("a.button").attr("href");
		if($link){
			$(this).find("img").wrap("<a href=" + $link +">");
			$(this).find("h2").wrap("<a href=" + $link +">");
		}
	});

	$("div.project").click(function(){
		window.location = $(this).find("a.readmore").attr("href");
	});
});

$(window).load(function(){
	$("figure").each(function(){
		$(this).find("figcaption").css("max-width", $(this).find("img").width()).show();
	});
	$("div.input_block").each(function(){
		$(this).find("div.label").height($(this).height());
	});
});

$(function() {
	$('div.slideshow').each(function(index){
		var $pArr = $(this).find(" div.project");
		var pArrLen = $pArr.length;
		var pPerDiv = 3;
		for (var i = 0; i < pArrLen; i += pPerDiv){
			$pArr.filter(':eq('+i+'),:lt('+(i+pPerDiv)+'):gt('+i+')').wrapAll('<div class=\"slide\">');
		}
		
		$cycle = $(this).parent("div.projecten");
		$cycle.find(".page").addClass("page" + index);

		$(this).cycle({ 
			fx:     'scrollHorz',
			speed:   900,
			timeout: 0,
			pager:  '.page' + index,
			cleartype: true,
			cleartypeNoBg: true	
		});

		$cycle.find(".page").width($cycle.find("div.page a").length * 15);
	});
});
