/**
 * @package    JMyLife
 * @subpackage Components
 * @version    1.0.12.1
 * @copyright  2009-2010 Jeff Channell
 * components/com_jmylife/assets/js/footerToggle.js
 * @license    

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
	
 */
var emdash = '−';
if( typeof jQuery != 'undefined' )
{
	jQuery(document).ready( function()
	{
		jQuery('.comJMyLifeItemFooterToggle').each( function()
		{
			var el = jQuery(this);
			el.click( function()
			{
				el.text( el.text() == emdash ? '+' : emdash ).next().stop().animate({opacity: 'toggle'}, 400); 
			}).next().hide();
		});
	});
}
else
{
	window.addEvent( 'load', function()
	{
		$$('.comJMyLifeItemFooterToggle').each( function( el )
		{
			var moo2 = 0;
			var fadefx;
			try
			{
				fadefx = new Fx.Style( el.getNext(), 'opacity', { duration: 400, transition: Fx.Transitions.Quad.easeIn } );
			}
			catch( err )
			{
				moo2 = 1;
				fadefx = new Fx.Morph( el.getNext(), { duration: 400, transition: Fx.Transitions.Quad.easeIn, wait: false } );
			}
			fadefx.set( moo2 ? {opacity:0} : 0 );
			el.addEvent( 'click', function( e )
			{
				new Event( e ).stop();
				try
				{
					fadefx.stop();
				}
				catch( err ){}
				var eltxt;
				try{ eltxt = el.getText() } catch( err ){ eltxt = el.get('text'); }
				switch( eltxt )
				{
					case '+':
						fadefx.start( moo2 ? {opacity:1} : 1 );
						try{ el.setText( emdash ); } catch( err ){ el.set( 'text', emdash ); }
						break;
					case emdash:
						fadefx.start( moo2 ? {opacity:0} : 0 );
						try{ el.setText( '+' ); } catch( err ){ el.set( 'text', '+' ); }
						break;
					default:
						// this shouldn't happen :)
						alert( 'You have somehow managed to do something amazing. Congrats.' );
						break;
				}
			});
		});
	});
}
