/**
 * Sidebar/Navigation class. Should update the height of the sidebar/navigation column.
 */
Sidebar = {

	/**
	 * Initializes the sidebar/navigation class.
	 */
	init: function()
	{
		/* find navigation or sidebar element */
		var element = null;
		if ($("navigation"))
		{
			element = $("navigation");
		}
		else if ($("sidebar"))
		{
			element = $("sidebar");
		}

		/* check if either element was found */
		if (element)
		{
			/* get the originl height of the sidebar */
			var originalHeight = elementDimensions(element).h;

			/* height of the container */
			var height = elementDimensions($("container")).h;

			/* substract header and footer */
			height -= elementDimensions($("header")).h;
			height -= elementDimensions($("footer")).h;

			/* substract teaser */
			if ($("teaser"))
			{
				height -= elementDimensions($("teaser")).h;
			}
			else
			{
				height -= 60;
			}

			/* 10 pixels clearance from the footer */
			height -= 10;

			/* substract padding and border of the navigation (not for <IE7) */
			if (navigator.userAgent.indexOf("MSIE 5") == -1 && navigator.userAgent.indexOf("MSIE 6") == -1)
			{
				var paddingBorder = 0;
				paddingBorder += parseInt(computedStyle(element, "paddingTop", "padding-top"));
				paddingBorder += parseInt(computedStyle(element, "paddingBottom", "padding-bottom"));
				paddingBorder += parseInt(computedStyle(element, "borderTopWidth", "border-top-width"));
				paddingBorder += parseInt(computedStyle(element, "borderBottomWidth", "border-bottom-width"));

				height -= paddingBorder;
				originalHeight -= paddingBorder;
			}

			/* set new height (if greater than current height) */
			if (height > originalHeight)
			{
				element.style.height = height + "px";
			}
		}
	} // function init

}; // class Sidebar

/* initialize the sidebar/navigation class on document load */
addLoadEvent(Sidebar.init);