window.addEvent('domready', function ()
{
	var itemNumber = 0;
	var actifItem = 0;
	$$('#menu dl').each(function(item)
	{
		if ( item.hasClass('oppened') )
			actifItem = itemNumber;
			
		++ itemNumber;
	});
	
	new Accordion('#menu dl dt', '#menu dl dd',
	{
		alwaysHide: false, 
		display: actifItem,
		
		onActive: function(el)
		{
			el.getParent().addClass('oppened');
		},
		onBackground: function(el)
		{
			el.getParent().removeClass('oppened');
		}
	});
	
	
	$$('.searchElemList .searchElem').addEvent('click', function(e)
	{
		var e = new Event(e);
		e.stop();
		
		$$('.searchElemAct').removeClass('searchElemAct');
		this.addClass('searchElemAct');
		
		$('tx_indexedsearch_mode').value = this.rel;
        
        document.tx_hpotool_form_searchbox.action = this.rel;
	});
    
    if (document.getElementById('thumbnails')){
        var scroll = new Scroller('thumbnails', {area: 100, velocity: 0.2});
        $('thumbnails').addEvent('mouseover', scroll.start.bind(scroll));
    }
});


function getAjaxPage(url, container, dontclosebefore){
    if (dontclosebefore){
        $(container).setStyle('opacity', 1);
        f.stop();
            //document.getElementById(container).style.display='none';
        //$(container).setHTML('');
    }
    new Ajax(url, {
        method: 'get',
        onComplete: function()
        {
            $(container).setStyle('opacity', 0);
            $(container).setHTML(this.response.text);
            f.start(1);
            
            
            $$($$("a").filter(function(el) {
                return el.rel && el.rel.test(/^lightbox/i);
            })).slimbox({
                loop: false,
                initialWidth: 400,
                initialHeight: 300,
                overlayOpacity: 0.6,
                overlayFadeDuration: 100,
                resizeDuration: 300,
                counterText: "{x}/{y}"
            }, null, function(el) {
                return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
            });
            
        }
    }).request();
}

function setClass(container){
    $$('#thumbnails .inside A').removeClass('selected');
    /*$$('#thumbnails .inside A').rel('lightbox-gal');*/
    $$('#thumbnails .inside '+container).addClass('selected');
    /*$$('#thumbnails .inside '+container).rel('');*/
}

function showLegende(obj, val){
    if (val){
        $('span_'+obj).setStyle('display', 'block');
        $('number_'+obj).setStyle('display', 'block');
    } else {
        $('span_'+obj).setStyle('display', 'none');
        $('number_'+obj).setStyle('display', 'none');
    }
}

