window.addEvent('domready', function() {

	//YOUTUBE
	SqueezeBox.initialize();
	$$('.yotube-over').each(function(el) {
	    el.addEvent('click', function(e) {
	        e.stop();
	        var code = this.get('ref');
	        var width = 590;
	        var height = 360;
	        var youtube = new Element('div');
	        var html = '<object width="'+width+'" height="'+height+'">';
	        html += '<param name="movie" value="http://www.youtube.com/v/'+code+'&autoplay=1"></param>'
	        html += '<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>';
	        html += '<embed src="http://www.youtube.com/v/'+code+'&autoplay=1" type="application/x-shockwave-flash"';
	        html += ' allowscriptaccess="always" allowfullscreen="true" width="'+width+'" height="'+height+'"></embed></object>';
	        youtube.set('html', html);
	        SqueezeBox.open(youtube, {
	            handler: 'adopt',
	            size: {x: (width + 4), y: (height + 5)}
	        });
	    });
	});

	//ARCHIV
	if ($('archive')) { // navigacia {{{

        // najprv vyrobit
        var navList = new Array();
        $('archive').getElements('ul li a').each(function(item) {
            if (!navList[item.get('text').match('\\d\\d\\d\\d')]) {
                navList[item.get('text').match('\\d\\d\\d\\d')] = new Array();
            }
            navList[item.get('text').match('\\d\\d\\d\\d')].push('<a href="' + item.get('href') + '">' + item.get('text').match('[^\\d].*') + '</a>');
        });
        $('archive').getElement('ul').set('html', ''); // vyclearujeme a spravime ten hierarchicky ul
        navList.each(function(months, year) {
            var myList = new Element('li', {
                'class': 'navAccordionTogglers plus',
                'html':  '<a href="#" class="" onclick="return false;">+ ' + year + '</a><ul class="navAccordionElements"><li>' + months.join('</li><li>') + '</li></ul>'
            }).inject($('archive').getElement('ul'), 'top');
        });

        // potom accordion
        var navAccordion = new Fx.Accordion(
            document.getElementsByClassName('navAccordionTogglers'),
            document.getElementsByClassName('navAccordionElements'),
            { display: -1 }
        );
        navAccordion.addEvents({
            'active': function(toggler, element) {
                toggler.addClass('active');
                a = toggler.getElement('a');
                a.set('html', '-' + a.get('html').substr(1));
            },
            'background': function(toggler, element) {
                toggler.removeClass('active');
                a = toggler.getElement('a');
                a.set('html', '+' + a.get('html').substr(1));
            }
        });

        navAccordion.display(0);
    } // }}}

	
	//PRODUKTY MENU
	if ($('produkty-menu')) {
		
	}
	
	if ($('topreference')) { // slider {{{
        refSlider = new slideGallery($('slideshow_wrapper'), {
        	elementsParent: 'div',
            steps: 1, // o kolko sa ma posunut?
            mode: 'circle',
            random: 'false',
            autoplay: false,
            elements: 'a',
            prevItem: '#slideLeft',
            nextItem: '#slideRight',
            duration: 3000,
            speed: 800
        });
    } // }}}

});
