/* SITE-WIDE JAVASCRIPT */

// Share This
stLight.options({publisher:'3a54c5f3-4e46-41d2-9ea9-1a1e88ceadb1'});

jQuery(function($) {

    // MODAL
    //////////////////////////////////////////////
    $("a.modal").live("click", function(evt) {

        // modal variables
        var $backdrop = $("#modal-backdrop"),
            $modal = $("#modal");
            $modal_content = $modal.find("#modal-content");

        // Fade In white Backdrop
        $backdrop.fadeTo(0, 0.8);
        // Scroll window to top before modal window loads
        $('html, body').animate({scrollTop:0}, 350, function() {
            // Use ScrollFollow Plugin to follow close button.
            $("#modal-close").scrollFollow({offset:20});
        });
        
        // Grab all content from #modal-placeholder div in the provided url
        $modal_content.load(this.href + " #modal-placeholder", function() {
            $backdrop.removeClass("modal-loader");
            $modal.show();
        });
        
        // Close modal when clicked
        $("#modal-close, #modal-backdrop").click( function() {
            $backdrop.hide().addClass("modal-loader");;
            $modal.hide();
        });
        
        // print when clicked
        $("#modal-print").bind("click", function(){ 
            $modal_content.printElement();
        })
        
        evt.preventDefault();
    });
    
});
