
/********************

slider class runs the slider - requires isw_effects.js

takes the following arguments

headings - the array of elements used as buttons
contentpanes - the array of elements that will be opened or shut
eventType - the event to respond to - 'mouseover' or 'click'
type - the slider type, 'accordion' or 'toggler'
effect type - 'slide' or 'display' ( slide does not work well with some elements )
openIndex - index contentpane open at start


*****************************/



var ISW_Slider = new Class( {						   
						        initialize: function( headings, contentpanes, options ){
								  
							       this.headings = headings;
								   this.contentpanes = contentpanes;
							       this.options = [];
								   var initOptions = { eventType: 'click', type: 'accordion', effectType: 'slide', openIndex: 0 };								   
								   this.setOptions( initOptions );
								   this.setOptions( options );
								   
								   this.headings.setStyle('cursor','pointer');
								   
								   this.slide_holder = [];
								   this.contentpanes.each(function(item, index){							                                            //var myVerticalSlide = new Fx.Slide(item);
											if ( this.options.effectType == 'display' )
											{
											    var myVerticalSlide = new ISW_DisplayFx(item);
											}
											else if ( this.options.effectType == 'slide' )
											{
											    var myVerticalSlide = new ISW_SlideFx(item);
											}
											
		                                    if ( index != this.options.openIndex )
		                                    {
		                                          myVerticalSlide.hide();
												  myVerticalSlide.hide();
		                                    }
		                                   this.slide_holder.push( myVerticalSlide );

                                    }, this);
								   										   								   								   if ( this.options.type == 'toggler' )
									{																									                                  
								        this.headings.each( function( item, index){
											   item.addEvent( this.options.eventType, this.slide_toggle.bind( this, index ));					
																}, this);
									}
									else if ( this.options.type == 'accordion' )
									{
										//accordion
										 this.headings.each( function( item, index){
											   item.addEvent( this.options.eventType, this.accordion_slide.bind( this, index ));					
																}, this);
									}

  									   
							},/*end initialize*/
							
							setOptions: function( options )
							{
								for ( var prop in options )
								{
									this.options[ prop ] = options[ prop ];
								}
							},							
							slide_toggle: function( index ){								
                                   this.slide_holder[ index ].toggle();								
							},
							accordion_slide: function( index ){
								
								 for ( var i=0; i<this.slide_holder.length; i++)
								 {
									if ( index != i ){   
										this.slide_holder[ i ].hide(); }
								 }								 
								 this.slide_holder[ index ].slideIn();
							}
						
							 
							 
							 
});						   

