function pagecarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
         carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
         return false;
    });

    jQuery('.jcarousel-scroll select').bind('change', function() {
         carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
         return false;
    });

   jQuery('#pagecarousel-next').bind('click', function() {
        carousel.next();
        return false;
   });

   jQuery('#pagecarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
  };

function peoplepagecarousel_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
         carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
         return false;
    });

    jQuery('.jcarousel-scroll select').bind('change', function() {
         carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
         return false;
    });

   jQuery('#peoplepagecarousel-next').bind('click', function() {
        carousel.next();
        return false;
   });

   jQuery('#peoplepagecarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
  };

// Credits: Robert Penners easing equations (http://www.robertpenner.com/easing/).
 jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
  if ((t/=d) < (1/2.75)) {
    return c*(7.5625*t*t) + b;
  } else if (t < (2/2.75)) {
    return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  } else if (t < (2.5/2.75)) {
   return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
   } else {
   return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  }
 };

   // Ride the carousel...
  jQuery(document).ready(function() {
    jQuery("#pagecarousel").jcarousel({
      scroll: 1,
      initCallback: pagecarousel_initCallback,
      // This tells jCarousel NOT to autobuild prev/next buttons
      buttonNextHTML: null,
      buttonPrevHTML: null
    });
  });

 // Ride the carousel...
jQuery(document).ready(function() {
      jQuery("#peoplepagecarousel").jcarousel({
        scroll: 1,
        easing: 'BounceEaseOut',
        animation: 1000,
        initCallback: peoplepagecarousel_initCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
  });

  function showPointer(id) {
    $j('#pointer' + id).show();
    $j("#img" + this.id).stop(true,true).slideDown('1500');
  }

  function showProfile(id, friendly_id, photo_handle) {

    url = "/articles/" + friendly_id;
    $j("#ajaxBusy").show();
    jQuery.getJSON(url, function(data) { 
      $j("#ajaxBusy").hide();
      new Effect.Highlight('proj_desc');
      $j("#proj_desc").html("<div style='margin-right:10px;'>" + data.body + "</div>"); 
      $j("#proj_title").html(data.title);
      $j('#p_img').attr('src', photo_handle);
      $j('#img'+data.id).show();

      (data.docs[0] == null) ? $j("#proj_ppt").html('') : $j("#proj_ppt").html("<a href='" + data.docs[0]['url'] + "'>Download PPT</a>");
      (data.references == null) ? $j("#proj_urls").html('') : $j("#proj_urls").html(data.references);

      Scroller.reset('proj_desc');
     });

     profiles = $j('#pagecarousel').find('.jcarousel-item');
     profiles.each(function(p) {
       if(p != id) {
         $j('#item'+p).removeClass('highlight');
         $j('#item'+p).addClass('unhighlight');
       }
       else if (p == id) {
         $j('#item'+p).removeClass('unhighlight');
         $j('#item'+p).addClass('highlight'); 
       }
     });
     

  }


 function loadAccordions(width,active_proj) {
   var topAccordion = new accordion('horizontal_container', {
                                     classNames : {
                                       toggle : 'horizontal_accordion_toggle',
                                       toggleActive : 'horizontal_accordion_toggle_active',
                                       content : 'horizontal_accordion_content'
                                       },
                        defaultSize : {
                          width : width 
                        },
                        direction : 'horizontal'
                      }); 
    topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[active_proj]);

  }




