var URL = '/';
dirImages = URL+'images/';

$(document).ready(function()
{
    unBlurAllLinks();
    setDefaultValue('sfsearch', 'zadejte hledaný text');
    
    $('a[href=#top]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });
    
	toplist.init();
	if (getElement('hmarklist'))
	    mnc = new scrolls('scrollMarkMenu', 0, 0, 751, 110, 'fast');
	    
    $('#hmarklist .vice').click(function(){
        if (mnc.scrollObject.scrollLeft < mnc.maxLeft)
        {
            $('#scrollMarkMenu').animate({scrollLeft: '+=751'}, 1000);//, 'easeOutQuart');
            mnc.posLeft+=124;
        }
        else
        {
            $('#scrollMarkMenu').animate({scrollLeft:0}, 1500);
            //mnc.posLeft=0;
        }
        return false;
    });

    menut = new eltabs1('tabarts');
    Cron.set('menut.toggle()', 10000);
});

var toplist = {
        items_count         :   0,        
        items_paused        :   0,        
        items               :   new Array(),
        items_id            :   new Array(),
        index_current       :   null,
        item_current        :   null,
        
        init                :   function(){
            $('.topadverts .prev a').click(function(){
                if (toplist.index_current>1)
                {
                    $('.thumbslayer').animate({left: '+=122'}, 700, 'easeOutQuart', function(){
                    });
                    toplist.index_current--;
                    toplist.current();
                }
            });
            $('.topadverts .next a').click(function(){
                if (toplist.index_current<toplist.items_count)
                {
                    $('.thumbslayer').animate({left: '-=122'}, 700, 'easeOutQuart', function(){
                    });
                    toplist.index_current++;
                    toplist.current();
                }
            });
            
            this.item_current   =  {
                item            :   $(".topadverts .current").get(0),
                label           :   $(".topadverts .current .label").get(0),
                link            :   $(".topadverts .current .link").get(0),
                art             :   $(".topadverts .current .art").get(0)                
            };

            a_blocks = $('.thumbslayer>.thumb');
            this.items_count = a_blocks.length;
            var id = null;
            for (i=0; i<a_blocks.length; i++)
            {
                this.items[i+1] = a_blocks[i];
                if (!this.index_current)
                {
                    this.index_current = 2;
                    /*$(a_blocks[i]).children().each(function(){
                        
                    });*/
                }
            }
            if (this.items_count>1)
                this.current(2);
            else
                this.current(1);
        },
        current             :   function(index){
            if (typeof(index)=='undefined')
                index = toplist.index_current;
            if (typeof(toplist.items[index])!='undefined')
            {
                $(toplist.item_current.label).text($(toplist.items[index]).children('.label').text());
                toplist.item_current.link.href = $(toplist.items[index]).children('.art').get(0).href;
                if ($(toplist.items[index]).children('.art').eq(0).children('img.big').length)
                {
                    bigimg = $(toplist.items[index]).children('.art').eq(0).children('img.big').get(0);
                    src = bigimg.src;
                }
                else
                    src = false;
                $(toplist.item_current.art).removeClass('hide');
                if (!$(toplist.item_current.art).children('img').length)
                {
                    $(toplist.item_current.art).append($(bigimg).clone());
                    $(toplist.item_current.art).eq(0).children('img.big').fadeIn(100);
                }
                else
                {
                    img = $(toplist.item_current.art).children('img');
                    img.get(0).newsrc = bigimg.src;
                    img.get(0).newstyle = $(bigimg).attr('style');
                    img.get(0).newalt = $(bigimg).attr('alt');
                    img.get(0).newtitle = $(bigimg).attr('title');
                    img.fadeOut(200, function(){
                        $(this).attr({
                            src:    $(this).get(0).newsrc,
                            style:  $(this).get(0).newstyle,
                            alt:    $(this).get(0).newalt,
                            title:  $(this).get(0).newtitle
                        });
                        $(this).fadeIn(200);
                    });
                }
            }
        }
};

