$(document).ready(function() {	
	
	$("#BESTELLINGEN").hide();
	$("#BESTELLINGEN").fadeIn(300, function(){
		$("#BESTELLINGEN").fadeOut(300, function(){
			$("#BESTELLINGEN").fadeIn(300);
		});
	});
	
	/* tabs =================================== */
	$(".tab.act").each(function() {
		var tabnaam=$(this).attr('id');
		$(this).html("<img src='../img/nl/"+tabnaam+"_act.gif'>");
	});
	$(".tab").click(function() {
		var tabnaam=$(this).attr('id');
		$(".tabblok .tabblok_content").hide();
		var optieblok = "#optie_"+tabnaam;
		$(optieblok).show();
		
		$(".tab").each(function() {
			var tabnaam2=$(this).attr('id');
			$(this).html("<img src='../img/nl/"+tabnaam2+".gif'>");
		});
		$(this).html("<img src='../img/nl/"+tabnaam+"_act.gif'>");
	});
	
	/* knoppen */
	$("a.knop span").each(function() {
		var knopnaam=$(this).attr('class');
		$(this).html("<img src='../img/nl/knop/"+knopnaam+".gif'>");
	});
	
	
	
	/* hoofdmenu */
	$(".menu_item:not(.act)").animate({ "opacity" : 0.73 }, 0);
	$(".menu_item:not(.act)").hover(function() {
		$(this).animate({ "opacity" : 1 }, 100);
	}, function(){
		$(this).animate({ "opacity" : 0.73 }, 100);
	});
	
	
	
	
	/* footer */
	$(".footer_menuitem:not(.act)").animate({ "opacity" : 0.53 }, 0);
	$(".social").animate({ "opacity" : 0.53 }, 0);
	$(".social, .footer_menuitem:not(.act)").hover(function() {
		$(this).animate({ "opacity" : 1 }, 100);
	}, function(){
		$(this).animate({ "opacity" : 0.53 }, 100);
	});
	
	
	$("#naarboven").click(function () {
		$.scrollTo(0, 800, {easing:'easeInOutExpo'} );
	});

	
	
	/* MIX */
	
	
	$(".keuze_mix").click(function() {
		var keuze=$(this).attr('id');
		$(".keuze_mix").animate({ "opacity" : 0.70 }, 0);
		$(this).animate({ "opacity" : 1 }, 400);
		var toggle = ".keuze_mix_actie."+keuze;
		$(toggle).toggle();
		keuzeaan = true;
	});
	
	/* homepage */
	
	var keuzegemaakt = false;
	
	$("#sw_mueslimix").click(function() {
		$(this).hide();
		$("#sw_mueslimix2").show();
	});
	
	$("#sw_snackmix").click(function() {
		$(this).hide();
		$("#sw_snackmix2").show();
	});
	
	$("#sw_koffiemix").click(function() {
		$(this).hide();
		$("#sw_koffiemix2").show();
	});
	
	/* poll */
	
	var options = { path: '/', expires: 5 };
	
	
	$(".polloptie").click(function() {
		var pollid = $("#pollid").attr('value');
		var polloptie = $(this).attr('value');
		$("#poll_knoppen").hide();
		$("#poll_opties").slideUp(400, function(){
			$('#poll_laden').slideDown(200);
			$.cookie("mmm_poll", pollid, options);
			$("#poll_resultaten").load("blok_pollres.php", {varg: polloptie}, function(){
				$('#poll_laden').slideUp(200, function(){
					$("#poll_resultaten").slideDown(300);
				});
			});
		});
	});
	
	$(".poll_res").livequery(function() { 
		$(this).hover(function() { 
			var vraag = $(this).attr('title');
			$("#vraagtekst").html(vraag);
			$(this).css({'background-color' : '#a7950d'});
		}, function() { 
            $("#vraagtekst").html("&nbsp;");
			$(this).css({'background-color' : '#cab723'});
        });
	}, function(){
		$(this).unbind('mouseover').unbind('mouseout'); 
	});
	
	$("#bekijkresultaten").click(function() {
		$(this).hide();
		$("#poll_opties").slideUp(400, function(){
			$('#poll_laden').slideDown(200);
			$("#poll_resultaten").load("blok_pollres.php", '', function(){
				$('#poll_laden').slideUp(200, function(){
					$("#poll_resultaten").slideDown(300);
					$("#bekijkstemmen").show();
				});
			});
		});
	});
	
	$("#bekijkstemmen").click(function() {
		$(this).hide();
		$("#poll_resultaten").slideUp(400, function(){
			$("#poll_opties").slideDown(300);
			$("#bekijkresultaten").show();
		});
	});
	
	
});
