/**
 * Gestion du min-height de la home pour bloquer le footer en bas de page
 */
(function ($) {
	$(document).ready(function(){
		if( !$('.front').length )return;

		function positionneFooter(){
			var minHeight = 190;
			if( $(window).height() > 605 )minHeight = $(window).height() - 284;
		
			// on redimensionne le min-height du centre
			$( '#main' ).css( { 'min-height': minHeight + 'px' , 'height': minHeight + 'px' } )
		}
		positionneFooter();
		
		$(window).resize(positionneFooter);
	});
})(jQuery);

/**
 * Ouverture automatique des liens externes
 * dans une nouvelle fenêtre avec ajout d'une classe pour chaque extension
 */
(function ($) {
	$(document).ready( function () {
		var links=document.links;
		var localhost=window.location.hostname;
		for(var i=0;i<links.length;++i)
		{
			var extension = links[i].href.substr(-3).toLowerCase();
			if((links[i].hostname!=localhost&&(links[i].protocol=='http:'||links[i].protocol=='https:'))|| (extension == 'pdf' ) )
			{
				links[i].onclick=function()
				{
					window.open(this.href);
					return false;
				};
			}
		}
	});
})(jQuery);

/**
 * texte dans l'input du form de recherche
 */
(function($) {
	$(document).ready(function() {
		var champ = 'edit-search-block-form--2';
		var _default = 'Rechercher';

		$('#' + champ).attr('autocomplete', 'off').val(_default);
		$('#' + champ).focus(function() {
			if (_default == $(this).val()) {
				$(this).val('');
			}
		});
		$('#' + champ).blur(function() {
			if ('' == $(this).val()) {
				$(this).val(_default);
			}
		});
	});
})(jQuery);

/**
 * Gestion des archives
 */
(function ($) {
	$(document).ready(function(){
		var selectorStr = '#sidebar-first #block-views-actus_liste-block_2 .view-id-actus_liste .view-content';
			
		var archivesBoxes = $(selectorStr);
		
		if( !archivesBoxes ) {
			return;
		}
		
		// Recherche du "header" (h3) du bloc sélectionné
		var select = false;
		$(selectorStr+' a[class="active"]').parents().each(function(){
			if( $(this).is('div.item-list') ) {
				select = $(this).find('h3');
				return false;
			}
		});
			
		archivesBoxes.accordion({ header:'h3', active:select, collapsible:true});
	});
})(jQuery);

/**
 * Activation des onglets 
 * - du bloc "infos pratiques"
 * - de la fiche expo
 */
;(function($) {
	$(document).ready(function(){
		if( $('#tabs-infos-pratiques').length )$( "#tabs-infos-pratiques" ).tabs();
		if( $('#tabs-fiche-exposition').length )$( "#tabs-fiche-exposition" ).tabs();
	});
})(jQuery);

/**
 * Gestion des paragraphes de la page "La Solution" 
 * Et de la classe "active" sur les items menu primary pour le hover de IE
 */
(function ($) {
	$(document).ready(function(){
		//$( ".node-type-page-solution .contentSolution .boxContent" ).accordion({ header: 'h2' });
		//$( ".view-listing-partenaires ul li.views-row-6,.view-listing-partenaires ul li.views-row-11,.view-listing-partenaires ul li.views-row-16" ).before('<li class="clearfix"></li>');
		
	});
})(jQuery);;

