/*     
 * Image Rotator & Community Page
 */

$(document).ready(function() {
  
  $('#facebook .fbConnectWidgetHeaderTitle').remove();
  
  /*
   * Nivo Slider (image rotator)
   * http://nivo.dev7studios.com
   */
  var slider = $('#slider');
  
  if (slider.length) {
    var slider_nav = 1;
    
    // initialize
    if (slider.hasClass('images')) {
      slider_nav = 0;
      slider.nivoSlider({
        effect:'fade',
        slices:1,
        animSpeed:300,
        pauseTime:4000,
        //directionNav:true,
        //directionNavHide:true,
        controlNav:false,
        keyboardNav:true,
        pauseOnHover:true,
        captionOpacity:0.8
      });
    } else {
      slider.nivoSlider({
        effect:'fade',
        slices:1,
        animSpeed:500,
        pauseTime:4000,
        //directionNav:true,
        //directionNavHide:true,
        controlNav:true,
        keyboardNav:true,
        pauseOnHover:true,
        captionOpacity:0.8
      });
    }
    
    /* if we're using the control navigation, move next/prev with the numbers */
    if (slider_nav) {
      slider.find('.nivo-controlNav').before('<div class="controls"></div>');
      var controls = slider.find('.controls');
      controls.append(slider.find('.nivo-controlNav'));
      controls.append(slider.find('.nivo-prevNav').html('&laquo;'));
      controls.append(slider.find('.nivo-nextNav').html('&raquo;'));
    }
    
    /* usually title attributes are used for the caption text, but since the
       images already contain the text, we're going to hide here */
    slider.find('.nivo-caption').remove();
    
    /* add last class */
    slider.find('a:last').addClass('last');
  }

});
