
//when page loads
Event.observe(window,'load',function(){
	//Hide
	var anchors = $$('.arrow');
	for(var i = 0; i < anchors.length; i++)
	{
		//Hide second level navigation
		//Check if page is under current section
		var winLoc = window.location.toString();
		if(winLoc.indexOf('custom') == -1)
		{
			anchors[i].parentNode.getElementsByTagName('ul')[0].style.display = 'none';
			anchors[i].className = 'arrow closed';
		} else {
			//Attach classes to parent anchor tags
			anchors[i].className = 'arrow open';
		}
		
		//Attach click event to anchor tags
		Event.observe(anchors[i],'click',function(event){
			//Stop event propagation
			event.stop();
				
			//Get reference to uls
			var parentUl = this.parentNode;
			//If first level navigation parent exists
			if(parentUl)
			{
				//Get second level navigation
				var childUl = parentUl.getElementsByTagName('ul')[0];
				//If the sub nav isnot showing	
				if(childUl && childUl.style && childUl.style.display && childUl.style.display == 'none')
				{
					childUl.style.display = 'block';
					this.className = 'arrow open';
				} else {
					childUl.style.display = 'none';
					this.className = 'arrow closed';
				}
			}		
		});
	}
});
