var animation = new Array();
var content = new Element("div");
var size;

window.addEvent("domready", function()
{
	links = $("navi").getElements("a");
	links[1].href = "#projects";
	links[2].href = "#about";
	size = $(document.body).getSize();
	document.body.adopt(content);
	go();
});

window.onhashchange = go;

window.addEvent("resize", function()
{
	size = document.body.getSize();
	go();
});

function brag(html)
{
	var h = size.y / 2 - $("box").getSize().y;
	var sz = size.x / 10;
	animation.length = 10;
	for (var i = 0; i < animation.length; i++)
	{
		animation[i] = new Element("div", {
			"class": "abt_f",
			"styles": {
				left: sz * i,
				width: sz
			}
		});
		document.body.adopt(animation[i]);
		animation[i].tween("height", h * Math.random());
	}
	content.set("id", "about");
	content.set("html", html);
	content.setStyle("top", (size.y / 4) - (content.getSize().y / 2));
	content.setStyle("height", content.getSize().y);
	content.setStyle("width", 0);
	content.tween("width", size.x);
}

function dispose(e)
{
	e.dispose();
}

function go()
{
	for (var i = 0; i < animation.length; i++)
	{
		animation[i].set("tween", { onComplete: dispose });
		animation[i].tween("opacity", 0);
	}
	animation.length = 0;
	content.erase("html");
	content.erase("id");
	content.erase("style");
	switch (window.location.hash.substring(1))
	{
		case "about":
			new Request({ url: "about.php", onSuccess: brag }).send("ajax=true");
			break;
		case "projects":
			new Request({ url: "projects.php", onSuccess: showcase }).send("ajax=true");
			break;
		default: break;
	}
}

function showcase(html)
{
	content.set("id", "projects");
	content.set("html", html);
	content.setStyle("top", 50);
	content.setStyle("left", 50);
}
