var SlideList = new Class({
 initialize: function(menu, options) {
 this.setOptions(this.getOptions(), options);
 
 this.menu = $(menu), this.current = this.menu.getElement('li.current');
  
 this.menu.getElements('li').each(function(item){
 item.addEvent('mouseover', function(){ this.moveBg(item); }.bind(this));
 item.addEvent('mouseout', function(){ this.moveBg(this.current); }.bind(this));
 item.addEvent('click', function(event){ this.clickItem(event, item); }.bind(this));
 }.bind(this));
  
 this.back = new Element('li').addClass('background').injectInside(this.menu);
 this.back.fx = this.back.effects(this.options);
 if(this.current) this.setCurrent(this.current);
 },
  
 setCurrent: function(el, effect){
 this.back.setStyles({left: (el.offsetLeft)+'px', width: (el.offsetWidth)+'px'});
 (effect) ? this.back.effect('opacity').set(0).start(1) : this.back.setOpacity(1);
 this.current = el;
 },
  
 getOptions: function(){
 return {
 transition: Fx.Transitions.sineInOut,
 duration: 500, wait: false,
 onClick: Class.empty
 };
 },
  
 clickItem: function(event, item) {
 if(!this.current) this.setCurrent(item, true);
 this.current = item;
 this.options.onClick(new Event(event), item);
 },
  
 moveBg: function(to) {
	 if(!this.current) return;
	 this.back.fx.custom({
 			left: [this.back.offsetLeft, to.offsetLeft],
 			width: [this.back.offsetWidth, to.offsetWidth]
			});
 	}
 });
  
 SlideList.implement(new Options);

// usuniete onClick: function(ev, item) { ev.stop(); } !!!! inaczej nei dzialaja linki
window.addEvent('domready', function() {
new SlideList($E('ul', 'mainmenu'), {transition: Fx.Transitions.sineInOut, duration: 500});
});



function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

/**
 * Light Menu System v0.1
 * @author Jonathan Schemoul
 * @copyright 2006-2007 Holdiland
 * @license GPL V2 or newer
 */
var menuEffects = new Class({
        initialize: function(selector, options) {
                this.options = Object.extend({
                        subElement: false,
                        subElementSelector: 'a'
                }, options || {})
                this.selector = selector;
                this.currTimer = 1900;
                $ES(selector + ' li ul').each(function(el) {
                        el.setStyles({
                                'display': 'block'
                        });
                        normalHeight = el.offsetHeight;
                        el.setStyles({
                                'opacity': '0'
                        });
                        elParent = $(el.parentNode);
                        
                        currentMenu = new Fx.Style(el, 'opacity');
                        elParent.addEvents({
                                'mouseover': function(submenu, myParent, targetValue) {
                                        myParent.addClass('hover');
                                        submenu.clearTimer();
                                        submenu.custom(targetValue);
                                }.pass([currentMenu, elParent, 1]),
                                'mouseout': function(submenu, myParent, targetValue) {
                                        myParent.removeClass('hover');
                                        submenu.clearTimer();
                                        submenu.custom(targetValue);
                                }.pass([currentMenu, elParent, 0])
                        })
                }.bind(this));
        }
});
function processMenuEffects (){
        var myMenus = new menuEffects('#mainmenu', {
                subElement: true
        });
}
window.onDomReady(processMenuEffects);
