
	var nrMenuItems = 5; // Number of main menu items
	var extendedX = 4; // Final x coordinate of extended menu
	var unextendedX = 4; // Initial x coordinate of extended menu
	var unextendedHeight = 24; // How high a normal item is. This should also be in css.
	var theElementsY = new Array(0,0,0,0,0); // All 'top' postitions from css for each menu item.
	var theElementsYDisplacement = new Array(20,160,20,40,60);
	var extendedItem = 1000;
	var lastIndex = false;

	function AnimatableNode(domNode) {
	    this.node = domNode;
	}

	AnimatableNode.prototype.getValue = function AnimatableNode_getValue(propertyName) {
	    var node = this.node;
	    var value = 0;
	    switch (propertyName) {
	        case "x":			{ value = node.style.left; break; }
	        case "y":			{ value = node.style.top; break; }
	        case "width":   	{ value = node.style.width; break; }
	        case "height":		{ value = node.style.height; break; }
	    }
	    // If the properties are not set correctly in the stylesheet, this may produce NaN...
	    return parseInt(value);

	};

	AnimatableNode.prototype.setValue = function AnimatableNode_setValue(propertyName, value) {
	    var node = this.node;
	    value = value + "px"; // animations in pixels
	    switch (propertyName) {
	        case "x":       { node.style.left = value; break; }
	        case "y":       { node.style.top = value; break; }
	        case "width":   { node.style.width = value; break; }
	        case "height":  { node.style.height = value; break; }
	    }
	};

	AnimatableNode.prototype.setBackground = function AnimatableNode_setBackground(value) {
		var node = this.node;
	    value = "#" + value;
		node.style.background = value;
	};

	AnimatableNode.prototype.getBackground = function AnimatableNode_getBackground(value) {
	    var node = this.node;
		var value = value = node.style.background;
		return value.substr(1);
	};

	function moveMenuItem(itemNumber)
	{
		var theElements = new Array(new AnimatableNode(document.getElementById('menu_item_1')),new AnimatableNode(document.getElementById('menu_item_2')),new AnimatableNode(document.getElementById('menu_item_3')),new AnimatableNode(document.getElementById('menu_item_4')),new AnimatableNode(document.getElementById('menu_item_5')));
		itemNumber--;

		for(i = 0; i < theElements.length; i++) {

			// stop running animations!
			AnimationLibrary.stop(theElements[i]);

			// Initiate objects to animate
			if(isNaN(theElements[i].getValue("x"))) {
				theElements[i].setValue("x", unextendedX);
					theElements[i].setValue("y", theElementsY[i]);
					theElements[i].setValue("height", unextendedHeight);
			}

			// Retract extended item and restore height to normal
			if(theElements[i].getValue("x") == extendedX) {
				AnimationLibrary.animate(theElements[i], 200, "x", unextendedX);
				if(theElements[i].getValue("height") > 20) {
					if(i != itemNumber) {
						// Only restore height if the clicked item isn't already extended
						AnimationLibrary.animate(theElements[i], 200, "height", unextendedHeight);
						theElements[i].setBackground("dee8f3");
					}
				}
			}

			// Move displaced items back upwards
			if(theElements[i].getValue("y") != theElementsY[i]) {
				theElements[i].setValue("y", theElementsY[i]);
			}

			// Save last clicked item
			if(i == itemNumber) {
				Set_Cookie("menu_last_clicked_1", itemNumber, "", "/", "", "");
				lastIndex = i;
			}
		}

		// Move item outwards && stretch it (unless already stretched; people like to doubleclick hyperlinks for some strange reason)
		AnimationLibrary.animate(theElements[itemNumber], 200, "x", extendedX);

		if(extendedItem != itemNumber) {
			// Animate stretching and recolor element.
			AnimationLibrary.animate(theElements[itemNumber], 200, "height", unextendedHeight + theElementsYDisplacement[itemNumber]);
			theElements[itemNumber].setBackground("c1d4e9");
		} else {
			// Include this else to prevent item from folding in.
			theElements[itemNumber].setValue("height", unextendedHeight + theElementsYDisplacement[itemNumber]);
		}

		extendedItem = itemNumber;
	}

	function initMenu()
	{
		// Bake menu (no, *b*ake menu isn't a typo)
		if(Get_Cookie("menu_last_clicked_1") != null) {
			lastIndex = parseInt(Get_Cookie("menu_last_clicked_1"));
			get_element = 'menu_item_'+(lastIndex+1);
			got_element = new AnimatableNode(document.getElementById(get_element));
			got_element.setValue("height", unextendedHeight + theElementsYDisplacement[lastIndex]);
			got_element.setValue("x", extendedX);
			got_element.setBackground("c1d4e9");
		}

		// After all this is done, show the menu
		document.getElementById("menu").style.visibility = "visible";
	}
