// -----------------------------------------------------------------------------------------------
//
//	Copyright 2011, Orbital Guidance Industries, Ltd. (orbitalguidance.com), All rights reserved.
//
//	This work is provided under a royalty-free, non-exclusive license in perpetuity to
//	residualzen (residualzen.com) and its clients.
//
// -----------------------------------------------------------------------------------------------
//
//	Mootools dependencies from Mootools More - Fx.Slide
//
//  <http://mootools.net/docs/more/Fx/Fx.Slide>
//
// -----------------------------------------------------------------------------------------------

var SimpleSlider = new Class(
{
	options:
	{
		// Slider orientation: 'vertical' or 'horizontal'
		orientation: 'vertical',
		
		// Initial state of slider: 'show', 'hide', 'in' or 'out'
		slide: 'show',
		
		// Duration of slider effect: 'normal', 'short' 'long' or a value in milliseconds (i.e. 500 = 1/2 sec)
		duration: 'normal',
		
		// Transition effect -- popular choices: 'sine:in:out' or 'linear' and for more choices please see <http://mootools.net/docs/core/Fx/Fx.Transitions>
		transition: 'sine:in:out',
		
		// Direction of fade upon trigger: 'show', 'hide', 'in', 'out', 'toggle', a value between 0.0 to 1.0 or null (no fade effect)
		fade: null,
		
		// Container element id upon which slider acts
		container: null,
		
		// Trigger element id upon which slider in activated
		trigger: null
	},
	
	initialize: function(options, events)
	{
		this.setOptions(options);
		
		var container = $(this.options.container);
		
		var slider = new Fx.Slide(container,
		{
			mode: this.options.orientation,
			duration: this.options.duration,
			transition: this.options.transition,
			onStart: function()
			{
				if (this.options.fade)
				{
					$(this.options.container).fade(this.options.fade);
				}
			}.bind(this)
		});
		
		switch (this.options.slide)
		{
			case 'show': { slider.show(); break; }
			case 'hide': { slider.hide(); break; }
			case 'in': { slider.slideOut(this.options.orientation); break; }
			case 'out': { slider.slideIn(this.options.orientation); break; }
			default: { break; }
		}
		
		$(this.options.trigger).addEvent('click', function(event)
		{
			event.stop();
			slider.toggle();
		});
	}
});

SimpleSlider.implement(new Options, new Events);

