var uberZindex = 100;
var djZindex = 100000;
var current_page = "";
var current_subpage = "";
var colour = "";

$(document).ready(function() {
      // Typography
      Cufon.replace('h2, .acts li', { fontFamily: 'Gotham Light', hover: true });
      Cufon.replace('#menu a', { fontFamily: 'Gotham Black', hover: true });
      
      $(".submitbtn").click(function () {
      	submit_vrijwilligers();
      });
      
      //Cycles
		$('#slides').cycle({ 
			fx:     'scrollVert', 
			prev:   '#prev', 
			next:   '#next', 
			timeout: 6000,
			speed: 	 'fast',
			pager:  '#nav',
			pagerAnchorBuilder: function(idx, slide) { 
			return '<a href="#"></a>'; 
		}
		});
      $("#slides").hover(function() {
		   $("#slides").cycle('pause');
		}, function() {
		   $("#slides").cycle('resume');  
		});
      
      $(".picdj-cycle").cycle({ 
			fx:     'fade',
			timeout: 4000,
			speed: 	 'fast'
		});
      $("#tweets").hover(function() {
		   $("#tweets").cycle('pause');
		}, function() {
		   $("#tweets").cycle('resume');  
		});
   
		// Draggin'
		$("div.block:not(#djcontest_text)").draggable({
			start: function () {
			
				$(this).css("z-index", uberZindex);
				
				uberZindex++;
			
			},
			stop: function () {
				bounceUp(this);
			}
		}).css("cursor", "move");
		
		// No draggin
		$( "#subsponsors div" ).draggable( "disable" )
     
      //make some links external
      $("#tweets a, .typeDJ a").each(function () {
         $(this).attr("target", "_blank");   
      });

      //back button DJs
      $(".typeDJ .back").css("cursor", "pointer").click(function () {
         window.location = "/#/";
         
         close_all_house_o_love();
         close_all_volt();
         
         fadeToBlue();
         animate_home_in_weinig();
      });

      //vrijwilligersknop
      $(".freewilly-btn, .freewillybg").click(function () {
         
		  $(".freewillyform").toggle();
		  $(".freewillybg").toggle();
		  
      });
	  
		//fanCybox -> video
		$("a.videolink").click(function() {
				$.fancybox({
						'padding'		: 0,
						'autoScale'		: false,
						'transitionIn'	: 'none',
						'overlayShow'	: true,
						'overlayOpacity': '0.6',
						'overlayColor'	: '#000000',
						'transitionOut'	: 'none',
						'centerOnScroll' : true,
						'titleShow'		: false,
						'title'			: this.title,
						'width'			: 680,
						'height'		: 495,
						'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
						'type'			: 'swf',
						'swf'			: {
						
							'wmode'				: 'transparent',
							'allowfullscreen'	: 'true'
							
						}
					});

				return false;
			});
         
      $("#container #header #menu .btn a").click(function() {
         $("#container #header #menu .btn a").removeClass("on");
         $(this).addClass("on");
      });	  

      page_init();
      balloon_cycle();
      
      $('#tweets').cycle({ 
			fx:     'scrollHorz',
			timeout: 8000,
			speed: 	 'fast'
		});
      $("#tweets").hover(function() {
		   $("#tweets").cycle('pause');
		}, function() {
		   $("#tweets").cycle('resume');  
		});
		
	  // stick + win cycle	
      $('.stickwin_cycler').cycle({ 
			fx:     'fade',
			timeout: 3000,
			speed: 	 'fast'
		});		
});

function balloon_cycle() {
	var window_width = $(window).width();
	$("#balloon").css({
		left: "-600px"
	}).animate({
		left: (window_width + 300) + "px"
	}, 50000, "linear", function () {
		balloon_cycle();
	});
}

function balloon_kill() {
	var window_width = $(window).width();
	$("#balloon").stop().animate({
		top: "-600px",
		left: window_width + "px"
	}, {
		specialEasing: {
			top: "easeInCirc",
			left: "easeInExpo"
		},
		duration: 4000
	});
}

/* Hash convertion & init page */
function page_init() {
   read_hash();
   
   setInterval(function () {
      read_hash();
   }, 100);
   
   //slide header
   $("#header").delay(1000).animate({
      marginTop: "0px"
   }, 2500, "easeOutBounce", function () {
      
   });
}

