// dom
window.addEvent("load",function(){
var $b = $(document.getElementsByTagName('body')[0]);

	// init
	new SmoothScroll();

	// animation class
	Fx.Height = Fx.Style.extend( {
		initialize: function(el, options) {
		this.parent(el, 'height', options);
		this.element.setStyle('overflow', 'hidden');},toggle: function() {
		
		return (
			this.element.offsetHeight > 0) ?
			this.custom(this.element.offsetHeight, 0) :
			this.custom(0, this.element.scrollHeight);}, show: function() {

		return this.set(this.element.scrollHeight);}});
			Fx.Opacity = Fx.Style.extend({initialize: function(el, options) {
			this.now = 1;this.parent(el, 'opacity', options);},toggle: function() { 
			return (
			this.now > 0) ? this.start(1, 0) :
			this.start(0, 1);},show: function() { 
			return this.set(1);
							}
						});

// panello
if($('pannello') && $('pannello').hasClass('animate')) {
	var panel = $('pannello');
	var topAnim = new Fx.Style(panel,'top',{duration:1000,wait:false,transition:Fx.Transitions.Back.easeOut});
	var limit = panel.getParent().getCoordinates().top;
	var bottomLimit = panel.getParent().getSize().size.y + panel.getSize().size.y + 500;
	window.addEvent("scroll",function(){
		var pos = window.getScrollTop();
		if(pos <= limit) topAnim.start(125);
		else if(pos <= bottomLimit) topAnim.start(pos-limit+125);
		else topAnim.start(bottomLimit);
		});
	}
});
