/**
 * @author syndicat
 * accordion that works with Prototype and Scriptaculous
 */

var Accordion = Class.create();
Accordion.prototype =  { 
	/**
	 * inintialize(arr, blindspeed)
	 * function creates new Accordion
	 * must be supplied with an array that contains div names
	 * 
	 * @param {array} arr
	 * @param {float} blindspeed
	 */
	initialize: function(arr, blindspeed){ 
		this.accord = new Array();
		for (var i = 0, len = arr.length; i < len; ++i){ 
			this.accord[i] = arr[i]; 
		}
		this.blindSpeed = blindspeed;
		this.previous;
	},
	
	/**
	 * slide(div)
	 * function determines which of the divs may slide open and which one should close
	 * 
	 * change divName var to below when you want to use the 'this' referer
	 * var divName = $(div).id;
	 * 
	 * @param {string} div
	 */
	slide: function(div){
		var divName = div;	
		for (var i = 0, len = this.accord.length; i < len; ++i){
			if (this.accord[i] == divName){
				new Effect.toggle(this.accord[i],'blind', {duration: this.blindSpeed}); 
			}	
			if(this.previous == this.accord[i]){ 
			  if(this.previous != divName){
				new Effect.BlindUp(this.accord[i], {duration: this.blindSpeed}); 
			  }
			}
		}
		this.previous = divName;
	}
}
//alert('Accordion loaded');
