$(document).ready(function() {
	/* CUFON */
	Cufon.replace('#eonNav', {hover: 'true'});
	Cufon.replace('#eonZakelijkNav', {hover: 'true'});
	Cufon.replace('#footerBottom span');
	Cufon.replace('#slider h1');
	Cufon.replace('.layover p');
	Cufon.replace('#content .eonBeter span');
	Cufon.replace('.center h1');
	Cufon.replace('#content .brancheImage p');
	
});

/* DROPDOWN HOMEPAGE */
function go()
{
	box = document.forms[1].energieproducten;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}
	

/* SLIDER */
function slider() {		
	$.featureList(
		$("#tabs li a"),
		$("#images li"), {
			start_item	:	0
		}
	);
	//Voor ie7 en 8 wordt een gif als achtergrond voor de slidertekst gebruikt welke een andere opacity value nodig heeft
	if (jQuery.browser.msie && (parseInt(jQuery.browser.version) == 6 || parseInt(jQuery.browser.version) == 7 || parseInt(jQuery.browser.version) == 8)) {
		var opacityValue = '0.70';
	} else {
		var opacityValue = '0.99';
	}
	$(".images li:eq(0)").children('div').css("display", "block");
	$(".images li:eq(0)").children('div').css("opacity", opacityValue);
	$(".images li:eq(0)").children('img').css("display", "block");
	
	// top zetten van de active achtergrond
	$('.advantages div.active').css("top", "3px");
	
	//omdat de lis omgebouwd zijn en niet ineens verborgen worden maar de elementen in de lis apart op display block zetten
	$('.images li').each(function(elm) {
		$(this).css("display", "block");
	});
}	
;(function($) {
	
	if (jQuery.browser.msie) {
		var opacityValue = '0.70';
	} else {
		var opacityValue = '0.99';
	}
	$(".images li:eq(0)").children('div').css("display", "block");
	$(".images li:eq(0)").children('div').css("opacity", opacityValue);
	$(".images li:eq(0)").children('img').css("display", "block");
	
	//omdat de lis omgebouwd zijn en niet ineens verborgen worden maar de elementen in de lis apart op display block zetten
	$('.images li').each(function(elm) {
		$(this).css("display", "block");
	});
		
		
	$.fn.featureList = function(options) {
		var tabs	= $(this);
		var output	= $(options.output);

		new jQuery.featureList(tabs, output, options);

		return this;	
		
	};

	$.featureList = function(tabs, output, options) {
		
		function slide(nr) {
			
			
			if (typeof nr == "undefined") {
				nr = visible_item + 1;
				nr = nr >= total_items ? 0 : nr;
			}
			tabs.removeClass('current').filter(":eq(" + nr + ")").addClass('current');
			
			//Zorgen dat de achtergrond meebeweegt
			var offset = $('#tabs li a.current').offset();
			
			//door position relative wordt de top gerekend vanaf het blok waar de active instaat, de ruimte erboven moet er af gerekend worden
			var offsetAdvantages = $('.advantages').offset();
			offset.top = offset.top - offsetAdvantages.top + 3;
						
			//De achtergrond zetten
			//$(".advantages div.active").offset({ top: offset.top });
			
			$('.advantages div.active').animate({
			top: offset.top
			}, 400, function() {
		 		// Animation complete.
			});
			
			
			setTimeout(function() {
				 test();
			}, 400);
			function test() {	
				
				
				output.stop(true, true).filter(":visible").children('img').fadeOut();
				output.stop(true, true).filter(":visible").children('div').fadeOut();
				$(".images li:eq(" + nr + ")").children('img').fadeIn(function() {
					visible_item = nr;
					
					output.stop(true, true).filter(":visible").children('div').css("opacity", "0");
					
					$(".images li:eq(" + nr + ")").children('div').css("left", "270px");
					$(".images li:eq(" + nr + ")").children('div').css("display", "block");
					$(".images li:eq(" + nr + ")").children('div').each(function() {
						queue: false
						$(".images li:eq(" + nr + ")").children('div').animate({
						queue: false,
						
						opacity: opacityValue,
						left: '260'
						}, 300, function() {
							// Animation complete.
						});
					});
				});
			}
			
		}

		var options			= options || {}; 
		var total_items		= tabs.length;
		var visible_item	= options.start_item || 0;

		options.pause_on_hover		= options.pause_on_hover		|| false;
		options.transition_interval	= options.transition_interval	|| 6200;

		output.hide().eq( visible_item ).show();
		//console.log(visible_item);
		//tabs.eq( visible_item ).addClass('current');
		
		tabs.click(function(event) {
			event.preventDefault();
			this.blur();
			if ($(this).hasClass('current')) {
				return false;	
			}
			/* ALS on pause false is deze code toevoegen*/
			clearInterval( timer );
			timer = setInterval(function () {
				slide();
				
				
				
			}, options.transition_interval);
			/*--*/
			
			slide( tabs.index( this) );
		});
		
		if (options.transition_interval > 0) {
			
			
			var timer = setInterval(function () {
				slide();
				
			}, options.transition_interval);
			
			if (options.pause_on_hover) {
				tabs.mouseenter(function() {
					clearInterval( timer );

				}).mouseleave(function() {
					clearInterval( timer );
					timer = setInterval(function () {
						slide();
						
						
						
					}, options.transition_interval);
				});
			}
		}
	};
})(jQuery);
