(function($){

Drupal.behaviors.primarymenu = {
    attach: function (context, settings) {
      $('#block-menu-block-1 .expanded', context).once('primarymenu', function () {
        $(this).hover(
          function() {
            $('ul', $(this)).stop(1,1).delay(250, function() {
              $(this).stop(1,1).fadeIn(300)
            })
          },
          function() {
            $('ul', $(this)).stop(1,1).delay(100, function() {
              $(this).stop(1,1).fadeOut(100)
            })         
          }
        )
      });
    }
  };
  
  Drupal.behaviors.Accordion = {
	

    attach: function(context, settings) {
    	$('.view-faq .group-right', context).once('Accordion', function(){
    		var $this = $(this);
    		$this.find('.views-field-body').hide();
    		$this.find('.views-row').click(function(){
    			$this.find('.views-field-body').slideUp();
    			var $content = $(this).find('.views-field-body');
    			if($content.hasClass('open')){
    				$content.slideUp(function(){
    					$(this).removeClass('open');
    				});
    			}
    			else{
    				$(this).find('.views-field-body').slideDown(function(){
    					$(this).addClass('open');
    				});
    			}
    		});
    	});
    }
   };
   
   Drupal.behaviors.AccordionFaq = {
    attach: function(context, settings) {
    	$('.view-id-taxonomy_term', context).once('AccordionFaq', function(){
    		var $this = $(this);
    		$this.find('.field-name-body').hide();
    		$this.find('.views-row').click(function(){
    			$this.find('.field-name-body').slideUp();
    			var $content = $(this).find('.field-name-body');
    			if($content.hasClass('open')){
    				$content.slideUp(function(){
    					$(this).removeClass('open');
    				});
    			}
    			else{
    				$(this).find('.field-name-body').slideDown(function(){
    					$(this).addClass('open');
    				});
    			}
    		});
    	});
    }
   };
   
   Drupal.behaviors.allLink = {
   	  		    attach: function(context, settings) {
   	  		    	$('.view-actualites .views-row, .view-evenements .views-row, .view-archives .views-row', context).once('allLink', function(){
   	  		    		var test = $("a").exists;
						if(test !== 'undefined'){		
							var link = $(this).find('a');
							var href = link.attr('href');
							var childs = $(this).children();
							childs.wrap('<a class="all-link" href="'+href+'"></a>');
						}
   	  		    	});
   	  		    }
   	  		   };
 
 
}(jQuery));;
(function ($) {
 
 // initialisation :
  Drupal.thouare2011 = Drupal.thouare2011 || {}

  // --- Behavior ---
  Drupal.settings.thouare2011 = Drupal.settings.thouare2011 || {}


  // Définition d'une behavior :
  Drupal.thouare2011.agendaBlockDate = function(element) {
    element.addClass('agenda-block-processed');


    jQuery("#views-exposed-form-evenements-calendrier-accueil-block .views-exposed-form").datepicker( {
      altField: 'input#edit-date-value-date',
      altFormat: 'dd-mm-yy',
      closeText: 'Fermer',
      prevText: 'Précédent',
      nextText: 'Suivant',
      currentText: 'Aujourd\'hui',
      monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
      'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
      monthNamesShort: ['Janv.','Févr.','Mars','Avril','Mai','Juin',
      'Juil.','Août','Sept.','Oct.','Nov.','Déc.'],
      dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
      dayNamesShort: ['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.'],
      dayNamesMin: ['D','L','M','M','J','V','S'],
      weekHeader: 'Sem.',
      dateFormat: 'dd/mm/yy',
      firstDay: 1,
      isRTL: false,
      showMonthAfterYear: false,
      yearSuffix: ''
      }
      //jQuery.datepicker.regional['fr']
    );

    jQuery('.ui-state-default').live('click', function(){
      jQuery('#views-exposed-form-evenements-calendrier-accueil-block').submit();
    });

  }

  Drupal.behaviors.thouare2011 = {
    attach: function(context, settings) {
      // Appel des behaviors :
      jQuery('#views-exposed-form-evenements-calendrier-accueil-block:not(.agenda-block-processed)', context).each(function(){
        Drupal.thouare2011.agendaBlockDate(jQuery(this));
      });
    }
  };

})(jQuery);


;

