jQuery(function(){
  
  // detect iphone and put iphone class in body tag
  if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
  {
    $('body').addClass('iphone');
  }
  
  // screenshot slideshow
  $('ul#gc_pictures_carousel.carousel').jcarousel({
    scroll: 1,
    initCallback: init_carousel,
    buttonNextCallback: next_callback,
    buttonPrevCallback: prev_callback
  })
  

})

function next_callback(carousel,button,disable)
{
  var button = $('.carousel_controls .next');
  
  if(disable)
  {
    button.removeClass('disabled');
  }
  else
  {
    button.addClass('disabled');
  }
}

function prev_callback(carousel,control,disable)
{
  var button = $('.carousel_controls .previous');
  
  if(disable)
  {
    button.removeClass('disabled');
  }
  else
  {
    button.addClass('disabled');
  }
}



// this method binds forward/next using generic
// class names, so it can be used for any carousel
function init_carousel(carousel)
{
  // binds next button
  $('.carousel_controls .next').bind('click', function(){
    carousel.next();
    return false;
  });
  
  
  // binds previous button 
  $('.carousel_controls .previous').bind('click', function(){
    carousel.prev();
    return false;
  });
}

