$(function() {			
				
			var emails = $(".email");
				
				for(var i=0; i < emails.length; i++) {
					var email = emails.html();
					email = email.replace('[replace_with_at]', '@');
					email = email.replace('[replace_with_dot]', '.');
					email = email.replace('[replace_with_com]', 'com');
					email = email.replace('[replace_with_nl]', 'nl');
					email = email.replace(' ', '');
					emails.eq(i).html(email);
					emails.eq(i).attr('href', 'mailto:'+email);
				}
				
				$(".project_title, .hover")
					.mouseenter(function() {
						$("img", $(this)).fadeIn("fast");
					}).mouseleave(function() {
						$("img", $(this)).stop(true, true).fadeOut("fast");
					});
				
								
				$("button").replaceWith(function(e) {
					return '<div class="button"><span>'+$(this).html()+'</span></div>';
				})
				$(".button").click(function() {
					$(this).parents("form").submit();
				});
				
				$(".view_project, .next_tour, .prev_tour,  .scroll-down, .button, button")
					.append('<div class="bg"></div>').mouseenter(function() {
						$(".bg", $(this)).fadeIn("fast"); // .css('filter', 'alpha(opacity=0)')
					}).mouseleave(function() {
						$(".bg", $(this)).stop(true, true).fadeOut("fast");
					});
	
				$(".project-gallery-content .next, .project-gallery-content .prev")
					.mouseover(function() {
						$(this).animate({"opacity":"1.0"}, "fast");
					}).mouseout(function(){
						$(this).stop(true, true).animate({"opacity":"0.5"}, "fast");
					});			
				
					
				$('.download-wide')
					.click(function(){
						// Send some data to Google Analytics
						_gaq.push(['_trackEvent', 'Downloads', 'Main download']);																
						return true;
					});
					
				$('.download')
					.click(function(){
						// Send some data to Google Analytics
						_gaq.push(['_trackEvent', 'Downloads', 'Sub page download']);															
						return true;
					});					
				
				$('.download-legacy')
					.click(function(){
						// Send some data to Google Analytics
						_gaq.push(['_trackEvent', 'Downloads', 'Old version downloaded']);										
						return true;
					});	
					
				$('.download-legacy-25')
					.click(function(){
						// Send some data to Google Analytics
						_gaq.push(['_trackEvent', 'Downloads', '2.5 no update']);																
						return true;
					});
				
				$('.goto-source')
					.click(function(){
						// Send some data to Google Analytics
						_gaq.push(['_trackEvent', 'Source', 'Current source']);						;											
						return true;
					});	
					
				$('.goto-source-legacy')
					.click(function(){
						// Send some data to Google Analytics
						_gaq.push(['_trackEvent', 'Source', 'Legacy source']);																	
						return true;
					});	
				
				$('.mdb-game')
					.click(function(){
						// Send some data to Google Analytics
						_gaq.push(['_trackEvent', 'Downloads', 'The Game']);																	
						return true;
					});	
								
						
				$(".gallery").imageScroller({animation:'fade'});
				
				$(".main_menu li:not(.active), .button:not(.active)")
					.mouseenter(function() {
						$(".hover", $(this)).fadeIn("fast"); // .css('filter', 'alpha(opacity=0)')
					}).mouseleave(function() {
						$(".hover", $(this)).stop(true, true).fadeOut("fast");
					});
				
				
				var params = {
					scale: "noScale", 
					salign: "lt", 
					menu: "false",
					allowscriptaccess: "always",
					allownetworking: "all",
					bgcolor: "#000000"
				};
				
				var attributes = {
					id: "official_game", 
					name: "official_game"
				};
					
				swfobject.embedSWF("/flash/game_teaser.swf", "game_teaser", "420", "225", "10.0.0", null, {}, params, {id:"game_teaser",name:"game_teaser"}); 
				swfobject.embedSWF("/flash/Main.swf", "official_game", "800", "600", "10.0.0", null, {}, params, attributes); 
				
				
				if($("#official_game").length > 0){
					swfmousewheel.registerObject(attributes.id);
					OAuth.setApplication(attributes.id);
				}
			});
