$(function(){
    var $searchForm = $('div#searchBox form');
    $('div.submit input.inputSubmit', $searchForm).hide();
    $('div.submit a.aSubmit', $searchForm).show().click(function(){
        $searchForm.submit();
        return false;
    });
    
    $('div.text').each(function(){
        var $text = $(this);
        $('div.textsize', $text).show();
        
        if($text.hasClass('text-big'))
        {
            $('div.textsize div.big', $text).addClass('active');
        }
        else
        {
            $('div.textsize div.small', $text).addClass('active');
        }
        
        $('div.textsize div.small', $text).click(function(){
            if(!$text.hasClass('text-big')) return false;
        
            $('div.textsize div.active', $text).removeClass('active');
            $(this).addClass('active');
            
            $text.removeClass('text-big');
        });
        $('div.textsize div.big', $text).click(function(){
            if($text.hasClass('text-big')) return false;
            
            $('div.textsize div.active', $text).removeClass('active');
            $(this).addClass('active');
            
            $text.addClass('text-big');
        });
    });
    
    $('div#separator div#showcase').each(function(){
        var $showcase = $(this);
        $('div.navigate span', $showcase).hover(function(){
            //$(this).addClass('hover');
        }, function(){
            //$(this).removeClass('hover');
        });
        var $scroll = $('div.scroll', $showcase);
        
        $scroll.css('width', ($('div.item', $showcase).length * 140)+'px');
        
        if($('div.item', $showcase).length <= 4)
        {
            $('div.navigate span', $showcase).hide();
            return true;
        }
        
        var animation = false;
        
        $('div.left span', $showcase).click(function(ev){
            if(animation)
            {
                return false;
            }
            
            animation = true;
            
            $scroll.css("left", (parseInt($scroll.css("left"))-140)+'px');
            $item = $('div.item:last', $showcase);
            $item.clone(true).prependTo($scroll);
            $item.remove();

            $scroll.animate({"left": '+=140px'}, 300, function(){
                animation = false;
            });
        });
        $('div.right span', $showcase).click(function(ev){
            if(animation)
            {
                return false;
            }
            animation = true;
            
            $scroll.animate({"left": '-=140px'}, 300, function(){
                $item = $('div.item:eq(0)', $showcase);
                $item.clone(true).appendTo($scroll);
                $item.remove();
                $scroll.css("left", (parseInt($scroll.css("left"))+140)+'px');
                
                animation = false;
            });
        });
    });
    
    $.superbox.settings = {
        boxId: "superbox", // Id attribute of the "superbox" element
        boxClasses: "", // Class of the "superbox" element
        overlayOpacity: .8, // Background opaqueness
        boxWidth: "600", // Default width of the box
        boxHeight: "400", // Default height of the box
        loadTxt: "Ładowanie...", // Loading text
        closeTxt: "Zamknij", // "Close" button text
        prevTxt: "Poprzednie", // "Previous" button text
        nextTxt: "Następne" // "Next" button text
    };
    $.superbox();
});
