// $Id: views_nivo_slider.js,v 1.1.2.5 2010/04/20 14:44:18 pedrofaria Exp $ 
Drupal.behaviors.views_nivo_sliderBehavior = function (context) {
  $('.views-nivo-slider').each(function() {
    var id = $(this).attr('id');
    var vns = $(this);
    var cfg = Drupal.settings.views_nivo_slider[id];

    // Fix sizes
    vns.data('hmax', 0).data('wmax', 0);
    $('img', vns).each(function () {
      hmax =  (vns.data('hmax') > $(this).height()) ? vns.data('hmax') : $(this).height();
      wmax =  (vns.data('wmax') > $(this).width()) ? vns.data('hmax') : $(this).width();

      vns.width(wmax).height(hmax).data('hmax', hmax).data('wmax', wmax);
    });

    vns.nivoSlider({ 
      effect: cfg.effect,
      slices: cfg.slices,
      animSpeed: cfg.animSpeed,
      pauseTime: cfg.pauseTime,
      startSlide: 0,
      directionNav: cfg.directionNav == "true" ? true : false,
      directionNavHide: cfg.directionNavHide == "true" ? true : false,
      controlNav: cfg.controlNav == "true" ? true : false,
      controlNavThumbs: cfg.controlNavThumbs == "true" ? true : false,
      controlNavThumbsSearch: cfg.controlNavThumbsSearch,
      controlNavThumbsReplace: cfg.controlNavThumbsReplace,
      keyboardNav: cfg.keyboardNav == "true" ? true : false,
      pauseOnHover: cfg.pauseOnHover == "true" ? true : false,
      manualAdvance: cfg.manualAdvance == "true" ? true : false,
      captionOpacity: parseFloat(cfg.captionOpacity)
    });
  });
};