function read_hash() {
   var hash = window.location.hash;
   hash = hash.substring(2);
   
   if (hash.length > 0) {
      var location = hash.split("/");
      var section = location[0];   
   } else {
      var section = "home";
   }
   
   switch (section) {
      case "djcontest":
         animate_djcontest_in();
      break;
      
      case "contest":
         animate_contest_in();
      break;
      
      case "partners":
         animate_partners_in();
      break;
      
      case "information":
         animate_information_in();
      break;
      
      case "buytickets":
         animate_tickets_in();
      break;
      
      case "win":
         animate_win_in();
      break;
      
      case "impressions":
         animate_impressions_in();
      break;
      
      case "dj":      
         switch (location[1]) {
            //love
            case "samson":
               load_dj("samson", "love");
            break;
            
            case "gregorsalto":
               load_dj("gregorsalto", "love");
            break;
            
            case "mason":
               load_dj("mason", "love");
            break;
            
            case "boemklatsch":
               load_dj("boemklatsch", "love");
            break;
            
            case "romero":
               load_dj("romero", "love");
            break;
            
            case "skitzofrenix":
               load_dj("skitzofrenix", "love");
            break;
            
            case "shermanology":
               load_dj("shermanology", "love");
            break;
            
            case "becharmd":
               load_dj("becharmd", "love");
            break;
            
            case "bassjackers":
               load_dj("bassjackers", "love");
            break;
            
            case "boogshe":
               load_dj("boogshe", "love");
            break;
            
            case "bizzey":
               load_dj("bizzey", "love");
            break;
            
            //volt
            case "darkoesser":
               load_dj("darkoesser", "volt");
            break;
            
            case "nakadia":
               load_dj("nakadia", "volt");
            break;
            
            case "skils":
               load_dj("skils", "volt");
            break;
            
            case "fellow":
               load_dj("fellow", "volt");
            break;
            
            case "kamara":
               load_dj("kamara", "volt");
            break;
            
            case "normano":
               load_dj("normano", "volt");
            break;
            
            case "menno":
               load_dj("menno", "volt");
            break;
         }
      break;
      
      default:
         if (current_page == "" || current_page != "dj") {
            fadeToBlue();
            animate_out_everything();
            animate_home_in();
         }
         current_page = "dj";
         current_subpage = "";
      break;
   }
}

/* Color fades */
function fadeToBlue(oncomplete) {
   colour = "blue";
   if (!$("body").hasClass("bg-blue")) {
      destroy_clouds();
      destroy_heart();
      destroy_struck();

      $("body").animate({
         backgroundColor: "#6dcef5"
      }, 1000, "linear", function () {
         $("body").removeClass("bg-black");
         $("body").addClass("bg-blue");

         init_clouds();
         init_heart();
         
         if (typeof eval(oncomplete) == 'function') {
            oncomplete();
         }
      });
   } else {
      if (typeof eval(oncomplete) == 'function') {
         oncomplete();
      }
   }
}

function fadeToBlack(oncomplete) {
   colour = "black";
   if (!$("body").hasClass("bg-black")) {
      destroy_clouds();
      destroy_heart();
      destroy_struck();

      $("body").animate({
         backgroundColor: "#262622"
      }, 1000, "linear", function () {
         $("body").removeClass("bg-blue");
         $("body").addClass("bg-black");

         init_clouds();
         init_struck();
         
         if (typeof eval(oncomplete) == 'function') {
            oncomplete();
         }
      });
   } else {
      if (typeof eval(oncomplete) == 'function') {
         oncomplete();
      }
   }
}

/* content animations */
function bounceUp(obj) {	
	$(obj).animate({
		marginTop: "+20px"
	}, 100, "linear", function () {
		bounceDown(obj);
	});
}

function bounceDown(obj) {	
	var rand = Math.random()*200 + 300;

	$(obj).animate({
		marginTop: "0px"
	}, rand, "easeOutBounce", function () {
		//bounceUp(obj); //will end in endless cycle
	});
}

