window.addEvent('domready', function() {
	var clickedButton = "";
	
//	alert($defined($(document.body).getElement('div[id=accordion]')));
	if($defined($(document.body).getElement('div[id=accordion]')))
	{
		// add a few events to the toggler elements to do menu highlights
		$(document.body).getElements('h4.toggler').addEvents({
		'mouseenter': function(){
			
			
		},
		'mouseleave': function(){
			
		}
		});
		// -------------- ACCORDIAN CODE -------------- 
		var myAccordion = new Accordion($('accordion'), 'h4.toggler', 'div.element, div.elementBottom', {
			opacity: false,
			display: -1,
			alwaysHide: true,
			onActive: function(toggler, element){
		//		element.setStyle('padding-top', '16px');
				toggler.setStyle('color', '#ffffff');
				toggler.setStyle('background', '#6a0606');
				clickedButton = element.getProperty('class').toString();
			},
			onBackground: function(toggler, element){
		//		element.setStyle('padding-top', '0px');			
				toggler.setStyle('color', '#6a0606');
				toggler.setStyle('background', '#e8e8e8');
				clickedButton = "element";					
			},
		  onComplete: function()
		  {
		  	var targetBlock = $(document.body).getElement('div[id=accordion]');
				if(clickedButton == "elementBottom")
				{
				 	targetBlock.setStyle('border-bottom', 'solid 1px #cccccc');
				 	
		  	}
		  	else
				{
				 	targetBlock.setStyle('border-bottom', 'none 1px #cccccc');
				}
		  }
		});
		// ----------- ENDACCORDIAN CODE --------------
	}
	startList();
});


/*startList = function()
{
	if (document.all&&document.getElementById)
	{
		navRoot = document.getElementById("topnav");
		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=="li")
			{
				node.onmouseover=function() 
				{
					this.className+=" over";
				}
				node.onmouseout=function() 
				{
					this.className=this.className.replace(" over", "");
				}
		 	}
		}
	}
}*/

startList = function()
{
	//	alert($(document.body).getElement('#links .topnav'));
	//	alert($defined($(document.body).getElement('#links .topnav')));
	if (document.all&&document.getElementById)
	{
		if($defined($(document.body).getElement('#links .topnav')))
		{
			var menuItems = $$('#links .topnav li');//$(document.body).getElement('#links .topnav');
			menuItems.each(function(element)
			{
			/*	element.addEvent('mouseover', function(event){
					this.className+=" over";
				});
				element.addEvent('mouseout', function(event){		
					this.className=this.className.replace(" over", "");			
				});*/
					element.onmouseover=function() 
					{
						this.className+=" over";
					}
					element.onmouseout=function() 
					{
						this.className=this.className.replace(" over", "");
					}
				
				
				
			});
		}
	}
}