function PlayFun ()
{
	var animation;
	if (new Date().getMonth() == 11)
	{
		animation = new Snowflakes();
	}
	else
	{
		animation = new Balloons();
	}
	animation.Play();
}

function Balloons()
{

	this.Play = function ()
	{
		var animation = new BalloonAnimation();
		animation.Execute();
	};

	var AnimationParameters =
	{
		Count: 10,
		MinSize: Window.getSize().x / 12,
		MaxSize: Window.getSize().x / 4,
		MinDuration: 10000,
		MaxDuration: 20000,
		MaxDelay: 5000,
		ImageFileCount: 8,
		ImageFolder: "/images/stories/",
		ImageNameStub: "balloon0",
		ImageExtension: ".png"
	};

	var balloonImageSources = new Array();
	for (var i = 0; i < AnimationParameters.ImageFileCount; i++)
	{
		var source = AnimationParameters.ImageFolder 
			+ AnimationParameters.ImageNameStub 
			+ i 
			+ AnimationParameters.ImageExtension;
		balloonImageSources[i] = source;
	}
	var balloonsReady = false;
	var balloonImages = new Asset.images(balloonImageSources, { onComplete: function () { balloonsReady = true; } });

	var BalloonAnimation = new Class(
		{
			Execute : function()
			{
				var windowSize = Window.getSize();
				this.balloons = new Array;
				for(var i = 0; i < AnimationParameters.Count; i++)
				{
					this.balloons[i] = new Balloon(windowSize);
					this.balloons[i].Start();
				}
			}
		}
	);

	var Balloon = new Class(
		{
			Extends: Fx.Tween,
			top: null,
			delay: null,
			initialize: function(windowSize)
			{
				var size = $random(AnimationParameters.MinSize, AnimationParameters.MaxSize);
				var maxLeft = (size * -0.5).toInt();
				var maxRight = (windowSize.x - (size * 0.5)).toInt();
				var left = $random(maxLeft, maxRight);
				var sourceNumber = $random(0, AnimationParameters.ImageFileCount - 1);
				var tag = document.createElement("img");
				$(tag); // HACK: applies Element to the tag in IE
				var _duration = $random(AnimationParameters.MinDuration, AnimationParameters.MaxDuration);
				tag.setStyles(
					{
						"top": windowSize.y + 10,
						"left": left,
						"height": size,
						"width": size,
						"z-index": size,
						"position": "absolute"
					});
				tag.set("src", balloonImageSources[sourceNumber]);
				this.parent(tag,
					{
						property: "top",
						duration: _duration,
						onComplete: this.Teardown
					});
				this.fps = 20;
				this.delay = $random(0, AnimationParameters.MaxDelay);
				this.top = 0 - size;
			},
			Start: function()
			{
				document.body.appendChild(this.element);
				this.start.delay(this.delay, this, this.top);
			},
			Teardown: function()
			{
				this.element.destroy();
			}
		}
	);

} // Balloons

function Snowflakes()
{

	this.Play = function ()
	{
		var animation = new SnowflakeAnimation();
		animation.Execute();
	}

	var AnimationParameters = 
	{
		Count: 30,
		MinSize: Window.getSize().x / 20,
		MaxSize: Window.getSize().x / 10,
		MinDuration: 10000,
		MaxDuration: 20000,
		MaxDelay: 5000,
		ImageFileCount: 18,
		ImageFolder: "/images/stories/",
		ImageNameStub: "snowflake",
		ImageExtension: ".png"
	};

	var snowflakeImageSources = new Array();
	for (var i = 0; i < AnimationParameters.ImageFileCount; i++)
	{
		var source = AnimationParameters.ImageFolder
			+ AnimationParameters.ImageNameStub
			+ (i < 10 ? "0" : "")
			+ i
			+ AnimationParameters.ImageExtension;
		snowflakeImageSources[i] = source;
	}
	var snowflakesReady = false;
	var snowflakeImages = new Asset.images(snowflakeImageSources, { onComplete: function () { snowflakesReady = true; } });

	var SnowflakeAnimation = new Class(
		{
			Execute : function()
			{
				var windowSize = Window.getSize();
				this.snowflakes = new Array;
				for(var i = 0; i < AnimationParameters.Count; i++)
				{
					this.snowflakes[i] = new Snowflake(windowSize);
					this.snowflakes[i].Start();
				}
			}
		}
	);

	var Snowflake = new Class(
		{
			Extends: Fx.Tween,
			top: null,
			delay: null,
			initialize: function(windowSize)
			{
				var size = $random(AnimationParameters.MinSize, AnimationParameters.MaxSize);
				var maxLeft = (size * -0.5).toInt();
				var maxRight = (windowSize.x - (size * 0.5)).toInt();
				var left = $random(maxLeft, maxRight);
				var sourceNumber = $random(0, AnimationParameters.ImageFileCount - 1);
				var tag = document.createElement("img");
				$(tag); // HACK: applies Element to the tag in IE
				var _duration = $random(AnimationParameters.MinDuration, AnimationParameters.MaxDuration);
				tag.setStyles(
					{
						"top": -10 - size,
						"left": left,
						"height": size,
						"width": size,
						"position": "absolute"
					});
				tag.set("src", snowflakeImageSources[sourceNumber]);
				this.parent(tag,
					{
						property: "top",
						duration: _duration,
						onComplete: this.Teardown
					});
				this.fps = 20;
				this.delay = $random(0, AnimationParameters.MaxDelay);
				this.top = windowSize.y + 10;
			},
			Start: function()
			{
				document.body.appendChild(this.element);
				this.start.delay(this.delay, this, this.top);
			},
			Teardown: function()
			{
				this.element.destroy();
			}
		}
	);
	
} // Snowflakes