/* cloud animations */
function init_clouds() {
   if (!$.browser.msie ) {
      for (var i = 0; i < 10; i++) {
   		var left = Math.random()*$(window).width();
   		var top = Math.random()*$(window).height();
   		var opacity = Math.random()*0.5 + 0.5;
   
   		var className = "cloud";
   		if (i > 3) {
   			var className = "cloud2";
   		}
   
   		var newCloud = $("<div class='" + className + "'>").css({
   			left: left + "px",
   			top: top + "px",
   			opacity: 0
   		}).prependTo("body");
         $(newCloud).animate({
            opacity: opacity
         }, 400, "linear")
   
   		var rand = Math.random()*500 + 300;
   		var leftright = Math.random()*2;
   		if (leftright > 1) {
   			cloudMove(newCloud, "right", rand);
   		} else {
   			cloudMove(newCloud, "left", rand);
   		}
      }
   }
}

function destroy_clouds() {
   $(".cloud, .cloud2").each(function () {
      $(this).stop().animate({
         opacity: 0
      }, 500, "linear", function () {
         $(".cloud, .cloud2").remove();
      });
   });
}

function cloudMove(cloud, dir, speed) {
	if (dir == "left") {
		$(cloud).animate({
			left: "-=20px"
		}, speed, "linear", function () {
			var offset = $(cloud).offset();
			if (offset.left < -200) {
				var top = Math.random()*$(window).height();
				$(cloud).css({
					"left": $(window).width() + "px",
					"top": top + "px"
				});
			}
			cloudMove(cloud, dir, speed);
		});
	} else if (dir == "right") {
		$(cloud).animate({
			left: "+=20px"
		}, speed, "linear", function () {
			var offset = $(cloud).offset();
			if (offset.left > $(window).width() + 200) {
				var top = Math.random()*$(window).height();
				$(cloud).css({
					"left": "-200px",
					"top": top + "px"
				});
			}
			cloudMove(cloud, dir, speed);
		});
	}
}

function init_struck() {
   if (!$.browser.msie ) {
   	var left = Math.random()*$(window).width();
   	var top = Math.random()*$(window).height();
   
   	if (colour == "black") {
         var newStruck = $("<div class='struck'></div>").css({
         	left: left + "px",
         	top: top + "px",
         	opacity: 1
         }).prependTo("body");
         animate_struck(newStruck);  
   	}
   }
}

function animate_struck(obj) {  
   $(obj).animate({
      top: "+=150",
      left: "-=75"
   }, 100, "linear", function() {
      $(this).animate({
         left: "+=75"
      }, 100, "linear", function() {
         $(this).animate({
            top: "+=200",
            left: "-=75",
            opacity: 0
         }, 100, "linear", function() {
            $(this).animate({
               left: 10
            }, 1000, "linear", function () {
               init_struck();
               $(this).remove();
            });
         });
      });
   });
}

function destroy_struck() {
   $(".struck").remove();
}

function init_heart() {
   if (!$.browser.msie ) {
   	var left = Math.random()*$(window).width();
   	var top = $(window).height() + 150;
   
   	var newHeart = $("<div class='heart'></div>").css({
   		left: left + "px",
   		top: top + "px",
   		opacity: 1
   	}).prependTo("body");
      animate_heart(newHeart);
   }
}

function animate_heart(obj) {  
   var left = Math.random()*$(window).width() - 75;
	var top = $(window).height() + 150;
   
   $(obj).css({
		left: left + "px",
		top: top + "px"
	});
   $(obj).animate({
      top: "-150px"
   }, 10000, "linear", function() {
      animate_heart(this);
   });
}

function destroy_heart() {
   $(".heart").each(function () {
     $(this).stop().animate({
         opacity: 0
      }, 500, "linear", function () {
         $(".heart").remove();
      });
   });
}

/* PAGE IN OUT ANIMATIONS */
function animate_out_everything() {
   animate_home_out();
   close_all_house_o_love();
   close_all_volt();
   
   animate_tickets_out();
   animate_impressions_out();
   animate_information_out();
   animate_partners_out();
   animate_djcontest_out();
   animate_contest_out();
   animate_win_out();
}

