function mainmenu(){
	 $("#menu-principale li.first-level").hover(function(){
		  $(this).find('ul:first:hidden').css({
				'display': 'block'
		  });
		  $(this).addClass("hover");
	 },function(){
		  $(this).find('ul:first').css({
				'display': 'none'
		  });
		  $(this).removeClass("hover");
	 });
}

function evenement(){
	$('.fermer-bt').click(function(e){
	
		e.preventDefault();
		$(this).parent().hide();
	})	
}


$(document).ready(function(){
	//liste des boutiques home page
	$("#locator_country").change(function(){
		$("#location .custom-font").text($("option:selected", this).text());
		$("#store-locator a.google-map").attr("href" , $("option:selected", this).attr("adress"));
		Cufon.refresh();
	});
	
	
	var var_mute = 'false';

	 // gestion du menu
	mainmenu();
    //
	evenement();
	 // gestion des block clickable
	 $('.block-hover').hover(function(){
		  $(this).addClass('hover');
	 },function(){
		  $(this).removeClass('hover');
	 });

	/* $(".block-hover").click(function(){
		  window.location=$(this).find("a").attr("href");
		  return false;
	 });*/
	/* $(".rejoignez-nous button").click(function(){

		  //window.location= $(".block-hover").find("a").attr("href");
		  return false;
	 });*/

	 // gestion des value input
	 $('.inp-value').click(
		  function() {
				if (this.value == this.defaultValue) {
					 this.value = '';
				}
		  })
	 .blur(
		  function() {
				if (this.value == '') {
					 this.value = this.defaultValue;
				}
		  }
		  );

	 $('#btn-switch-lang').click(function () {
		  $(this).siblings('ul').slideToggle('fast');
	 });
	
	 $("#menu-newsletter a:eq(0), #menu-newsletter a:eq(1)").prettyPopin({
		  width: 357,
		  height: 324,
		  loader_path: '/images/loader.gif'
	 });
	
	 $("#btn_contact_presse").prettyPopin({
		  width: 500,
		  height: 450,
		  loader_path: '/images/loader.gif'
	 });
	
	 $(".pop-contact").prettyPopin({
		  width: 357,
		  height: 324,
		  loader_path: '/images/loader.gif'
	 });

	$(".galerie-formation li a").prettyPopin({
		  width: 711,
		  height: 449,
		  loader_path: '/images/loader.gif'
	 });
	 $(".article .popin").prettyPopin({
		  width: 711,
		  height: 449,
		  loader_path: '/images/loader.gif'
	 });
	 $(".popinNews").click(function(){
		
		 var newhref =  $('#form_newsletter_home')
			.attr("action")
			.replace(new RegExp("EMAIL"),
				encodeURIComponent($("#emailinput").val()).replace(/\./g, "+")	
			);
		 
		 $(this).attr("href", newhref );
	 });
	 $(".popinNews").prettyPopin({
		  width: 500,
		  height: 160,
		  loader_path: '/images/loader.gif'
	 });
	 
	 $("#form_newsletter_home").submit(function(e){
		 $(".popinNews").click();
		 e.preventDefault();return false;
	 });
	 
	 jQuery('.external_link').each(function() {
		  jQuery(this).attr('target','_blank');
	 } );

	 jQuery('.btn-son').click(function(){
		  mute();
		  return false;
	 })

	 function getFlash() {
		  var isIE = navigator.appName.indexOf("Microsoft") != -1;
		  return (isIE) ? window['conteneur-flash'] : document['conteneur-flash'];
	 }
	 function mute() {
		  var_mute = var_mute == 'false' ? 'true' : 'false';
		  getFlash().muteSound(var_mute);
	 }

});

