function enableVideoThumbs(scrollToTop) {

    // START CUSTOM behavior for vimeo thumbnails (adapted from wp-content/plugins/fw-vimeo-videowall/fw-vimeo-videowall.js)

        jQuery(".fwvvw_vthumb").live('click',
                function() {

                    var idreq = jQuery(this).attr('id');
                    var expl_idreq = idreq.split('_');
                    var idvideo = expl_idreq[1];
                    var responsediv = '.videomain';

                    // templateUrl is initialized in header-medium-wide.php, just before loading of this file.
                    jQuery.post(templateUrl + "/vimeo-ajax-handler.php", {

                        'id': idvideo,
                        'height': '424',
                        'width': '640'
                    },

                            function(response) {
                                jQuery(responsediv).html(response);

                                if (scrollToTop) {

                                    scroll(0,0);
                                }
                            });
                });

    jQuery(".fwvvw_tablink").live('click',
         function() {
             jQuery('#tab-pane-spinner').show();
             jQuery("#fwvvw-tab-nav a").removeClass('fwvvw-tablink-selected');
             var thisElement = jQuery(this);
             thisElement.addClass('fwvvw-tablink-selected');
             var idreq = thisElement.attr('id');
                         var expl_idreq = idreq.split('_');
                         var source = expl_idreq[1];
                         var idsrc = expl_idreq[2];
                         var typesrc = expl_idreq[3];
                         var w = expl_idreq[4];
                         var h = expl_idreq[5];
                         var number = expl_idreq[6];

                         var page = expl_idreq[7];



             var responsediv = '#fwvvw-tab-pane';
             var wallDivId = 'wall-fwvvw-'+source+'-'+idsrc;

             jQuery.post( fwvvw_ajax_handler, {

                 action: 'show_page',
                 'id': idsrc,
                                 'source' : source,
                                 'type' : typesrc,
                                 'width' : w,
                                 'height' : h,
                                 'number' : number,

                                 'page' : page

                 },

                 function(response) {
                     jQuery('#tab-pane-spinner').hide();
                     response = '<div id="' + wallDivId + '" class="fwvvw-channel">' + response + '</div>'
                     jQuery(responsediv).html(response);

                 });
             return false;
     });



    // END CUSTOM behavior for vimeo thumbnails (adapted from wp-content/plugins/fw-vimeo-videowall/fw-vimeo-videowall.js)


    // START copy (copied without modification from wp-content/plugins/fw-vimeo-videowall/fw-vimeo-videowall.js)

    jQuery(".fwvvw_pagelink").live('click',
          function() {

              var idreq = jQuery(this).attr('id');
                          var expl_idreq = idreq.split('_');
                          var source = expl_idreq[1];
                          var idsrc = expl_idreq[2];
                          var typesrc = expl_idreq[3];
                          var w = expl_idreq[4];
                          var h = expl_idreq[5];
                          var number = expl_idreq[6];

                          var page = expl_idreq[7];



              var responsediv = '#wall-fwvvw-'+source+'-'+idsrc;

              jQuery.post( fwvvw_ajax_handler, {

                  action: 'show_page',
                  'id': idsrc,
                                  'source' : source,
                                  'type' : typesrc,
                                  'width' : w,
                                  'height' : h,
                                  'number' : number,

                                  'page' : page

                  },

                  function(response) {
                      jQuery(responsediv).html(response);
                  });
      });

    // END copy (copied without modification from wp-content/plugins/fw-vimeo-videowall/fw-vimeo-videowall.js)



}

function enableGalleryThumbs() {
    $("#gallery-thumbs a").each(function() {

        $(this).click(function(e) {
            var aHref = $(e.target).parent().attr("href");
            $("#gallery-main a").attr("href", aHref);
            $("#gallery-main a img").attr("src", aHref);
            return false;
        });
    });
}

function openNewWindowFor(linkTitle, linkUrl) {
    jQuery(function() {
        var menuLink = jQuery('ul.sf-menu a[title=' + linkTitle + ']');
        menuLink.attr("href", "#");
        menuLink.click(function() {
            window.open(linkUrl);
            return false;
        });
    });
}

function enableVideoThumbsLinkToVideosPage(bloginfoUrl) {
  jQuery(document).ready( function() {
        jQuery(".fwvvw_vthumb").live('click',
		function() {

			var idreq = jQuery(this).attr('id');
                        var expl_idreq = idreq.split('_');
                        var idvideo = expl_idreq[1];


			document.location.href = bloginfoUrl + '/videos?video_id=' + idvideo;
        });
  });
}

/* Most like only called from page-home.php. Choosing Your Setup page initializes scrollable directly, look in WP admin page content for that call. */ 
function enableScrollableSlider(circular) {

 jQuery(document).ready( function() {

        /* Initialize Scrollable "Coda Slider"
           Options listed at  */
        jQuery("div.scrollable").scrollable({
          size:1,
          clickable: false,
          circular: circular
        });

        /* If the previous arrow is hidden on initial load, show it after the first click on next and keep it shown
           This behavior looks intuitive on a looping (circular) slider. */
        var nextArrow = jQuery('.scrollable').children('a.next');
        nextArrow.bind('click.firstClick', function(event) {
           $(this).parent().children('a.prev').removeClass('hidden');
           nextArrow.unbind('click.firstClick');
        });


  });

}