function animate_contest_in() {
   //DJ CONTEST IN
   if (current_page != "contest") {
      animate_out_everything();
      fadeToBlue();
      
      $("#contest_text").css({
         display: "block"
      }).stop().animate({
         left: "-10px",
         top: "10px"
      }, 2000, "easeInOutExpo");
      $("#djcontest_picture").css({
         display: "block"
      }).stop().animate({
         left: "530px",
         top: "10px"
      }, 2100, "easeInOutExpo");
   }
   current_page = "contest";
   current_subpage = "";
}

function animate_contest_out() {
   //DJ CONTEST OUT
   $("#contest_text").stop().animate({
      left: "-1400px",
      top: "10px"
   }, 2000, "easeInOutExpo", function() {
      $(this).css("display", "none");
   });
    $("#djcontest_picture").stop().animate({
      left: "2000px",
      top: "10px"
   }, 2100, "easeInOutExpo", function() {
      $(this).css("display", "none");
   });
}

function animate_djcontest_in() {
   //DJ CONTEST IN
   if (current_page != "djcontest") {
      animate_out_everything();
      fadeToBlue();
      
      $("#djcontest_text").css({
         display: "block"
      }).stop().animate({
         left: "-10px",
         top: "10px"
      }, 2000, "easeInOutExpo");
      $("#djcontest_picture").css({
         display: "block"
      }).stop().animate({
         left: "530px",
         top: "10px"
      }, 2100, "easeInOutExpo");
   }
   current_page = "djcontest";
   current_subpage = "";
}

function animate_djcontest_out() {
   //DJ CONTEST OUT
   $("#djcontest_text").stop().animate({
      left: "-1400px",
      top: "10px"
   }, 2000, "easeInOutExpo", function() {
      $(this).css("display", "none");
   });
   $("#djcontest_picture").stop().animate({
      left: "2000px",
      top: "10px"
   }, 2100, "easeInOutExpo", function() {
      $(this).css("display", "none");
   });
}

function animate_partners_in() {
   //PARTNERS IN
   if (current_page != "partners") {
      animate_out_everything();
      fadeToBlue();
      
      $("#sponsor1").stop().animate({
         left: "-10px",
         top: "15px"
      }, 5000, "easeOutElastic");
      $("#sponsor2").stop().animate({
         left: "193px",
         top: "15px"
      }, 4500, "easeOutElastic");
      $("#sponsor3").stop().animate({
         left: "393px",
         top: "15px"
      }, 4000, "easeOutElastic");
      $("#sponsor4").stop().animate({
         left: "593px",
         top: "15px"
      }, 3500, "easeOutElastic");
      $("#sponsor5").stop().animate({
         left: "795px",
         top: "15px"
      }, 3000, "easeOutElastic");
      
      $("#subsponsors").css({
         display: "block"
      }).stop().animate({
         left: "-17px"
      }, 5000, "easeOutElastic");
   }
   current_page = "partners";
   current_subpage = "";
}

function animate_partners_out() {
   //PARTNERS OUT
   $("#sponsor1").stop().animate({
      left: "-1400px",
      top: "15px"
   }, 2000, "easeInElastic");
   $("#sponsor2").stop().animate({
      left: "-1400px",
      top: "15px"
   }, 2000, "easeInElastic");
   $("#sponsor3").stop().animate({
      left: "-1400px",
      top: "15px"
   }, 2000, "easeInElastic");
   $("#sponsor4").stop().animate({
      left: "-1400px",
      top: "15px"
   }, 2000, "easeInElastic");
   $("#sponsor5").stop().animate({
      left: "-1400px",
      top: "15px"
   }, 2000, "easeInElastic");
   
   $("#subsponsors").stop().animate({
      left: "2000px"
   }, 1500, "easeInBack", function() {
      $(this).css("display", "none");
   });
}

function animate_information_in() {
   //INFORMATION IN  
   if (current_page != "information") {
      animate_out_everything();
      fadeToBlue();
      
      $("#left_1").css({
         display: "block"
      }).stop().animate({
         left: "0px",
         top: "0px"  
      }, 2000, "easeInOutBack");
      $("#left_2").css({
         display: "block"
      }).stop().animate({
         left: "-10px",
         top: "240px"  
      }, 2200, "easeInOutBack");
      $("#left_3").css({
         display: "block"
      }).stop().animate({
         left: "0px",
         top: "457px"  
      }, 2400, "easeInOutBack");    
      
      $("#right_1").css({
         display: "block"
      }).stop().animate({
         left: "330px",
         top: "0px"  
      }, 3000, "easeInOutBack");    
      $("#right_2").css({
         display: "block"
      }).stop().animate({
         left: "660px",
         top: "0px"  
      }, 3400, "easeInOutBack"); 
      
   }
   current_page = "information";
   current_subpage = ""; 
}

