$(document).ready(function() {
	

	$('.select').mSelect(); // customisation des select
	$(".mSelect").hover(    // hover des select
	  function () {
		$(this).removeClass('no_hover');
		$(this).addClass('hover');
	  },
	  function () {
		$(this).removeClass('hover');
		$(this).addClass('no_hover');
	  }
	);
	$(".bouton").hover(    // hover des select
	  function () {
		$(this).removeClass('bouton_no_hover');
		$(this).addClass('bouton_hover');
	  },
	  function () {
		$(this).removeClass('bouton_hover');
		$(this).addClass('bouton_no_hover');
	  }
	);
	$(".mOption").hover(    // hover des options dans les select
	  function () {
		$(this).css('color','#bc92c2');
	  },
	  function () {
		$(this).css('color','#FFF'); 
	  }
	);
	// submit pour le bouton "rechercher"
	$('#rechercheBTN a').click(function() {
	  $('#form_recherche_home').submit();
	});
});
 $(function(){
	jQuery.fn.extend({ // fonction pour trouver position d'un element
   findPos : function() {
       obj = jQuery(this).get(0);
       var curleft = obj.offsetLeft || 0;
       var curtop = obj.offsetTop || 0;
       while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
       }
       return {x:curleft,y:curtop};
   }
});
	//CARROUSEL
	//on enleve le texte pour le référencement
	$(".carousel_home .texte_referencement").hide();
	//on lance le carrousel
	$(".carousel_home").carousel( { animSpeed: 1200,pagination: true } );
   var width_fenetre=document.documentElement.clientWidth;
   if(width_fenetre>1040){
		var pos_left = $('#top').findPos().x;
		width_fenetre=width_fenetre-pos_left+65;
	}else{width_fenetre=1150;}
	
   $('#container_carousel_home').css('width',width_fenetre+'px');
});
$(window).resize(function() {
	var width_fenetre=document.documentElement.clientWidth; 
	if(width_fenetre>1040){
		var pos_left = $('#top').findPos().x;
		width_fenetre=width_fenetre-pos_left+65;
	}else{width_fenetre=1150;}
   $('#container_carousel_home').css('width',width_fenetre+'px');
});	

