
	
function slideHeader(margin){
	new Effect.Morph('all_sliders_wrapper',{
		style:{'margin-top':margin},
		transition:Effect.Transitions.sinoidal,
		duration:0.5
	});
}
	
Element.addMethods((function(){
	var g={enter:'over',leave:'out'},h=/^mouse(enter|leave)$/;
	function i(f){
		if(Prototype.Browser.IE)return f;
		f=f.wrap(function(a,b){
			var c=Object.isElement(this)?this:this.element,d=b.relatedTarget;
			while(d&&d!=c){
				try{d=d.parentNode}
				catch(e){d=c}
			}
			if(d==c)return;a(b)
		});
		return f
	}
	var j=Prototype.Browser.IE?Event.observe:function(a,b,c){
		var a=$(a),d=h.exec(b);
		if(d){
			b='mouse'+g[d[1]];
			c=i(c)
		}
		Event.observe(a,b,c);
		return a
	};
	return{customObserve:j}
})());

var Slideable=Class.create({
	initialize:function(b){
		this.element=$(b);
		this.options=Object.extend({
			hoverBackground:'#101010',
			defaultBackground:'#303030',
			minimumHeight:150,
			resizeDuration:0.5,
			colorDuration:0.2,
			//transition:function(a){return((a/=0.5)<1?0.5*Math.pow(a,4):-0.5*((a-=2)*Math.pow(a,3)-2))}
			transition:Effect.Transitions.sinoidal
		},arguments[1]||{});
		this.prepare();	
	},
	prepare:function(){
		this.wrapper=this.element.down('.wrapper'),this.children=this.wrapper.childElements(),totalHeight=0;this._0=this.element.getHeight();
		this._2=(this._0/this.children.length).round();
		this.children.each(function(a){
			a._1=a.getHeight();
			totalHeight+=a._1;
			a.setStyle({height:this._2+'px'}).customObserve('mouseenter',this.mouseenter.bindAsEventListener(this)).customObserve('mouseleave',this.mouseleave.bindAsEventListener(this));
			var b=a.getStyle('backgroundColor');
			if(b){
				a._3=b;a.setStyle({backgroundColor:b})
			}
			a.down('.text').hide();
			a.setOpacity(0.5);
			a.down('.logo').setOpacity(1);
		}.bind(this));
		this.element.customObserve('mouseleave',this.restore.bindAsEventListener(this)).down('.wrapper').setStyle({height:totalHeight*3+'px',visibility:'visible'})
	},
	mouseenter:function(b){
		var c=b.findElement('.slide');
		if(!c)return;
		this.slide(c);		
	},
	slide:function(c){
		var d=this.children.without(c),f=((this._0-c._1)/d.length).round();
		Effect.Queues.get('resizeable').each(function(a){a.cancel()});
		//c.morph({backgroundColor:this.options.hoverBackground},{duration:this.options.colorDuration,queue:{scope:'resizeable'}});
		new Effect.Opacity(c, { to: 1, duration: 0.5 });
		new Effect.Morph(c,{
			style:{height:c._1+'px', 'background-position':'100px 0px'},
			queue:{scope:'resizeable'},
			transition:this.options.transition,
			delay:this.options.colorDuration,
			duration:this.options.resizeDuration, 
			afterFinish : function(){
				c.down('.text').appear({duration:0.5});
			}
		});
		new Effect.multiple(d,Effect.Morph,{style:{height:f+'px', 'background-position':'0px 0px'},queue:{scope:'resizeable'},transition:this.options.transition,delay:this.options.colorDuration,duration:this.options.resizeDuration});
	},
	mouseleave:function(a){
		var b=a.findElement('.slide');
		if(!b)return;
		//b.morph({backgroundColor:b._3||this.options.defaultBackground},{duration:this.options.colorDuration})
		b.down('.text').fade({duration:0.5});
		new Effect.Opacity(b, { to: 0.5, duration: 0.5 });
	},
	restore:function(){
		Effect.Queues.get('resizeable').each(function(a){a.cancel()});
		var b=this.children.last();
		b.setStyle({height:this._0+'px'});
		new Effect.multiple(this.children.without(b),Effect.Morph,{style:{height:this._2+'px', 'background-position':'0px 0px'},queue:{scope:'resizeable'},transition:this.options.transition,duration:this.options.resizeDuration})
	}
});