/* functions which navigate through the page */
	var loader;
	var activeActie = false;
	// * called by "Authenticated"
	// check if the social verification has returned a mailaddress, and decide
	// where to go:
	// - no email: showMail
	// - email: adduser and loadMap afterwards.

	function checkEmail()
	{
		//console_log("checking email");
		
		$(".voornemen-content-box").hide();
		//
		if(connected)
		{
			showLoading();
			//get id from network

			if(!socialType) {
				if(socialServices[2].user_id) { socialType = "twitter"; }
				if(socialServices[1].user_id) { socialType = "hyves"; }
				if(socialServices[0].user_id) { socialType = "facebook"; }
			}
			if(socialType == "facebook") { userId = socialServices[0].user_id; }
			if(socialType == "hyves") { userId = socialServices[1].user_id; }
			if(socialType == "twitter") { userId = socialServices[2].user_id; }
			
			//console_log(socialServices);
			//console_log("get-userinfo: "+socialType+", userId: "+userId);
			$.getJSON("/wp-content/plugins/social-sharer/mahieu/social-get-userinfo.php",
			{
				type: socialType,
				userid: userId
			},
			function(socialdata) {
				//console_log(socialdata);
				//console_log("Socialdata: "+socialdata.displayname);
				socialName = socialdata.displayname;
				email = socialdata.email;
				socialAvatar = socialdata.avatar;
				temp_userid = userId;
				//console_log("Email: ["+email+"]");
				if(!email || email == "") {
					showMail();
				} else {
					if(userId) {
						//console_log("addUser"+socialType+"/ uid: "+userId);
						addUser(socialType,userId,email,socialAvatar,socialName,loadMap);
					}
				}
			});
			
			for(var i = 0; i < socialServices.length; i++)
			{
				if(socialServices[i].connected)
				{
					$(".socialCB").show();
					$("#connect-"+socialServices[i].type+" .socialCB").prop("checked", true);
				}
				else{
					$("#connect-"+socialServices[i].type+" .socialCB").prop("checked", false);
				}
			}
		}
		else
		{
			hideLoading();
			$(".voornemen-content-box").hide();
			fillRespects();
			$("#stap01-disconnected").show();
		}
		
	}

	// NORMAL MAP: (in sharing flow)
	// A) loadMap: show loader and fire ajax call to check what social networks the user is connected to.
	// B) checkConnections: will set all parameters in socialServices and call "showMap"
	// C) showMap: will insert a new resolution and call "googlemaps.js" : googleMapInitialize

	function loadMap() {
		
		hideHome();
		
		
		if (typeof _gaq != 'undefined'){
			_gaq.push(['_trackEvent', 'home', 'plaats-marker-en-deel-venster-getoond']);
		}
		
	    $("#header").show();

		$("#explanation-container").fadeOut();
		$("#good-inside-container").fadeOut();

		$(".resolution-arrows-container").fadeOut();
		$(".dit-ga-ik-vandaag-doen").fadeOut();
		$(".wat-is-dit").hide();
		
		if(!activeActie){
			/*
			$("#voornemens").stop().animate({
				left:0 
			}, {
				duration: 600,
				specialEasing: {
					left:'easeOutCubic'
				}
			});
			*/
		}
		
		$("#voornemens .bottles").stop().animate({
			left:0
		}, {
			duration: 600,
			specialEasing: {
				left:'easeOutCubic'
			}
		});

		$("#voornemens #voornemen-content").stop().delay(200).animate({
			top:0
		}, {
			duration: 500,
			specialEasing: {
				top:'easeOutBack'
			}
		});
		

		pageState = "loadMap";
		showLoading();
		$(".voornemen-content-box").hide();
		checkConnections();
		return false;
	}

	function showMap() {
		
		$('#startShare').trigger('startMap');
		
		pageState = "mapLoaded";
		hideLoading();
		//$(".social-sidebar").hide();
		$('#voornemens #header').html(socialName+",<br/>Wat leuk dat je dit vandaag gaat doen!");
		$('#voornemens_subcontent p').html("Je bent geconnect met je "+socialType+" profiel. Deel je voornemen met je vrienden.");
		$("#voornemens .voornemen-content-box").hide();

		$("#voornemens #stap02-map").stop().delay(400).show().animate({
				marginTop:0
			}, {
				duration: 500,
				specialEasing: {
				marginTop:'easeOutBack'
			}, 
			complete: function() {
				$("#voornemens #stap02-map #map_canvas").show();
			}
		});

		// save a resolution, and proceed to googleMapInitialize afterwards
		insertVoornemen(googleMapInitialize);
		
		return false;
	}	
	
	// BIG MAP:
	// A) showBigMap: show loader and fire ajax call to fetch all resolutions to plot.
	// B) showBigMapComplete: Loaded. Hide loader, show page and initialize Google
	// C) googleBigMapInitialize: in "googlemaps_display.js", plots every marker on the big map.

	function showBigMap() {
		pageState = "mapLoaded";
		$.getJSON("/wp-content/plugins/social-sharer/social-get-resolutions.php", 
		{},
		function(data) {
			showBigMapComplete(data);
		});
		return false;
	}	
	
	function showBigMapComplete(data) {
		$('.bottles').fadeOut();
		hideLoading();
	
		//$(".social-sidebar").show();
		$('#header').html("Bedankt en veel plezier vandaag!<br/>(en tot morgen voor een nieuw voornemen)");
		
		$("#voornemens #stap04-map").stop().delay(400).show().animate({
				marginTop:0
			}, {
				duration: 500,
				specialEasing: {
				marginTop:'easeOutBack'
			}, 
			complete: function() {
				$("#voornemens #stap04-map #bigmap_canvas").show();
				googleBigMapInitialize(data);
			}
		});
		
		$('.voornemen-content-maincontainer').animate({
		   
		    left: 100
		
		 }, 400);

	}


	// ******************************* //
	//        Visual functions         //
	// ******************************* //

	function showLoading() {
		$("#loading-box").show();
		
		var dots = 0;
		
		loader = self.setInterval(function(){

			if(dots == 0){
				$("#loading-box").html("<b>Even geduld</b>");
			} else if (dots == 1){
				$("#loading-box").html("<b>Even geduld.</b>");
			} else if (dots == 2){
				$("#loading-box").html("<b>Even geduld..</b>");
			} else if (dots == 3){
				$("#loading-box").html("<b>Even geduld...</b>");
			}
			
			if(dots < 3){
				dots++;
			} else {
				dots = 0;
			}
			
		}, 350);
		
	}
	
	function hideLoading() {
		$("#loading-box").hide();
		window.clearInterval(loader);
	}

	function showThanks() {
		
		if (typeof _gaq != 'undefined'){
			_gaq.push(['_trackEvent', 'home', 'bedankt-voor-het-delen-venster-getoond']);
		}
		
		showBigMap();
	}

	function showMail() {
		hideLoading();
		$(".voornemen-content-box").hide();
		$("#stap01-email").show();
	}

	function hideHome() {
		$("#explanation-container").hide();
		$("#good-inside-container").hide();
		
		$(".resolution-arrows-container").hide();
		$(".dit-ga-ik-vandaag-doen").hide();

		$(".resolutions-bottle").show();
		$("#header").show();
	}

	function showStart() {
		
		if (typeof _gaq != 'undefined'){
			_gaq.push(['_trackEvent', 'home', 'dit-ga-ik-vandaag-doen']);
		}
		
		$("#explanation-container").fadeOut();
		$("#good-inside-container").fadeOut();
		
		$(".resolution-arrows-container").fadeOut();
		$(".dit-ga-ik-vandaag-doen").fadeOut();
		$(".wat-is-dit").hide();
				
		$("#voornemens .bottles").stop().animate({
			left:0
		}, {
			duration: 600,
			specialEasing: {
				left:'easeInOutBack'
			}
		});
		
		$("#voornemens #voornemen-content").stop().delay(200).animate({
			top:50
		}, {
			duration: 500,
			specialEasing: {
				top:'easeOutBack'
			}
		});
		
		
		$("#first-glow").stop().animate({
				left:-220
			}, {
				duration: 600,
			specialEasing: {
				top:'easeOutBack'
			}
			});
		
		
		$("#header").show();
		fillRespects();
		$("#stap01-disconnected").show();
		
		return false;
	}	
	
	// BOTTLE ANIMATION BY MARTIJN VAN MECHELEN
		
	var aPlayGoodOnInsideAnimation, aPlayGiveMeNewResolution, aPlayBackToResolution, imgResolution;
	var intCurrentResolution = currentVoornemen;

	function playGoodOnInsideAnimation() {
		// Remove css class if present.
		if (typeof _gaq != 'undefined'){
			_gaq.push(['_trackEvent', 'home', 'wil-je-uitleg']);
		}
		// Disable ahrefs.
		disableAHrefs();

		imgResolution.fadeOut("swing", function () {
			// Animate sprite.
			turnBottle("forward", "normal");

			var intID = window.setTimeout(function() {					
				// Hide and show container.
				hideButtonsAndShowGoodInsideContainer();

				// Enable ahrefs.
				enableAHrefs();
			}, 650);
	  	});


	}
	
	var spriteCount = 1;
	var maxSprite = 7;
	var s;
	
	function turnBottle(rotation, bottleType){
		
		$(".give-me-new-resolution").unbind('click', playGiveMeNewResolutionAnimation);
		$(".go-to-good-inside").unbind('click', animateToStap0);
		$("#voornemens .wat-is-dit").unbind('click', showExplanation);
		
		if(rotation == "forward"){
			spriteCount = 0;
		} else {
			spriteCount = 7;
		}
		
		s = self.setInterval(function(){
					
			var Ypos;

			if(bottleType == "blank"){
				yPos = "-443px";
			} else {
				yPos = "0px";
			}
						
			if(rotation == "forward"){
				
				if(spriteCount <= maxSprite){
					
					//console_log(spriteCount);
					//console_log(($(".resolutions-bottle").width() - ($(".resolutions-bottle").width() * spriteCount)));
					
					var xPos = String(($(".resolutions-bottle").width() - ($(".resolutions-bottle").width() * spriteCount))+"px");
					
					$(".resolutions-bottle").css("background-position", xPos +" "+ yPos);

					if(spriteCount == maxSprite){
						s = window.clearInterval(s);
						$(".give-me-new-resolution").bind('click', playGiveMeNewResolutionAnimation);
						$(".go-to-good-inside").bind('click', animateToStap0);
						$("#voornemens .wat-is-dit").bind('click', showExplanation);
					} else {
						spriteCount++;	
					}
				}

			} else {
				
				if(spriteCount >= 1){
					//console_log(spriteCount);
					//console_log(($(".resolutions-bottle").width() - ($(".resolutions-bottle").width() * spriteCount)));
					
					var xPos = String(($(".resolutions-bottle").width() - ($(".resolutions-bottle").width() * spriteCount)))+"px";
					
					$(".resolutions-bottle").css("background-position", xPos +" "+ yPos);
					
					if(spriteCount == 1){
						s = window.clearInterval(s);
						$(".give-me-new-resolution").bind('click', playGiveMeNewResolutionAnimation);
						$(".go-to-good-inside").bind('click', playGoodOnInsideAnimation);
						$("#voornemens .wat-is-dit").bind('click', showExplanation);
						
					} else {
						spriteCount--;	
					}
	
				} 
				
			}

		}, 45);		
	}
	
	
	
	function playGiveMeNewResolutionAnimation() {
		// Add css class to switch to blank bottle.
		if (typeof _gaq != 'undefined'){
			_gaq.push(['_trackEvent', 'home', 'wil-je-een-andere']);
		}
		
		spriteCount = 0;
		// Disable ahrefs.
		disableAHrefs();

		imgResolution.fadeOut("swing", function () {
			// Animate sprite.
			turnBottle("forward", "blank");

			var intID = window.setTimeout(function() {
				// Load and display new resolution.
				LoadAndDisplayNewResolution();
			}, 450);
	  	});
	}

	function setCurrentVoornemen(num) {
		voornemenID = allVoornemens[num].id;
		voornemenText = allVoornemens[num].title;
		voornemenLink = allVoornemens[num].link;
	}

	function LoadAndDisplayNewResolution() {
		
		$("a.dit-ga-ik-vandaag-doen").removeClass("bg-"+allVoornemens[intCurrentResolution].color);
		
		// Modify current resolution counter.
		if (intCurrentResolution < allVoornemens.length-1)
			intCurrentResolution++;
		else
			intCurrentResolution = 0;

		setCurrentVoornemen(intCurrentResolution);

		imgResolution.fadeOut("swing", function () {
			// Load next resolution.
			var img = new Image();

			// Wrap new image in jQuery and set source.

			$(img).attr("src", "/wp-content/plugins/buddypress/bp-themes/actimel/_inc/images/resolutions/" + allVoornemens[intCurrentResolution].id + ".png");
			$("a.dit-ga-ik-vandaag-doen").addClass("bg-"+allVoornemens[intCurrentResolution].color);
			// Add load event handler.
			$(img).load(function () {
				// Set src attribute.
				imgResolution.attr("src", this.src);

				// Fade in loaded resolution.
				imgResolution.fadeIn();
			});

			// Clear img var.
			img = null;
		});
	}
	function playBackToResolution(clickedBtn) {
		if (typeof _gaq != 'undefined'){
			_gaq.push(['_trackEvent', 'home', 'terug-naar-voornemen']);
		}
		// Disable ahrefs.

		disableAHrefs();
		
		if(clickedBtn != "resolution")
		{
			$("#voornemens #explanation-container").stop().animate({
				top:-500
			}, {
				duration: 600,
				specialEasing: {
					top:'easeInBack'
				}
			});
		
		
			$("#voornemens #good-inside-container").stop().animate({
				top:-500
			}, {
				duration: 600,
				specialEasing: {
					top:'easeInBack'
				}
			});
		}
		else
		{
			$("#voornemens #voornemen-content").stop().animate({
				top:-500
			}, {
				duration: 600,
				specialEasing: {
					top:'easeInBack'
				}
			});
		}
		
		$('#voornemens').trigger('rollBack');
		
		$("#voornemens .bottles").stop().delay(400).animate({
			left:120
		}, {
			duration: 400,
			specialEasing: {
				left:'easeInBack'
			},
			complete: function() {
				
				//console_log(clickedBtn);
				
				if(clickedBtn != "explanation" && clickedBtn != "resolution"){
					turnBottle("backward", "normal");
					
				}
				
				$(".resolution-arrows-container").fadeIn();
				$(".dit-ga-ik-vandaag-doen").fadeIn();
				$(".wat-is-dit").fadeIn();
				
			}
		});
/*
		var intID = window.setTimeout(function() {	
			// Show containers.
			showResolutionContainers();

			// Enable ahrefs.
			enableAHrefs();
			
		}, 1250);
		*/
	}
	
	
	function hideButtonsAndShowGoodInsideContainer() {
			$("#voornemens #good-inside-container").show();

			$(".resolution-arrows-container").fadeOut();
			$(".dit-ga-ik-vandaag-doen").fadeOut();
			$(".wat-is-dit").hide();

			$("#voornemens .bottles").stop().animate({
				left:0
			}, {
				duration: 600,
				specialEasing: {
					left:'easeOutCubic'
				}
			});

			$("#voornemens #good-inside-container").stop().delay(200).animate({
				top:140
			}, {
				duration: 600,
				specialEasing: {
					top:'easeOutBack'
				}
			});
	}
	function showResolutionContainers() {
		$(".resolution-arrows-container").fadeIn("slow");
		imgResolution.fadeIn("slow");
	}
	/// Disables the ahrefs, needed because otherwise the animation will go corrupt.
	function disableAHrefs() {
		aPlayGoodOnInsideAnimation.attr('disabled', 'disabled');
		aPlayBackToResolution.attr('disabled', 'disabled');
	}
	/// Enables the ahrefs.
	function enableAHrefs() {
		aPlayGoodOnInsideAnimation.removeAttr('disabled');
		aPlayBackToResolution.removeAttr('disabled');
	}

	function showExplanation(){
		if (typeof _gaq != 'undefined'){
			_gaq.push(['_trackEvent', 'home', 'wil-doet-dit']);
		}
		
		$('.wat-is-dit').trigger('showExplanation');
		$("#voornemens #explanation-container").show();
		
		$(".resolution-arrows-container").fadeOut();
		$(".dit-ga-ik-vandaag-doen").fadeOut();
		$(".wat-is-dit").hide();
		
		$("#voornemens .bottles").stop().animate({
			left:0
		}, {
			duration: 600,
			specialEasing: {
				left:'easeOutCubic'
			}
		});

		$("#voornemens #explanation-container").stop().delay(200).animate({
			top:100
		}, {
			duration: 500,
			specialEasing: {
				top:'easeOutBack'
			}
		});
		
	}
	
	function arrowOver(){
		
		//console_log($(this).attr("class")+" over");
		
		var leftPos;
		
		if($(this).attr("class") == "go-to-good-inside"){
			leftPos = 265;
		} else {
			leftPos = 115;
		}

		$("#voornemens ."+$(this).attr("class")+"-image").stop().animate({
				left:leftPos
			}, {
				duration: 400,
				specialEasing: {
				left:'easeOutBack'
			}
		});
		
	}
	
	function arrowOut(){
		
		var leftPos;
		
		//console_log($(this).attr("class")+" out");
		
		if($(this).attr("class") == "go-to-good-inside"){
			leftPos = 255;
		} else {
			leftPos = 125;
		}
		
		$("#voornemens ."+$(this).attr("class")+"-image").stop().animate({
				left:leftPos
			}, {
				duration: 400,
				specialEasing: {
				left:'easeOutBack'
			}
		});
		
	}
	
	
	function showStap0(){
		
		$("#voornemens .bottles").css({left: 0, top: 20}).show();
		$("#voornemens .bottles .first-visit-bottle").show();
		$("#voornemens #first-visit-container").show();
		
		$(".probeer-maar").bind("click", animateToStap1);
		$(".resolution-buttons-container .go-to-good-inside").bind('click', animateToStap0);
		
		loadIntroAnimation();
	}
	
	function animateToStap0(){
		
		$('.go-to-good-inside').trigger('startUitleg');
		
		if (typeof _gaq != 'undefined'){
			_gaq.push(['_trackEvent', 'home', 'wil-je-uitleg']);
		}
	//	alert("animateToStap0");
		$("#voornemens .bottles .first-visit-bottle img").css({"display": "block", "position" : "absolute", left: 2, top:1});
		$("#voornemens .wat-is-dit").unbind('mouseenter mouseleave');

		$("#voornemens .resolution-buttons-container").fadeOut();
		$("#voornemens .resolution-arrows-container").fadeOut();
		$("#voornemens .dit-ga-ik-vandaag-doen").fadeOut();
		$("#voornemens .wat-is-dit").hide();
		
		$("#voornemens .bottles .resolutions-bottle").fadeOut(400, function(){
			
			$("#first-glow").stop().animate({
				left:-250
			}, {
				duration: 400
			});
			
			$("#voornemens .bottles").stop().animate(
				{
					left:0
				}, 
				{
					duration: 400,
					specialEasing: {
					left:'easeInOutBack'
				}, 
				complete: function() {
					
					$("#voornemens .bottles .first-visit-bottle").fadeIn(400, function(){
						$("#voornemens #first-visit-container").fadeIn(400, function(){
							loadIntroAnimation();
						});
					});
					
				}
			});
		
		});

	}
	
	var introInserted = false;
	
	function loadIntroAnimation(){
		var introSprite = new Image();

		// Wrap new image in jQuery and set source.

		if(!introInserted){
			$(introSprite).attr("src", "/wp-content/plugins/buddypress/bp-themes/actimel/_inc/images/resolutions/BottleSequenceSpriteIntro.png");		
		} else {
			startIntroAnimation();
		}
	
		$(introSprite).load(function () {
			$("#voornemens .bottles .first-visit-bottle").append(introSprite);
			$("#voornemens .bottles .first-visit-bottle img").css({"display": "block", "position" : "absolute", left: 2, top:1});
			introInserted = true;
			////console.log("loaded!");
			startIntroAnimation();
		});
	}
	
	function startIntroAnimation(){
		
		var intervalCount = 0;
		var positionCount = 0;
		var pauseIt = false;
		
		s = self.setInterval( function() {
			
			if(intervalCount == 7){
				pauseIt = true;
			} else if (intervalCount == 87){
				pauseIt = false;
			} else if (intervalCount == 93){
				pauseIt = true;
			} else if (intervalCount == 173){
				pauseIt = false;
			} else if (intervalCount == 179){
				pauseIt = true;
			} else if (intervalCount == 259){
				pauseIt = false;
			} else if (intervalCount == 265){
				pauseIt = true;
			} else if (intervalCount == 345){
				pauseIt = false;
			} else if (intervalCount == 351){
				pauseIt = true;
			} else if (intervalCount == 431){
				pauseIt = false;
			} else if (intervalCount == 437){
				pauseIt = true;
				s = window.clearInterval(s);
			}
			
			if( !pauseIt ){
				
				var pos = -positionCount*218;
				$("#voornemens .bottles .first-visit-bottle img").css({left:pos});
				positionCount++;
				
			}
			
			intervalCount++;
			
		}, 45);
	}
	
	function showStap1(){
		
		$("#first-glow").css('left', -100);
		$("#voornemens .bottles").css({left: 120, top: 20}).show();
		$("#voornemens .bottles .resolutions-bottle").show();
		$("#voornemens .resolution-buttons-container").show();
		$("#voornemens .resolution-arrows-container").show();
		$("#voornemens .dit-ga-ik-vandaag-doen").show();
		$("#voornemens .wat-is-dit").show();
		
		imgResolution.fadeIn("swing");
		
		$("#voornemens .give-me-new-resolution-image").delay(700).show().animate({
				left:125
			}, {
				duration: 400,
				specialEasing: {
				left:'easeOutBack'
			}
		});
		
		$("#voornemens .go-to-good-inside-image").delay(700).show().animate({
				left:255
			}, {
				duration: 400,
				specialEasing: {
				left:'easeOutBack'
			}, 
			complete: function() {
				$(".resolution-buttons-container a").hover(arrowOver,arrowOut);
				activateStap1();
			}
		});
		
		
		
		$(".probeer-maar").bind("click", animateToStap1);
		$(".resolution-buttons-container .go-to-good-inside").bind('click', animateToStap0);
	}

	function animateToStap1(){
		
		$('.probeer-maar').trigger('rollBack');
		
		if(GetCookie("FIRST_VISIT") == null){
			setCookie("FIRST_VISIT", "here", 1000000);
		}
		
		s = window.clearInterval(s);
		//alert("animateToStap1");
		$("#voornemens .bottles .first-visit-bottle").fadeOut();
		
		$("#voornemens #first-visit-container").fadeOut();
		$("#voornemens .first-visit-bottle").fadeOut(function(){

			$("#first-glow").stop().animate({
				left:-100
			}, {
				duration: 400
			});

			$("#voornemens .bottles").stop().animate({
					left:120
				}, {
					duration: 400,
					specialEasing: {
					left:'easeOutBack'
				}, 

				complete: function() {

					$("#voornemens .bottles .resolutions-bottle").fadeIn();
					$("#voornemens .resolution-buttons-container").fadeIn();
					$("#voornemens .resolution-arrows-container").fadeIn();
					$("#voornemens .dit-ga-ik-vandaag-doen").fadeIn();
					$("#voornemens .wat-is-dit").fadeIn();

					imgResolution.fadeIn("swing");

					$("#voornemens .give-me-new-resolution-image").delay(700).show().animate({
							left:125
						}, {
							duration: 400,
							specialEasing: {
							left:'easeOutBack'
						}
					});

					$("#voornemens .go-to-good-inside-image").delay(700).show().animate({
							left:255
						}, {
							duration: 400,
							specialEasing: {
							left:'easeOutBack'
						}, 
						complete: function() {
							$(".resolution-buttons-container a").hover(arrowOver,arrowOut);
							activateStap1();
						
						}
					});
				}
				
			});

		});

	}
	
	function activateStap1(){
		
		$("#voornemens .wat-is-dit").hover(watIsDitOver, watIsDitOut);

	}
	
	function watIsDitOver(){
		
		$("#voornemens .wat-is-dit").stop().html("").animate({
			width:78
		}, {
			duration: 150,
			specialEasing: {
				marginTop:'easeOutCubic'
			}, 
			complete: function() {
				$(this).html("Wat is dit?");
			}
		});
		
	}
	
	function watIsDitOut(){
		$("#voornemens .wat-is-dit").stop().html("").animate({
			width:9
		}, {
			duration: 150,
			specialEasing: {
			marginTop:'easeOutCubic'
		}, 
			complete: function() {
				$(this).html("?");
			}
		});
	}
	
	$(document).ready(function() {
		aPlayGoodOnInsideAnimation = $(".go-to-good-inside");
		aPlayGiveMeNewResolution = $(".give-me-new-resolution");
		aPlayBackToResolution = $(".back-to-resolution");
		imgResolution = $(".image-resolution");
	
	
		
		if(GetCookie("FIRST_VISIT") == null){
			showStap0();
		} else {
			////console.log("cookie found");
			showStap1();
		}

		$("#voornemens .wat-is-dit").bind('click', showExplanation);
		$(".resolution-buttons-container .give-me-new-resolution").bind('click', playGiveMeNewResolutionAnimation);
		
	});

	function fillRespects() {
		
		//var fbsrc = '<fb:like href="'+baseURL+'/'+voornemenLink+'" send="false" layout="button_count" width="100"  show_faces="false"></fb:like>';
		//$('#facebook-like').html(fbsrc);
		
		//$("#addThis-wrap").html('<!-- AddThis Button BEGIN --><div class="addthis_toolbox addthis_default_style "><a class="addthis_button_facebook_like"></a><a class="addthis_button_tweet" tw:count="none"></a><a class="addthis_button_hyves_respect"></a><a class="addthis_button_compact"></a><a class="addthis_counter addthis_bubble_style"></a></div><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4eb12c313ac18762"></script><!-- AddThis Button END -->');
		$("#addthis-frame").attr('src',baseURL+'/wp-content/plugins/buddypress/bp-themes/actimel//addthis.php?url='+baseURL+'/'+voornemenLink);

		//console.log('change frame');

		//var hysrc = '<iframe src="http://www.hyves.nl/respect/button?url='+baseURL+'/'+voornemenLink+'&amp;counterStyle=no-count" style="margin-left: 4px; margin-top: 1px; border: medium none; overflow:hidden; width:70px; height:81px;" scrolling="no" frameborder="0" ></iframe>';
		//$('#hyves-respect').html(hysrc);

		/*var twsrc = '<a href="https://twitter.com/share" class="twitter-share-button" data-url="'+baseURL+'/'+voornemenLink+'" data-text="'+voornemenText+' #voelmegoed" data-count="none">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>';
		$('#tweet-respect').html(twsrc);*/
	}
			
	function setCookie(c_name,value,exdays)
	{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
	}
	
	function GetCookie(name) {
		var arg=name+"=";
		var alen=arg.length;
		var clen=document.cookie.length;
		var i=0;
		while (i<clen) {
			var j=i+alen;
			if (document.cookie.substring(i,j)==arg)
			return "here";
			i=document.cookie.indexOf(" ",i)+1;
			if (i==0) break;
		}
		return null;
	}
