$(window).load(function() {
    Resize();
    $(window).resize(function() {
        Resize();
    });
    function Resize() {
        var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();
        viewportHeight = viewportHeight - 245;
        $("#container").css({ 'height': viewportHeight }, 0);
        $("#container .viewport").css({ 'height': viewportHeight - 30 }, 0);
        $("#container").tinyscrollbar();
    }

    $(".gallery-hor a, .gallery-ver a, #sidebar a.btn:not(:last-of-type), #sidebar ul.random-item li a, a.fancy, .fancy-form").fancybox();
    $(".gallery-video a").fancybox({
        type: 'iframe'
    });


    $("div.gallery-hor.read-more div").hide();
    $("div.gallery-hor.read-more strong").click(function() {
        $(this).prev("div").slideToggle(500);
    });

    $("a.top").click(function() {
        $(".overview, .thumb").animate({ 'top': '0' }, 400);
        setTimeout(function() {
            $("#container").tinyscrollbar();
        }, 400);
        return false;
    });
});
