/****************************************************************************
 File: menu.js
 Author: Richard Coleman
 Date: 13/05/2009
 
 © Red Kite Business Systems, 2009
 
 ****************************************************************************
 
 Description:
 ------------
 
 Provides bespoke menu functionality
 ****************************************************************************/

/*
 * Increases the size of the right-margin of each menu item by the
 * prescribed amount.  This is a crude implementation specifically for the
 * Diploma in Science website, so would need re-working for something more
 * clever and flexible.
 *
 * Parameters
 * ==========
 *	menuId		the ID of the element that contains the menu anchors
 *	gradAmt		the gradient amount used to adjust the right margin
 */
function TaperMenu(menuId,gradAmt) {
	var menuList = document.getElementById(menuId);
	
	if (menuList) {
		var anchors = menuList.getElementsByTagName("a");
		for (i = 0 ; i < anchors.length ; i++){
			if (anchors[i].className == "L0" || anchors[i].className == "L0sel"){
				anchors[i].style.marginRight = (i*gradAmt) + "px";
			}
		}
		
		var subMenuList = menuList.getElementsByTagName("ul");
		if (subMenuList) {
			for (i = 0 ; i < subMenuList.length ; i++){
				var l1Anchors = subMenuList[i].getElementsByTagName("a");
				for (x = 0 ; x < l1Anchors.length ; x++){
					if (l1Anchors[x].className == "L1" || l1Anchors[x].className == "L1sel") {
						l1Anchors[x].style.marginRight = (x*gradAmt*0.6) + "px";
					}
				}
			}
		}
	}
}