		$(function(){
		
			function randomposition(){
				return Math.floor(Math.random()* 800) + "px";
			}
			
			if( $.cookie('visited') !="yes"){
				$("#overlay").show().delay(30000).fadeOut(500);
				$.cookie('visited', 'yes');
			}		

			$("#overlay, #inner_overlay").click(function(){$("#overlay").clearQueue().fadeOut(600);});	
			
			$("#message").focus();
			
			$(".draggable, #uploadform").draggable({ cursor: 'move', zIndex: 99999, stack: '#postits div' });

			$(".draggable").hover(function(){
				if( ! $(this).hasClass("widebox") ) {
					$(this).css("z-index", "9999999");
			  		$(this).animate({ 
			    		width: "180px",
			    		height: "180px"
			  		}, "fast" );
				}
			},function(){
				if( ! $(this).hasClass("widebox") ) {
					$(this).animate({ 
				    	width: "170px",
				    	height: "170px"
				  	}, 500 );
				  	$(this).css("z-index", "999");	
				}	
			});
			
			$("#logo").draggable({
				start: function() {$(this).removeClass();},
				drag: function() {$(this).removeClass();},
				stop: function() {
					$("#logo img").attr("src", "/images/assets/logos/" + logos[Math.floor(Math.random()*logos.length)])
				}
			});

			$("#uploadform").css(
				"left", randomposition(),
				"top", randomposition()
			);
						
			$("#logo").css(
				"left", randomposition(),
				"top", randomposition()
			);

			var colors = [ "#d0d9fd", "#cff1fd", "#fdd5d5", "#e4fdcf", "#fbfdcf","#cefde7", "#fed6f3"];

			$(".box").each(function() {
				var rand_number = Math.floor(Math.random()*colors.length);
				$(this).css("background", colors[rand_number]);
				$(this).css("left", randomposition());
				$(this).css("top", randomposition());
			});
			
			$("#openabout").click(function(){
				$("#overlay").fadeIn(500).delay(30000).fadeOut(500);
				return false;
			});

			$("#listview").click(function(){
				$("body").css("overflow-y","visible");
				$(".box").addClass("widebox");
				$(".box").css({ 
					width: "95%"
				});
				  		
				$('#postits').isotope({ layoutMode : "straightDown" });
			});
		
			$("#gridview").click(function(){
				$("body").css("overflow-y","visible");
				$(".box").removeClass("widebox");
				$(".box").css({ 
					width: "170px",
				    height: "170px",
				    marginRight: "5px",
				    marginBottom: "5px"
				});		
					
				$('#postits').isotope({ layoutMode : "fitRows" });
			});	
		
			$("#randomview").click(function(){
				/*
				$('#postits').isotope( 'destroy' );
				$("body").css("overflow-y","hidden");
				$(".box").removeClass("widebox");
				$(".box").css({ 
					width: "170px",
				    height: "170px",
				    marginRight: "5px",
				    marginBottom: "5px"
				});		
					
				$(".box").each(function() {
					$(this).css("left", randomposition());
					$(this).css("top", randomposition());
				});
				*/
				 location.reload();
			});						
			
			$("#logo, #overlay #continue_link img").hover(function() {
			    $(this).fadeTo("fast", .7);
			 }, function(){
			 	$(this).fadeTo("fast", 1);
			 });

			$("#logo img").attr("src", "/images/assets/logos/" + logos[Math.floor(Math.random()*logos.length)]);
			
			$("#logo").click(function(){
				$("#logo img").attr("src", "/images/assets/logos/" + logos[Math.floor(Math.random()*logos.length)]);
			});

			$("#step1 #send").click(function(){
				if($("#message").val() == "" ){$("#message").fadeOut(300).fadeIn(300);}				
				
				else {
					$("#step1").fadeOut(400);
					$("#step2").delay(400).fadeIn();
					$("#voornaam").focus();
					$("#next img,#prev img").css("opacity",.7);
				}
			});
			
			$("#prev img").hover(function(){
				$(this).fadeTo("fast", 1);
			}, function(){
				$(this).fadeTo("fast", .7);
			});
			
			
			$("#step2 .confirmed").live('click', function(){
				$("#step2").fadeOut(400);
				$("#step3").delay(400).fadeIn();
				$("#email").focus();
			});			

			$("#voornaam,#achternaam").keyup(function(){
				if( $("#voornaam").val() !="" && $("#achternaam").val() !=""){
					$("#step2 #next").addClass("confirmed");
					$("#step2 #next img").css("opacity",1);
				}
				else{
					$("#step2 #next img").css("opacity",.7);
					$("#step2 #next").removeClass("confirmed");
				}
			});
			
			$("#email").keyup(function(){
				if ( $("#email").val().match("@") ) {
					$("#step3 #next").addClass("confirmed");
					$("#step3 #next img").css("opacity",1);
				}
				else{
					$("#step3 #next img").css("opacity",.7);
					$("#step3 #next").removeClass("confirmed");
				}
			});			
			
			$("#step2 #prev").click(function(){
				$("#step2").fadeOut(400);
				$("#step1").delay(400).fadeIn();
			});

			$("#step3 #prev").click(function(){
				$("#step3").fadeOut(400);
				$("#step2").delay(400).fadeIn();
			});	
			
			$("#step3 .confirmed").live('click', function(){
				$("#step3").fadeOut(400);
				$("#freeform").submit();
				$("#step4").delay(400).fadeIn();
			});				
			
			$(".listname").each(function() {
				var rand_number = Math.floor(Math.random()*colors.length);
				$(this).css("background", colors[rand_number]);
			});
			
			$("#message").keyup(function(){
				$("#sendbutton").hide();
				$("#send").css("background","#cd0099");
				$("#count").show().html( $(".counter").html() );
				Cufon.refresh();
			});
			
			$("#message").delayedObserver(function() {
			    $("#count").hide();
			    $("#send").css("background","#2fc2d3");
			    $("#sendbutton").show();			    
			}, 2);
			
			$("#message").charCounter(140, {
				container: "<div></div>",
				classname: "counter",
				format: "%1",
				pulse: false,
				delay: 0
			});	
			
			$("#step2, #step3, #step4").hide();
			
		});
		
		
		
		
		Cufon.replace('.content, #overlay', { fontFamily: 'Sentinel' });
		Cufon.replace('#overlay h2, .content h2', { fontFamily: 'sentinel bold' });
		Cufon.replace('label, .button, .secondsubmit, .box h2, #count,#about, #footer, #select-view a', { fontFamily: 'gotham bold' });		