function animate_information_out() {
   //INFORMATION OUT
   $("#left_1").stop().animate({
      left: "-1400px",
      top: "0px"  
   }, 2000, "easeInOutBack", function() {
      $(this).css("display", "none");
   });
   $("#left_2").stop().animate({
      left: "-1400px",
      top: "240px"  
   }, 2200, "easeInOutBack", function() {
      $(this).css("display", "none");
   });
   $("#left_3").stop().animate({
      left: "-1400px",
      top: "457px"  
   }, 2400, "easeInOutBack", function() {
      $(this).css("display", "none");
   });    
   
   $("#right_1").stop().animate({
      left: "2000px",
      top: "0px"  
   }, 3000, "easeInOutBack", function() {
      $(this).css("display", "none");
   });    
   $("#right_2").stop().animate({
      left: "2000px",
      top: "0px"  
   }, 3400, "easeInOutBack", function() {
      $(this).css("display", "none");
   }); 
      
}

function animate_win_in() {
   //WIN IN
   if (current_page != "win") {
   	balloon_kill();	
      animate_out_everything();
      fadeToBlue();

      $("#win_txt").css({
         display: "block"
      }).stop().animate({
         left: "515px",
         top: "0px"  
      }, 2000, "easeOutBounce");
      
      if (!$(".win-fotos").html()) {
         $(".win-fotos").html(image_html_win);
         //fanCybox
         $(".impressions-win a, #win_photos a").fancybox({
            centerOnScroll: true,
            overlayShow: false,
            titleShow: false
         });
      }
      
      $("#win_photos").css({
         display: "block"
      }).stop().animate({
         left: "-10px",
         top: "0px"  
      }, 3000, "easeInOutBounce");
   }
   current_page = "win";
   current_subpage = ""; 
}

function animate_win_out() {
   //WIN OUT
   $("#win_txt").stop().animate({
      left: "-1400px",
      top: "50px"  
   }, 1000, "easeInBack", function() {
      $(this).css("display", "none");
   });
   
   $("#win_photos").stop().animate({
      left: "2000px",
      top: "50px"  
   }, 1000, "easeInBack", function() {
      $(this).css("display", "none");
   });
}

function animate_impressions_in() {
   //IMPRESSIONS IN
   if (current_page != "impressions") {
      animate_out_everything();
      fadeToBlue();

      $("#impressions_movies").css({
         display: "block"
      }).stop().animate({
         left: "-10px",
         top: "0px"  
      }, 2000, "easeOutBounce");
      
      if (!$(".impressions-fotos").html()) {
         $(".impressions-fotos").html(image_html_impressions);
         //fanCybox
         $(".impressions-fotos a").fancybox({
            centerOnScroll: true,
            overlayShow: false,
            titleShow: false
         });
      }
      
      $("#impressions_photos").css({
         display: "block"
      }).stop().animate({
         left: "480px",
         top: "0px"  
      }, 3000, "easeInOutBounce");
   }
   current_page = "impressions";
   current_subpage = ""; 
}

function animate_impressions_out() {
   //IMPRESSIONS OUT
   $("#impressions_movies").stop().animate({
      left: "-1400px",
      top: "50px"  
   }, 1000, "easeInBack", function() {
      $(this).css("display", "none");
   });
   
   $("#impressions_photos").stop().animate({
      left: "2000px",
      top: "50px"  
   }, 1000, "easeInBack", function() {
      $(this).css("display", "none");
   });
}

function animate_tickets_in() {
   //TICKETS IN
   if (current_page != "buytickets") {
      animate_out_everything();
      fadeToBlue();
      
      $("#tickets_1").css({
         display: "block"
      }).stop().animate({
         left: "-10px",
         top: "0px"  
      }, 2000, "easeOutBack");
      $("#tickets_2").css({
         display: "block"
      }).stop().animate({
         left: "600px",
         top: "0px"  
      }, 2000, "easeOutBack");
   }
   current_page = "buytickets";
   current_subpage = ""; 
}

