/*
	Sarah Backhouse, Jadu LTD 16.02.2011
*/

var descriptionSlider = Class.create({
	initialize: function (wrapper) {
		this.wrapper			= $(wrapper);
		this.span			= this.wrapper.down('span');
		this.animating		= false;
		this.height			= this.span.getHeight();
		
		this.span.setStyle({'display': 'none', 'padding': '0 10px', 'height': '0'});
		
		this.wrapper.observe('mouseenter', this.blinddown.bind(this));
		this.wrapper.observe('mouseleave', this.blindup.bind(this));
	},
	blinddown: function (event) {
		if (event) { 
			Event.stop(event); 
		}
		if (!this.animating) {
			new Effect.BlindDown(this.span, { duration:0.2, beforeStart: function() { this.animating = true; }, afterFinish: this.finishDown()});
		}
	},
	blindup: function (event) {
		if (event) { 
			Event.stop(event); 
		}
		if (!this.animating) {
			new Effect.BlindUp(this.span, { duration:0.2, beforeStart: function() { this.animating = true; }, afterFinish: this.finishUp()});		
		}	
	},
	finishDown: function () {
		this.animating = false;
		this.span.style.height = this.height + 'px';
	},
	finishUp: function () {
		this.animating = false;
		this.span.style.height = '0';
	}

});


