var simpleAccordion = Class.create({
	initialize: function(id, options){
		this.id = id;
		this.options = {
			toggle: '.toggle',
			position: 'next',
			wrap: '.accWrap',
			openClass: 'open',
			closeOthers: false
		};
		Object.extend(this.options, options);
		var i = 0;
		$$('#'+this.id+' '+this.options.toggle).each(function(link){
			this.close(link, 0);
			if(!i){this.open(link, 0);}
			i++;
			link.observe('click', function(evt){
				evt.stop();
				this.toggle(link);
			}.bind(this));
		}.bind(this));
	},
	toggle: function(link){
		if(link.hasClassName(this.options.openClass)){
			this.close(link, 1);
		} else {
			this.open(link, 1);
			if(this.options.closeOthers) {
				$$('#'+this.id+' '+this.options.toggle).each(function(l){
					if(l != link) this.close(l,1);
				}.bind(this));
			}
		}
	},
	open: function(link, effect){
		var wrap = this.getWrap(link);
		if(!effect){
			wrap.show();
		}else{
			wrap.blindDown({duration:0.2});
		}
		link.addClassName(this.options.openClass);
	},
	close: function(link, effect){
		var wrap = this.getWrap(link);
		if(!effect){
			wrap.hide();
		}else{
			wrap.blindUp({duration:0.2});
		}
		link.removeClassName(this.options.openClass);
	},
	getWrap: function(link){
		if(this.options.position == 'next') {
			return link.next(this.options.wrap);
		} else {
			return link.prev(this.options.wrap);
		}
	}
});