var slideshow = function(container_selector) {
    // Initialize Advanced Galleriffic Gallery
    var slideshow_selector = container_selector+"-slideshow";
    var thumbs_selector = container_selector+"-thumbs";
    var galleryAdv = $(thumbs_selector).galleriffic({
         delay:                  7000,
         defaultTransitionDuration: 850,
         preloadAhead:           1,
         enableTopPager:         false,
         enableBottomPager:      false,
         imageContainerSel:      slideshow_selector,
         loadingContainerSel:    container_selector+'-loading',
         renderSSControls:       false,
         renderNavControls:      false,
         enableHistory:          false,
         autoStart:              true,
         syncTransitions:        false
    });
};

$(document).ready(function() {
    // ajaxify comments
    $(".submit-post").live("click", onSubmitComment);

    $("#boxcontainer").boxify();

    $(".box.showcase.closed.opener").live('click', function() {
        var $this = $(this);
        slideshow("#"+$this.attr("id"));
    });

    $(".click-to-post-a-comment").live('click', function(e) {
        if (e.button != 0) return true;
        var $comment_box = $("#"+$(this).attr("name")+".post-a-comment");
        var $parent = $(this).closest(".box");
        $comment_box.css("display", "inline");
        $.fn.boxify.open_box($parent, true);
        // needs to resize the box it's in to fit the form.
        //resize_box( $("#"+comment_box.attr("name")), false);
    });

    // also check if there's room on the page to load more. if so, load more!
    if($(document).height() <= $(window).height()){
        $(document).trigger('retrieve.infscr');
    }
});



