jQuery(function($) {
	
	// I've noticed firefox is a little slower than safari and chrome
	var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
	var spriteMultiplier = is_firefox ? 1 : 2;
	
	console.log('spriteMultiplier', spriteMultiplier);
	
	var circleAnimationSettings = [
		
		// eye
		{
			spriteCount: 12 * spriteMultiplier,
			speed: [-4, 4],
			yAmplitude: 0, 
			xAmplitude:  0, 
			startingSize: [50, 240],
			startingOpacity: [0.6, 0.9],
			phase: 0,
			sizePhase: 0,
			opacityPhase: 0,
			duration: [10000,30000]
		},
		
		// hydrogen
		{
			spriteCount: 12 * spriteMultiplier,
			speed: [-6, 6],
			xAmplitude:  20, 
			yAmplitude: 0, 
			startingSize: [90, 200],
			startingOpacity: [0.6, 0.9],
			phase:  0,
			opacityPhase: 0.5,
			sizePhase: 0,
			duration: [10000,24000]
		},
		
		/*
		// backnforth
		{
			spriteCount: [10, 20],
			speed: [-1, 5],
			xAmplitude:  0, 
			yAmplitude: 20, 
			startingSize: [30, 160],
			startingOpacity: 1,
			phase: 0,
			opacityPhase: 0.5,
			sizePhase: 0,
			duration: 5000
		},
		*/
		
		// whirlygig
		{
			spriteCount: 18 * spriteMultiplier,
			speed: [-3, 17],
			xAmplitude: 40,
			yAmplitude: 20,
			startingSize: [100, 180],
			startingOpacity: [0.2, 0.6],
			duration: [10000, 20000],
			phase: [0.4, 0.6],
			opacityPhase: 0.2
		},

		// orbits
		{
			spriteCount: 24 * spriteMultiplier,
			speed: [-6, 6],
			xAmplitude: [60, 180],
			yAmplitude: [20, 80],
			startingSize: [60, 120],
			startingOpacity: [0.3, 0.7],
			opacityPhase: 0.5,
			duration: 10000
		}
		
		/*
		// circles
		{
			spriteCount: 30,
			speed: [-4, 8],
			xAmplitude: [100, 120],
			yAmplitude: [60, 80],
			startingSize: [20, 140],
			startingOpacity: [0.3, 0.7],
			opacityPhase: 0.75,
			duration: 10000
		}
		*/
	];
	

	var animations = [
		
		function() {
			var animationSettings = circleAnimationSettings.randomItem(); //  animations[4]; // 
			var circleOptions = $.extend({centerPoint: { top: 120, left: 160 }}, animationSettings);
			$('#animation').circleAnimation(circleOptions);
		},
		
		function() {
			$('#animation').blinky({ spriteCount: 100, triggerRange: [6, 10] });
		}
		
	];
	

	$.address.init(function() {
		var isIE = /MSIE (\d+\.\d+);/.test(navigator.userAgent);
		var anim = $('#animation');
		
		if (isIE) {
		
			anim.addClass('can');
			
			$.message.show({
				title: "Shame on You",
				message: "This page is way less fun in Internet Explorer. Actually, all pages are. We can make it work, but it's just a lousy browser."
				
			});
			
		} else {
		
			anim.removeClass();
			animations[0]();
			// (animations.randomItem())();
			
			$.message.show({
				message: "There is no Flash, Silverlight, or other baby-toys on this page. It's all HTML, CSS, and JavaScript.",
				title: "Fun Fact"
			});
			
		};
	});
	
	$.address.change(function() {
		Colors.change();
	});
	
	
});
