function getBookmark(box, bookmark)
{
    var loader = $(box+'_loader');

    if (loader != null)
        loader.setStyle('display', '');

    var request_url = host_url+'/www/box.php?box='+box+'&bookmark='+bookmark;
	var json = new cmsAjaxResponse(request_url, {loader: false }).doRequest();
}

function numerGetWybranyArt(art)
{
    var loader = $('wybrany_loader');

    if (loader != null)
        loader.setStyle('display', '');
    
    var request_url = host_url+'/www/box.php?nrart='+art;
	var json = new cmsAjaxResponse(request_url, {loader: false }).doRequest();
}

var entries = Array();

function setHref(item)
{
    (function(){ item.setAttribute('href', item.title); item.setAttribute('target', item.rel); } ).delay(1000);
}

function getAccordion(id, style)
{
    if (style == 'sub')
    {
        entries[id] = new Accordion('li.header'+id, 'li.entry'+id, {
                            onActive: function(toggler, element){
                                toggler.setAttribute('id', 'header_active_sub');
                                element.setStyle('display', '');
                                element.setStyle('height', 'auto');
                                var alist = toggler.getChildren();
                                setHref(alist[0]);
                            },
                            onBackground: function(toggler, element){
                                toggler.setAttribute('id', 'header_inactive_sub');
                                element.setStyle('display', 'none');
                                var alist = toggler.getChildren();
                                alist[0].href = 'javascript:void(0);';
                                alist[0].target = '_self';
                            },
                            height: false
//                            onComplete: function(el)
//                            {
//                                alert(el.getStyle('height'));
//                                if(el.getStyle('height') > 0)
//                                    el.setStyle('height', 'auto');
//                            }

                        });
    }
    else
    {
          entries[id] = new Accordion('li.header'+id, 'li.entry'+id, {
                            onActive: function(toggler){
                                toggler.setAttribute('id', 'header_active');
                                var alist = toggler.getChildren();
                                alist[0].href = alist[0].title;
                            },
                            onBackground: function(toggler){
                                toggler.setAttribute('id', 'header_inactive');
                                var alist = toggler.getChildren();
                                alist[0].href = 'javascript:void(0);';
                            }
                        });
    }
}

var scroll = Array();
var counter = Array();
var count = Array();
var items = Array();

function setScroll(id, it, len)
{
    if ( $('scroll'+id) == null ) return;    
    if ( $('scroll_content'+id) == null ) return;
    counter[id] = 0;
    items[id] = it;
    count[id] = $$("#scroll"+id+" .item").length;

    if (len != 0)
        $('scroll_content'+id).setStyle('width', (len*count[id])+'px')

    scroll[id] = new Fx.Scroll('scroll'+id, { onComplete: function(){setOpacityBar(id);} });
}

function setOpacityBar(id)
{
    if ($('opacity_'+id+'_'+counter[id]) == null)
        return;

    $$('div.opacity_bar').each(function(element){ element.setStyle('display', 'none'); });

    var bar = $('opacity_'+id+'_'+counter[id]);
    bar.setStyle('display', '');
}

function scrollSelect(id, it)
{
	scroll[id].toElement('item_'+id+'_'+it);
}

function scrollNext(id)
{
	counter[id]++;
    
	if ( counter[id] > count[id] - items[id])
        counter[id] = 0;

	scroll[id].toElement('item_'+id+'_'+counter[id]);
}

function scrollPrev(id)
{
    counter[id]--;
    
	if ( counter[id] < 0 )
        counter[id] = count[id] - items[id];

    if ( counter[id] < 0 )
        counter[id] = 0;

	scroll[id].toElement('item_'+id+'_'+counter[id]);
}