/********************************************************************/
/* 
	RTA MyPlates.com.au Left Navigation Menu expanding accordion functions
	
	version: 		1.0
	developed by: 	Saatchi & Saatchi Digital Australia
	developer: 		Andy Yip (yipa@saatchi.com.au)
	created: 		02/03/2009
	last modified:	04/03/2009
	copyright:		(c) 2009 Saatchi & Saatchi Australia
*/
/********************************************************************/

	//scripts have been put here as a courtesy to you, the sourcecode viewer.
	
	//this script uses mootools: http://mootools.net
	
	var stretchers = $$('ul.accordion');
	var togglers = $$('div.toggler');
	var navs = $$('li.navOff');

	stretchers.setStyles({'height': '0', 'overflow': 'hidden'});
	navs.setStyles({'display': 'block'});
	
	window.addEvent('load', function(){
	try{	
		//initialization of togglers effects

		togglers.each(function(toggler, i){
			toggler.color = toggler.getStyle('background-color');
			toggler.$tmp.first = toggler.getFirst();
			toggler.$tmp.fx = new Fx.Style(toggler, 'background-color', {'wait': false, 'transition': Fx.Transitions.Quart.easeOut});
		});

		//the accordion
		
		var myAccordion = new Accordion(togglers, stretchers, {
			
			'opacity': false,
			
			'start': false,
			
			'transition': Fx.Transitions.Quad.easeOut,
			
//			onComplete:function(){ $("ul_about").class = ""; }.bind(this),
			
			onActive: function(toggler){
				//toggler.$tmp.fx.start('#ffffff');
				toggler.$tmp.first.setStyle('color', '#fdca00');
				toggler.onmouseover = function() { toggler.$tmp.first.setStyle('color', '#333333'); }
				toggler.onclick = function() { toggler.$tmp.first.setStyle('color', '#333333'); }
				toggler.onmouseout = function() { toggler.$tmp.first.setStyle('color', '#fdca00'); }
			},
		
			onBackground: function(toggler){
				//toggler.$tmp.fx.stop();
				toggler.setStyle('background-color', toggler.color).$tmp.first.setStyle('color', '#ffffff');
				toggler.onmouseover = function() { toggler.$tmp.first.setStyle('color', '#333333'); }
				toggler.onmouseout = function() { toggler.$tmp.first.setStyle('color', '#ffffff'); }
				toggler.onclick = function() { toggler.$tmp.first.setStyle('color', '#333333'); }
			}
		});
		
		//open the accordion section relative to the url
		
		var found = 0;
		$$('div.toggler a').each(function(link, i){
			if (window.location.hash.test(link.hash)) found = i;
		});
		myAccordion.display(found);
	}catch(e)
	{
		if($("a_highlight"))
			$("a_highlight").style.color = "#fdca00";
		
		$("a_highlight").onmouseover = function() { $("a_highlight").setStyle('color', '#333333'); }
		$("a_highlight").onmouseout = function() { $("a_highlight").setStyle('color', '#fdca00'); }
	}
	});
	
	
	
