var count = 0;

function cufonInit(){
	Cufon.replace('#menu li a', {hover: true});
	Cufon.replace('h2', {hover: false});
	//Cufon.replace('a', {hover: true});
	Cufon.replace('h3', {hover: false});
	Cufon.replace('h4', {hover: false});
	Cufon.replace('a .cta', {hover: false});
	Cufon.replace('.voordeel p', {hover: false});
	Cufon.replace('#footermenu li a', {hover: true});
	Cufon.replace('#uitgelicht ul li a', {hover: true});
	Cufon.replace('.form-class label', {hover: true});
	
	$('#content p:first').css('width','430px');
	$('#menu').show();
}

function aanmeldenShowPart(rechtsvorm)
{
	//alert(rechtsvorm);
	$('#aanmeldformulier .details').hide();
	$('#aanmeldformulier #' + rechtsvorm).slideDown(500);
}

function showContent(){
	$('#content,#contentsmall').css('visibility','visible');
}

function mogelijkheden()
{
	$('h4:first').css('margin-top','10px');
	$('h4').each(function(){
		var voordeel = $(this).next().html();
		$(this).next().remove();
		var titel = $(this).html();
		$(this).html('<div class="voordeel wrap"><img src="/media/images/label.png"><span>' + titel + '<p>' + voordeel + '</p></span></div>');
	});
	
	$('a.cta:last').css('clear','both');
}

function home()
{
	$('h3:first').css('margin-top','30px');
	$('h3').each(function(){
		count++;
		
		var voordeel = $(this).next().html();
		$(this).next().remove();
		var titel = $(this).html();
		if(count%2 == 0){
			$(this).html('<div class="voordeel links"><img src="/media/images/label.png"><span>' + titel + '<p>' + voordeel + '</p></span></div>');
		}else{
			$(this).html('<div class="voordeel rechts"><img src="/media/images/label.png"><span>' + titel + '<p>' + voordeel + '</p></span></div>');
		}

	});
	
	$('#content p').css('width','900px');
	
	$('a.cta:last').css('marginLeft','180px').addClass('ie');
}

function inleiding()
{
	$('p:first').addClass('inleiding');
}

function cta()
{
	$('a.cta').each(function(){
		var titel = $(this).html();
		var html = '<div class="cta"><div class="links"></div><div class="midden"><span>' + titel  + '</span><div class="pijltje"></div></div><div class="rechts"></div></div>';
		$(this).html(html);
	});
	
	$('a.cta2').each(function(){
		var titel = $(this).html();
		var html = '<div class="cta2"><div class="links"></div><div class="midden"><span>' + titel  + '</span><div class="pijltje"></div></div><div class="rechts"></div></div>';
		$(this).html(html);
	});
	
}

function uitgelichtInit()
{
	//$aantalItems = 
	// breedte eerste item
	var offset = parseInt($('#uitgelicht ul li:eq(0)').position().left);
	var breedte = parseInt($('#uitgelicht ul li:eq(0) a').width());
	$('#marker').css('marginLeft',(offset - 10) + 'px');
	$('#marker #middenmarker').css('width',(breedte-5) + 'px')
	
	
	//alert(parseInt($('#uitgelicht ul li:eq(0)').position().left));
	// hover functie
	$('#uitgelicht ul li').hover(function(){
		uitgelichtInAnimatie = true;
		$('#marker #middenmarker').stop();
		$('#marker').stop();
		$('#uitgelicht #imageslide').stop();
	
		var offset = parseInt($(this).position().left);
		var breedte = parseInt($('a',this).width());
		
		var picno = $(this).prevAll().length;
		
		
		// foto sliden
		
    	$('#uitgelicht #imageslide').animate({
          	marginLeft: "-" + (picno * 460)  +"px"
    	}, 400);
		//$('#uitgelicht #imageslide').css('marginLeft','-' + (picno * 450)  + 'px')	
		
		// goede breedte
    	$('#marker #middenmarker').animate({
          	width: "" + (breedte + 1) +"px"
    	}, 400);
    	
		// jump naar goede margin-left
		$('#marker').animate({
          	marginLeft: "" + (offset - 17) +"px"
    	}, 400);
		
	});
	
}

function menuInit()
{
	var offset = 0;
	
	if($('#menu ul li.huidig').length > 0){
		// positie bepalen
		var offset = 0;
		var itemno = ($('#menu ul li.huidig').prevAll().length+1);

		for(x = 1 ; x < itemno ; x++)
			offset += $('#menu ul li:eq(' + (x-1) + ')').width();
		
		//alert($('#menu ul li.huidig').position().left);
		
		// breedte van nieuwe item bepalen
		var breedte = $('#menu ul li:eq(' + (itemno-1) + ')').width() -24;
		
		// goede breedte
		$('#menuitemaccent #spacer').css('width',(breedte+3) + 'px');
    	
		// jump naar goede margin-left
    	$('#menuitemaccent').css('margin-left',(offset + 3) + 'px');
		// laten zien
    	$('#menuitemaccent').css('display','block');
	}
	
	// hover functie
	$('#menu ul li').hover(function(){
		
		// laten zien
		$('#menuitemaccent').css('display','block');
		$('#menuitemaccent').stop();
		$('#menuitemaccent #spacer').stop();
		
		// nieuwe positie bepalen
		var offset = 0;
		var itemno = $(this).prevAll().length+1;

		for(x = 1 ; x < itemno ; x++)
			offset += $('#menu ul li:eq(' + (x-1) + ')').width();
		
		// breedte van nieuwe item bepalen
		var breedte = $('#menu ul li:eq(' + (itemno-1) + ')').width() -24;
		
		// goede breedte
    	$('#menuitemaccent #spacer').animate({
          	width: "" + (breedte + 3) +"px"
    	}, 400);
    	
		// jump naar goede margin-left
		$('#menuitemaccent').animate({
          	marginLeft: "" + (offset + 3) +"px"
    	}, 400);
    	
	},function(){
		$('#menuitemaccent').stop();
		$('#menuitemaccent #spacer').stop();
		
		if($('#menu ul li.huidig').length == 0){
			$('#menuitemaccent').hide();
			return;
		}
		
		var offset = 0;
		var itemno = ($('#menu ul li.huidig').prevAll().length+1);
		//alert(itemno);
		for(x = 1 ; x < itemno ; x++)
			offset += $('#menu ul li:eq(' + (x-1) + ')').width();
		
		// breedte van item bepalen
		var breedte = $('#menu ul li:eq(' + (itemno-1) + ')').width() -24;
		
		// goede breedte
    	$('#menuitemaccent #spacer').animate({
          	width: "" + (breedte + 3) +"px"
    	}, 400);
    	
		// jump naar goede margin-left
		$('#menuitemaccent').animate({
          	marginLeft: "" + (offset + 3) +"px"
    	}, 400);

		
	});
	
}
