window.addEvent('domready', function(){            
 new SmoothScroll();
});

window.addEvent('scroll', function(){
	var top=$('gotop');
	if (top) {
		if (window.getScrollTop()==0) $E('a',top).setStyle('visibility','hidden');
		else $E('a',top).setStyle('visibility','visible');		
	}
});

window.addEvent('load', function(){            
 var myTips = new Tips($$('.tooltip-trigger'), {
	 maxTitleChars: 30,
		fixed: true,
		className: 'tooltip'
 });
});

function Toggle(menu) {
	$$('#'+menu +' li').each(function(el, i) {
				if (el.hasClass('level1'))	{														
     el.removeClass('level1');
			 	el.addClass('level0');
				} else if (el.hasClass('level0'))	{														
     el.removeClass('level0');
			 	el.addClass('level1');
				}
  });
	return false;
}

function equalHeights(divs) {
	var height = 0;
		
	divs.each( function(e){
		if (e.offsetHeight > height){
			height = e.offsetHeight;
		}
		//e.removeClass('(^minh)');
	});
		
	divs.each( function(e){
		e.setStyle('height', height + 'px');
		if (e.offsetHeight > height) e.setStyle( 'height', (height - (e.offsetHeight - height)) + 'px' );
	}); 
}

var MyScroller = Scroller.extend({
		options: {
						initialScroll: true,
						amount: {'x': 1,'y': 0},
						onChange: function(x, y){
							this.element.scrollTo(x, y);
							if (this.initialTimer) this.initialTimer = $clear(this.initialTimer);
						}
		},
		initialize: function(element, options) {
						this.parent(element); // we call the parent method
						this.setOptions(options);
						
						this.element.addEvent('mouseenter', this.start.bind(this));
						this.element.addEvent('mouseleave', this.stop.bind(this));
						
						if (this.options.initialScroll) {
								this.initialTimer = this.initialScroll.periodical(20, this);
						}
		},
		initialScroll: function() {
				var el = this.element.getSize();
				this.element.scrollTo(el.scroll.x + this.options.amount.x, el.scroll.y + this.options.amount.y)
		}
});

//flash
function setVolume(vol) {
	Cookie.set('vol', vol, {duration: 365});
}

