/**
 * @file ajaxView.js
 *
 * Handles AJAX fetching of views, including filter submission and response.
 */
(function ($) {

/**
 * Attaches the AJAX behavior to Views exposed filter forms and key View links.
 */
Drupal.behaviors.ViewsAjaxView = {};
Drupal.behaviors.ViewsAjaxView.attach = function() {
  if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {
    // Retrieve the path to use for views' ajax.
    var ajax_path = Drupal.settings.views.ajax_path;

    // If there are multiple views this might've ended up showing up multiple times.
    if (ajax_path.constructor.toString().indexOf("Array") != -1) {
      ajax_path = ajax_path[0];
    }

    $.each(Drupal.settings.views.ajaxViews, function(i, settings) {
      var view = '.view-dom-id-' + settings.view_dom_id;
      var element_settings = {
        url: ajax_path,
        submit: settings,
        setClick: true,
        event: 'click',
        selector: view,
        progress: { type: 'throbber' }
      };

      // Process exposed filter forms.
      $('form#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'))
      .filter(':not(.views-processed)')
      .each(function () {
        var button = $('input[type=submit], input[type=image]', this);
        button = button[0];

        var ajax = new Drupal.ajax($(button).attr('id'), button, element_settings);
      })
      .addClass('views-processed')

      $(view).filter(':not(.views-processed)')
        // Don't attach to nested views. Doing so would attach multiple behaviors
        // to a given element.
        .filter(function() {
          // If there is at least one parent with a view class, this view
          // is nested (e.g., an attachment). Bail.
          return !$(this).parents('.view').size();
        })
        .each(function() {
          // Set a reference that will work in subsequent calls.
          var target = this;
          $(this)
            .addClass('views-processed')
            // Process pager, tablesort, and attachment summary links.
            .find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')
            .each(function () {
              var viewData = {};
              // Construct an object using the settings defaults and then overriding
              // with data specific to the link.
              $.extend(
                viewData,
                settings,
                Drupal.Views.parseQueryString($(this).attr('href')),
                // Extract argument data from the URL.
                Drupal.Views.parseViewArgs($(this).attr('href'), settings.view_base_path)
              );

              // For anchor tags, these will go to the target of the anchor rather
              // than the usual location.
              $.extend(viewData, Drupal.Views.parseViewArgs($(this).attr('href'), settings.view_base_path));

              element_settings.submit = viewData;
              var ajax = new Drupal.ajax(false, this, element_settings);
            }); // .each function () {
      }); // $view.filter().each
    }); // .each Drupal.settings.views.ajaxViews
  } // if
};
})(jQuery);
;

(function($){function FadeTransition(element,opts){var el=element,$el=$(el),fadeTimer=null,current=0,paused=false,self=this,options=$.extend({pauseTime:5000,transitionTime:2000,ignore:null,delayStart:0,pauseOnMouseOver:false,manualNavigation:false,createNavButtons:false,navButtonContainer:null},opts),els=(options.ignore)?$("> *:not("+options.ignore+")",el):$("> *",el);function setup(){$el.css("position","relative");els.css("display","none").css({left:0,top:0,position:"absolute"});els.filter(':first').css("display","block");if(options.createNavButtons){createNavButtons();highlightNav();}if(options.pauseOnMouseOver){$el.mouseover(pause).mouseout(unpause);$('a',options.navButtonContainer||el).mouseover(pause).mouseout(unpause);}if(options.delayStart>0){setTimeout(start,options.delayStart);}else{start();}}function transitionTo(nextIdx){$(els[current]).fadeOut(options.transitionTime);$(els[current=nextIdx]).fadeIn(options.transitionTime,cue);highlightNav();}function manualNav(e){var idx;this.blur();$(els).stop(true);clearTimeouts();$(els).css({'opacity':1,'display':'none'});$(els[current]).css({'display':'block'});idx=$('.fadenav a',el).index(this);transitionTo(idx);e.preventDefault();}function createNavButtons(){var i,nav=$('<div class="fadenav"></div>');for(i=0;i<els.length;i++){$('<a class="nav'+i+'" href="#">'+(i+1)+'</a>',options.navButtonContainer||el).click(manualNav).appendTo(nav);}nav.appendTo(options.navButtonContainer||el);}function highlightNav(){if(options.createNavButtons){$('.fadenav a',options.navButtonContainer||el).removeClass('current');$('.fadenav a:nth-child('+(1+current)+')',options.navButtonContainer||el).addClass('current');}}function start(){if(options.ignore){$(options.ignore,el).fadeOut(options.transitionTime);$(els[current]).fadeIn(options.transitionTime);fadeTimer=setTimeout(self.next,options.pauseTime+options.transitionTime);}else{highlightNav();if(!options.manualNavigation){fadeTimer=setTimeout(self.next,options.pauseTime);}}}function pause(){paused=true;clearTimeouts();}function unpause(){paused=false;cue();}function clearTimeouts(){if(fadeTimer){window.clearTimeout(fadeTimer);fadeTimer=null;}}this.show=function(item){if(typeof(els[item])!=='undefined'){clearTimeouts();transition(item);}return this;};this.currentItem=function(){return current;};function cue(){if(paused||options.manualNavigation||(els.length<2)){return false;}clearTimeouts();fadeTimer=window.setTimeout(self.next,options.pauseTime);}this.next=function(){transitionTo((current+1)%els.length||0);};this.prev=function(){transitionTo(((current||els.length)-1)%els.length);};$el.data('Fader',this);setup();}$.fn.fadeTransition=function(options){function getFader(){if(typeof $(this).data('Fader')==='object'){return $(this).data('Fader');}else{return new FadeTransition(this,options);}}this.fader=function(){if(typeof $(this).filter(':first').data('Fader')==='object'){return $(this).filter(':first').data('Fader');}return null;};return this.each(getFader);};}(jQuery));
;
(function ($) {

  Drupal.behaviors.fade = {
    attach: function () {
      $('#block-views-front_page_slideshow-block .view-content').fadeTransition({pauseTime: 2000,
                                                  transitionTime: 2000,
                                                  delayStart: 2000,
                                                  pauseOnMouseOver: false,
                                                  createNavButtons: true});
    }
  };

}(jQuery));
;

