
// global var for defining URLS followed by cicking on the left nav buttons
var navItems = ["holidays/index.asp", "coaching.asp", "groupmasterclasses.asp", "coachingcourses.asp", "training/programmes.asp", "training/index.asp", "dvd.asp"];

function createmenuitems() {
   // Create main left nav semi-transparent buttons.
   $$('nav_container', 'div.nav_button').each(function(_this, index) { createmenuitem(_this,index) });

	}

function createmenuitem(element,itemIndex) {
   var el = $(element);
   var isSelected = (itemIndex==navID);	// comapre to global navID, set by ASP code in page header
   
	el.set('itemindex', itemIndex);			// this menu item's position in the menus array definintion
	el.set('selected', isSelected);			// 'selected' controls the button fade out animation on mouse out (true=no fade) - 1 button cab be selected per menu level
		
	// initial visual formats. If not selected fade otherwise leave as 100% opacity.
	if (!isSelected) {
   	el.setOpacity(0);
   	el.fade(0.7);
   	}
   
   // event definitions (implemented in menuhelper.js)
   el.addEvent('mouseover', 	function(e) { e.stop(); doButtonMouseOver(this); 	});
   el.addEvent('mouseout' , 	function(e) { e.stop(); doButtonMouseOut(this); 	});
   el.addEvent('click', 		function(e) { e.stop(); doButtonMouseClick(this);	});
   }

function doButtonMouseOver(aElement) {
	var _this = $(aElement);		// will accept a DIV.ID or element object
	_this.fade(1); 
	_this.setStyle('background-position', '0px -65px'); 
	}

function doButtonMouseOut(aElement) {
	var _this = $(aElement);		// will accept a DIV.ID or element object
	if (!_this.get('selected')) { _this.fade(0.7); }
	_this.setStyle('background-position', '0px 0px'); 
	}

function doButtonMouseClick(aElement) {
	$$('nav_container', 'div.nav_button').each(function(_this, index) { _this.set('selected', false); _this.fade(0.7); });

	var _this = $(aElement);		// will accept a DIV.ID or element object
	var thisNavID = _this.get('itemindex');
	
	_this.set('selected', true);
	_this.fade(1);
	//DEBUG:alert(_this.id + ", index:" + thisNavID + ", URL:" + navItems[thisNavID]);
	window.location = pathPrefix + navItems[thisNavID];
	}

