
	window.addEvent("domready", function()
	{		
		if($("id_home_twitter_tweets") != null)
		{
			/*
			 * Tweets
			 */
			var tweetShow = new SlideShow("id_home_twitter_tweets",
			{
				selector: 'div',
				autoplay: true,
				delay: 5000,
				duration: 800,
				transition: 'pushDown'
			});
		}
		
		if($("site_slideshow-id") != null)
		{
			/*
			 * InfoBox
			 */
			var delay = null;
			var navs = $$(".site_slideshow-navigation a");
			var items = $$(".site_slideshow-content img");
			var href = $$(".site_slideshow-box a");
			var titles = $$(".site_slideshow-box span");
			var infoBox = new SlideShow("site_slideshow-id",
			{
				selector: 'img',
				autoplay: true,
				delay: 6000,
				duration: 800,
				onShow: function(data)
				{
					var title = items[data.next.index].get("data-title");
					var text = items[data.next.index].get("data-text");
					var url = items[data.next.index].get("data-url");
					
					for(var i = 0; i < titles.length; i++)
						(new Fx.Tween(titles[i],
		                {
							duration: 800,
							onComplete:function(event)
							{
								titles[0].set("html", title);
								titles[1].set("html", text);
								href.set("href", url);
							
								(new Fx.Tween(titles[0])).start("opacity", "0.0", "1.0");
								(new Fx.Tween(titles[1])).start("opacity", "0.0", "1.0");
							}
		                })).start("opacity", "1.0", "0.0");
					
					navs[data.previous.index].getParent().removeClass("site_slideshow-navigation_active");
					navs[data.next.index].getParent().addClass("site_slideshow-navigation_active");
				}
			});
			
			/*
			 * Navigation
			 */
			navs.each(function(element)
			{
				element.addEvent("click", function()
				{
					infoBox.pause();
					for(var i = 0; i < navs.length; i++)
						if(navs[i] == this)
						{
							infoBox.show(i);
							
							if(delay != null)
							{
								clearTimeout(delay);
								delay = null;
							}
							delay = (function()
							{
								infoBox.play();
							}).delay(6000);
							break;
						}
				});
				element.addEvent("mouseover", function()
				{
					Tooltip.Show(this, this.get("data-title"));
				});
				element.addEvent("mouseout", function()
				{
					Tooltip.Hide();
				});
			});
		}
	});
