function hide_text(ids) {
  jQuery.each(ids, function() {
    jQuery('#'+this).fadeOut('fast');
  });
}
function show_text(ids,i) {
  jQuery.each(ids, function() {
    var e = jQuery('#'+this);
    e.html(jQuery('#slide'+i+' .'+this).html());
    e.fadeIn('fast');
  });
}
jQuery(document).ready(function() {
  c = jQuery('ul#portfolio');
  if (c.size() > 0) {
    c.jcarousel({
      scroll: 1,
      buttonNextHTML: null,
      buttonPrevHTML: null,
      initCallback: function(carousel) {
                      jQuery('#portfolio_container .pager a.next').bind('click', function() {
                        carousel.next();
                        return false;
                      });
                      jQuery('#portfolio_container .pager a.prev').bind('click', function() {
                        carousel.prev();
                        return false;
                      });
                    },
      itemFirstOutCallback: {
        onBeforeAnimation: function(carousel, item, i, state) {
                             hide_text(['portfolio_content', 'project_link', 'project_footnote']);
                           }
      },
      itemFirstInCallback: {
        onAfterAnimation: function(carousel, item, i, state) {
                            jQuery('span#photo_num').html(i);
                            show_text(['portfolio_content', 'project_link', 'project_footnote'],i);
                          }
      }
    });

    jQuery('a.enlarge').lightbox({
      fileLoadingImage: '/wp-content/themes/asterisk/images/lightbox-ico-loading.gif',
      fileBottomNavCloseImage: '/wp-content/themes/asterisk/images/lightbox-btn-close.gif',
      fitToScreen: true,
      containerResizeSpeed: 350
    });
  }
});

