function toggle()
{
    fader = new Fx.Style('box', 'opacity', {
            duration: 500,
            transition: Fx.Transitions.quartInOut
    });
    fader.start(1,0);
}

function makeSlide(x,d)
{
    var newSlide = new Fx.Slide(x, {duration:d});
    return newSlide;
}

function slide(x)
{
    x.toggle() //toggle the slider up and down.
}

function loopChild(child)
{
	if (child.nodeName == "UL")
		child.getChildren().each(loopChild);

	if (child.nodeName == "LI")
	{
		child.getChildren().each(loopChild);

		child.addEvent("mouseover", function()
			{
				this.className += " over";
			});

		child.addEvent("mouseout", function()
			{
				this.className = this.className.replace(" over", "");
			});
	}
}
		
function startList()
{
	if (!document.all)
		return;

	$('nav').getChildren()[0].getChildren().each(loopChild);
}

function anchorScroll()
{
	$$('a').each(function(link)
		{
			var index = link.href.indexOf("#");

			if (index != -1)
			{
				var anchor = link.href.substr(index + 1);

				link.href = "javascript:void(0)";
				link.addEvent("click", function(event)
					{
						new Fx.Scroll(window).toElement($(anchor));
					});
			}
		});
}

function externalLinks()
{
	if (!document.getElementsByTagName)
		return;

	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++)
	{
		var anchor = anchors[i];

		if (anchor.getAttribute("href") &&
			anchor.getAttribute("rel") == "external")

		anchor.target = "_blank";
	}
}

function loadFunc()
{
	startList();

	anchorScroll();

	externalLinks();

	if ( window.createTips )
		createTips();
}

window.onload = loadFunc;