function animate_tickets_out() {
   //TICKETS OUT
   $("#tickets_1").stop().animate({
      left: "-1400px",
      top: "0px"  
   }, 3000, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });
   $("#tickets_2").stop().animate({
      left: "2000px",
      top: "0px"  
   }, 3000, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });
}

function animate_home_in() {   
   $("#dj_menu").css({
      display: "block"
   }).stop().animate({
      top: "40px",
      left: "-10px"
   }, 6000, "easeOutBounce");
   
   $("#outlighted_dj").css({
      display: "block"
   }).stop().animate({
      top: "380px",
      left: "330px"
   }, 4000, "easeInOutElastic");
   
   $("#aftermovie").css({
      display: "block"
   }).stop().animate({
      top: "20px",
      left: "665px"
   }, 4000, "easeInOutElastic");   
   
   $("#flashy_news").css({
      display: "block"
   }).stop().animate({
      top: "670px",
      left: "325px"   
   }, 5000, "easeInOutElastic");
   
   $("#feeds_etc").css({
      display: "block"
   }).stop().animate({
      top: "280px",
      left: "670px"
   }, 6500, "easeOutBounce");
   
   $("#stickwin_cycle").css({
      display: "block"
   }).stop().animate({
      top: "0px",
      left: "325px"   
   }, 4000, "easeInOutElastic");
  
   $("#freewilly").css({
      display: "block"
   }).stop().animate({
      top: "255px",
      left: "325px"
   }, 4000, "easeInOutElastic");
  
}

function animate_home_out(oncomplete) {
   $("#dj_menu").stop().animate({
      top: "0px",
      left: "-1400px"
   }, 3000, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });
   
   $("#outlighted_dj").stop().animate({
      top: "0px",
      left: "2000px"
   }, 2000, "easeInOutElastic", function() {
      $(this).css("display", "none");
      if (typeof eval(oncomplete) == 'function') {
         oncomplete();
      }
   });
   
   $("#aftermovie").stop().animate({
      top: "10px",
      left: "2000px"
   }, 4000, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });      
   
   $("#flashy_news").stop().animate({
      top: "0px",
      left: "-1400px"
   }, 2500, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });
   
   $("#feeds_etc").stop().animate({
      top: "0px",
      left: "2000px"
   }, 3500, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });
   
   $("#stickwin_cycle").stop().animate({
      top: "0px",
      left: "2000px"
   }, 3500, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });  
   
   $("#freewilly").stop().animate({
      top: "0px",
      left: "-2000px"
   }, 3500, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });     
}

function animate_home_out_weinig(oncomplete) {
   $("#outlighted_dj").stop().animate({
      top: "0px",
      left: "2000px"
   }, 2000, "easeInOutElastic", function() {
      $(this).css("display", "none");
      if (typeof eval(oncomplete) == 'function') {
         oncomplete();
      }
   });
   
   $("#flashy_news").stop().animate({
      top: "0px",
      left: "-1400px"
   }, 2500, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });
   
   $("#aftermovie").stop().animate({
      top: "10px",
      left: "2000px"
   }, 4000, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });      
   
   $("#feeds_etc").stop().animate({
      top: "0px",
      left: "2000px"
   }, 3500, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });
   
   $("#stickwin_cycle").stop().animate({
      top: "0px",
      left: "2000px"
   }, 3500, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });   
   
   $("#freewilly").stop().animate({
      top: "0px",
      left: "-2000px"
   }, 3500, "easeInOutElastic", function() {
      $(this).css("display", "none");
   });    
}

function animate_home_in_weinig() {     
   $("#outlighted_dj").css({
      display: "block"
   }).stop().animate({
      top: "10px",
      left: "325px"
   }, 4000, "easeInOutElastic");
   
   $("#flashy_news").css({
      display: "block"
   }).stop().animate({
      top: "385px",
      left: "320px"
   }, 5000, "easeInOutElastic");
   
   $("#feeds_etc").css({
      display: "block"
   }).stop().animate({
      top: "280px",
      left: "670px"
   }, 6500, "easeOutBounce");
   
   $("#stickwin_cycle").css({
      display: "block"
   }).stop().animate({
      top: "20px",
      left: "670px"
   }, 6500, "easeOutBounce");  

   $("#freewilly").css({
      display: "block"
   }).stop().animate({
      top: "670px",
      left: "325px"
   }, 6500, "easeOutBounce"); 
   
}

