$(document).ready(function() {
    
    var lookbook_fancybox_options = {
        'padding': 0,
        'overlayColor': '#000',
        'overlayOpacity': 0.75,
        'onComplete': function() {
            $("#lookbook-scrollbox").scrollbox({'simple_pagination': true, 'slideshow': false, 'description': true})
//             })
        }
    }
    
    $("#nav-lookbook-link a").fancybox(lookbook_fancybox_options)
    
    $("#lookbook-pagination a").livequery(function() {
        $(this).fancybox(lookbook_fancybox_options)
    })

    $(".sidebar-pagination-arrow").live('click', function() {
        $.ajax({
            url: $(this).attr('href'),
            success: function(data) {
                $(".sidebar-wrapper").animate({
                    'opacity': 0
                }, 500, function(callback) {
                    $(".sidebar-wrapper").html(data)
                    scroll_sidebar_load()
                })
                $(".sidebar-wrapper").animate({
                    'opacity': 1
                }, 500)
            }
        })
        return false
    })

    $("#content").hide()
    $("#content").fadeIn(1000)
        
    $("#nav-subcategories a, #nav-category-link").click(function() {
        $("#content").animate({
            'opacity': 0
        }, 800)
        if($(this).attr('id') == 'nav-category-link') {
            $("#logo").animate({
                'opacity': 0
            }, 800)
        }
    })
            
    $("#nav-pages a, #nav-shop-link a").click(function() {
        $("#content").animate({
            'opacity': 0
        }, 800)
    })
    
    var referrer = document.referrer.split('/')
    var referrer_category = referrer[3]
    if(
            (referrer_category == '' && $("body").attr('class') == 'handmade') ||
            (referrer_category == 'handmade' && $("body").attr('class') == 'graphic')
        ) {
        $("#logo").css('opacity', 0)
        $("#logo").animate({
            'opacity': 1
        }, 1000)
    }

})

