window.addEvent('domready', function()			// Execute, when html is loaded complete
{
	center();
	
	var flasche = $('flasche');
	if (flasche)			//  Flasche vorhanden
	{
		// Flasche und Igel animieren
		var floatingBottle = new Pendulum(flasche, {x: 0.15, y: 0.1}, {x:40, y:55});
		floatingBottle.start();

		var myIgel = [];
		var myIgelPendulum = [];
		$$('.igel-description').each(function(el, index)
		{
			myIgel[index] = new Igel(flasche, el, $('igel-' + index), {width:160, height:550});
			myIgel[index].draw();

			var rnd1 = $random(80,100) / 100;
			var rnd2 = $random(80,100) / 100;
			var rnd3 = $random(80,100) / 100;
			var rnd4 = $random(80,100) / 100;
			myIgelPendulum[index] = new Pendulum(el, {x: 0.15*rnd1, y: 0.1*rnd2}, {x:35*rnd3, y:20*rnd4}, floatingBottle.breakzone, floatingBottle.timer);
			myIgelPendulum[index].start();
		}.bind(this));
		
//		var tmp = function()
//		{
//			myIgel.each(function (el)
//			{
//				el.redraw();
//			});
//		}.periodical(200);
		
//		floatingBottle.registerCallback(function()
//		{
//			myIgel.each(function (el)
//			{
//				el.redraw();
//			});
//		});
	}
	
	if ($('ich-bins'))
	{
		var aniPage = new DasBier(myIgel[0], myIgelPendulum[0], myIgel[1], myIgelPendulum[1], myIgel[2], myIgelPendulum[2], floatingBottle);
	}
});

window.addEvent('resize', function()				// Execute, when site is loaded complete
{
	center();
});

window.addEvent('onload', function()				// Execute, when site is loaded complete
{
});

window.addEvent('onunload', function()				// Execute, when html is loaded complete
{
});

// replaceSIFRFonts();                         // funktioniert nicht in IE, wenn unter onload oder domready

function center()
{
//alert('center');
	var w = window.getSize();
	var c = $('wrapper').getSize();
//alert(w.y);
//alert(c.y);
	var top = 0;
	
	if (w.y > c.y)
	{
		top = (w.y - c.y) / 2;
	}
	$('wrapper').setStyle('margin-top', top);
}