function animate_home_in_menu(oncomplete) {     
   $("#dj_menu").css({
      display: "block"
   }).stop().animate({
      top: "40px",
      left: "-10px"
   }, 6000, "easeOutBounce", function() {
      if (typeof eval(oncomplete) == 'function') {
         oncomplete();
      }
   });
}


/* DJ animation */
function load_dj(name, type) {
   if (current_page == "") {
      if (type == "love") {
         fadeToBlue();  
      } else {
         fadeToBlack();  
      }
      setTimeout(function () {
         open_dj(name, type);
      }, 2000);
      animate_home_in_menu();
   } else if (current_subpage != name) {
      open_dj(name, type);
   }
   current_page = "home";
   current_subpage = name;
}

function open_dj(name, type) {
   close_all_house_o_love();
   close_all_volt();
   
   if (type == 'love') {
      house_o_love_in(name);
      fadeToBlue();   
   } else {
      volt_in(name);
      fadeToBlack();  
   }
   
   animate_home_out_weinig();
}

function close_all_house_o_love() {
	house_o_love_out("samson");
	house_o_love_out("gregorsalto");
	house_o_love_out("mason");
	house_o_love_out("boemklatsch");
	house_o_love_out("romero");
	house_o_love_out("skitzofrenix");
	house_o_love_out("shermanology");
	house_o_love_out("becharmd");
	house_o_love_out("bassjackers");
	house_o_love_out("boogshe");
	house_o_love_out("bizzey");
}

function close_all_volt() {
   volt_out("darkoesser");
   volt_out("nakadia");
   volt_out("skils");
   volt_out("fellow");
   volt_out("kamara");
   volt_out("normano");
   volt_out("menno");
}

function house_o_love_in(name) {
   djZindex++;
   $("#house_o_love_" + name).css({
      "z-index": djZindex,
      display: "block"
   }).stop().animate({
      top: "20px",
      left: "80px"
   }, 1000, "easeOutBack");
}

function house_o_love_out(name) {
   if ($("#house_o_love_" + name).css("left") != "2080px") {
      $("#house_o_love_" + name).stop().animate({
         top: "20px",
         left: "-2080px"
      }, 1000, "easeInBack", function () {
        $(this).css({
         "left": "2080px",
         display: "none"
        }); 
      });   
   }
}

function volt_in(name) {
   djZindex++;
   $("#volt_" + name).css({
      "z-index": djZindex,
      display: "block"
   }).stop().animate({
      top: "20px",
      left: "80px"
   }, 1000, "easeOutBack");
}

function volt_out(name) {
   if ($("#volt_" + name).css("left") != "2080px") {
      $("#volt_" + name).stop().animate({
         top: "20px",
         left: "-2080px"
      }, 1000, "easeInBack", function () {
        $(this).css({
         "left": "2080px",
         "display": "none"
        }); 
      });
   }
}

function submit_vrijwilligers() {
	var feest = $("input[name=feest]").attr("checked");
	var breekaf = $("input[name=breekaf]").attr("checked");
	var naam = $("input[name=naam]").val();
	var emailadres = $("input[name=emailadres]").val();
	
	if ((feest == false && breekaf == false) && (naam.length < 1 && emailadres.length < 1)) {
		$("#bad").fadeIn();
		$("#success").fadeOut();
	} else {
		$("#bad").fadeOut();
		$("#success").fadeIn();
		$("#hide_this").css("display", "none");
		
		$.post("/includes/send_mail_ajax.php", {
			feest: feest,
			breekaf: breekaf,
			naam: naam,
			emailadres: emailadres
		});
	}
}

/* PURE AWESOME */
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(e) {
  kkeys.push( e.keyCode );
  if ( kkeys.toString().indexOf( konami ) >= 0 ){
    $(document).unbind('keydown',arguments.callee);
    //b8msomeness();         
  }
});
