// Animations jquery du site lacanche  

$(document).ready(function() {
      $("#overlay").hide();
      
      $("#fermer_popup").click(function(){
        $('#message_ok').stop().fadeOut(500);
      });
      
     // ***************************************** //
     // ***** ANIMATION RECHERCHE PRODUIT ******* //
     // ***************************************** //

      
      $('.input').click(function(){
        if($(this).hasClass('input_off')){
          return false;
        }else{
          if($(this).hasClass('input_on')){
            $(this).removeClass('input_on');
          }else{
            $(this).addClass('input_on');
          }
        }
      });

      $('#container_form .left div').click(function(){
        if($(this).hasClass('input_off')){
          return false;
        }else{


          var selector = $("#nombrefoyer option:selected").attr('data-filter');
          $('#container_form .input_on').each(function(){
            selector +=  $(this).attr('data-filter');
          });
          
          $('#container_gamme').isotope({ filter: selector });
          
          return false;
        }
      });
      
      $("#nombrefoyer").change(function () {
        var selector = $("#nombrefoyer option:selected").attr('data-filter');
        $('#container_form .input_on').each(function(){
          selector +=  $(this).attr('data-filter');
        });

        $('#container_gamme').isotope({ filter: selector });

        return false;
      });

      $(function(){
        $('#container_gamme').isotope({
          itemSelector : '.resultat_rech'
        });
      });
      
      
      $('#container_form .compo').click(function(){
        if($(this).hasClass('input_off')){
          return false;
        }else{
          for(var i=1; i<6; i++){
            if( $(this).attr('id') != 'compo'+i ){
              inputOff('compo',i);
            }
          }
        }
      });

      $('#container_form .capa').click(function(){
        if($(this).hasClass('input_off')){
          return false;
        }else{
          for(var i=1; i<4; i++){
            if( $(this).attr('id') != 'capa'+i ){
              inputOff('capa',i);
            }
          }
        }
      });
      
      $('#container_form .option').click(function(){
        if($(this).hasClass('input_off')){
          return false;
        }else{

          switch ($(this).attr('id')){
            case 'option1':
              inputOff('option',3,7);
            break;
            case 'option3':
              inputOff('option',1,7);
            break;
            case 'option7':
              inputOff('option',1,3);
            break;
            case 'option2':
              inputOff('option',4,8);
            break;
            case 'option4':
              inputOff('option',2,8);
            break;
            case 'option8':
              inputOff('option',2,4);
            break;
            default :
              return false;
            break;
          }
          
        }
      });


      
     // ***************************************** //
     // ******* ANIMATION GAMME PRODUIT ********* //
     // ***************************************** //
     
      $('#caroussel .affichage_piano a').hover(function(){
        $(this).children('.piano_hover').stop().animate({opacity: '1'});
      },function(){
        if(!$(this).hasClass('current')){
          $(this).children('.piano_hover').stop().animate({opacity: '0'});
        }
      });
      

     // ***************************************** //
     // *********** CARROUSSEL PIANO ************ //
     // ***************************************** //

      var nbPiano = $('.affichage_piano').length;
      if( $('#container_piano .affichage_piano .current').length > 0 ){
        var currentPiano = $('#container_piano .affichage_piano .current').attr('id').match(/\d+/);
      }
      var finCarrousel = -211*(nbPiano-4);

      if(currentPiano > 3){
        position = -currentPiano*211;
        if(position < finCarrousel){
          position = finCarrousel;
          $("#arrow_next").fadeOut(1000);
        }
        $("#container_piano").stop().css("left", position);
      }else{
        position = 0;
        $("#arrow_prev").hide();
      }
      

      $("#caroussel #arrow_next").click(function(){
        position = position - 211;
        if(position < finCarrousel){
          position = finCarrousel;
        }
        if(position == finCarrousel){
          $("#arrow_next").fadeOut(1000);
        }else{
          $("#arrow_next").fadeIn(1000);
          $("#arrow_prev").fadeIn(1000);
        }
        $("#container_piano").stop().animate({"left" : position}, {duration:1500 ,easing:'easeOutQuart'});
      });
      
      $("#caroussel #arrow_prev").click(function(){
        position = position + 211;
        if(position > 0){
          position = 0;
        }
        if(position == 0){
          $("#arrow_prev").fadeOut(1000);
        }else{
          $("#arrow_prev").fadeIn(1000);
          $("#arrow_next").fadeIn(1000);
        }
        $("#container_piano").stop().animate({"left" : position}, {duration:1500 ,easing:'easeOutQuart'});
      });
     

      if($('.class-gamme #loading').length != 0){
        $(window).load(function () {
          $('#loading').stop().fadeOut();
          $('#image_produit_big img').delay(600).fadeIn();
        });
      }
     
     // ***************************************** //
     // ******** ANIMATION SUR LA HOME ********** //
     // ***************************************** //
     


      //if(navigator.platform == "iPhone" || navigator.platform == "iPad"){
      if(!FlashDetect.installed){
        $("#flash").hide();
        $("#html5").show();
        
        $('.wlby_sprite').each(function()
    		{ this.addEventListener('webkitAnimationIteration', function(evt) { wlby_loop_children(evt, this); return false; }, false, false) });
        $('.wlby_sprite, .wlby_graphic').each(function()
    		{ this.addEventListener('webkitAnimationStart', function(evt) { wlby_activate_children(evt, this); return false; }, false, false) });
        $('.wlby_fs').each(function()
    		{ this.addEventListener('webkitAnimationEnd', function(evt) { wlby_activate_sibling(evt, this); return false; }, false, false) });
      }


      
 
      
     // ***************************************** //
     // ******* VERIF FORMULAIRE CONTACT ******** //
     // ***************************************** //
     
      $("#form_infos_revendeur").bind('submit', function(){

        var erreur = false;
        
        if($('#provenance').attr("value") == "Revendeur"){
          var obligatoire = new Array("#id1","#id2","#id3","#id5","#id6","#id7");
        }else{
          var obligatoire = new Array("#id1","#id2","#id3","#id5","#id6","#id7","#id11");
        }
        
        if ( !checkEmail( $(obligatoire[0]).attr("value") ) ) {
          $(obligatoire[0]).addClass('erreur');
          erreur = true;
        }else{
          $(obligatoire[0]).removeClass('erreur');
        }
          
        for (i=1; i < obligatoire.length; i++) {
          if ( $(obligatoire[i]).attr("value").length == 0 ) {
            $(obligatoire[i]).addClass('erreur');
            erreur = true;
          }else{
            $(obligatoire[i]).removeClass('erreur');
          }
        }
        
        if(erreur){
      		$('#champs_non_remplis').show();
      		return false;
      	} else {
      		$('#champs_non_remplis').hide();
      		return true;
      	}

      });
      

     // ***************************************** //
     // ************* GALERIE IMAGES ************ //
     // ***************************************** //
     
      if($('.class-galerie #galerie').length != 0){
        $(window).load(function () {
          $('#loading').stop().fadeOut();
          $('#galerie').stop().fadeIn();
        });
        $(function(){
          $('#galerie').isotope({
            itemSelector: '.image'
          });
        });
      }
      
      if($('.content-view-line #galerie').length != 0){
        $('#galerie').show();
      }
     
      
      
      $('#galerie .image').children('img').stop().animate({width: '250',height: '187'},50);
      
      $('#galerie .image').hover(function(){
        $(this).children('img').stop().animate({left: '-25px',top: '-25px',width: '300',height: '225'},400);
        $(this).children('.image_opacity').stop().animate({opacity: '0'},800);
      },function(){
        $(this).children('img').stop().animate({left: '0%',top: '0%',width: '250',height: '187'},700);
        $(this).children('.image_opacity').stop().animate({opacity: '0.55'},800);
      });
      
      /*
      $('#galerie .image').click(function(){
        $('#overlay').stop().animate({
                opacity: 0.8,
                height: 'toggle'
            });
      });
      */

     
     // ***************************************** //
     // ******** HOVER RUBRIQUE PRODUITS ******** //
     // ***************************************** //
     
      $('.rubrique').hover(function(){
        var rub_hover = $(this).attr('id');
        for(var i=1; i<5; i++){
          if( rub_hover == "rub"+i ){
            $('#rub'+i+" .rubrique_titre").stop().animate({top: '-46px',paddingLeft:'0',paddingRight:'25px'});
            $('#rub'+i+" .rubrique_titre").addClass('on').removeClass('out');
          }else{
            $('#rub'+i+" .rubrique_opacity").stop().animate({opacity: '0.60'});
          }
        }
      },function(){
        var rub_hover = $(this).attr('id');
        for(var i=1; i<5; i++){
          if( rub_hover == "rub"+i ){
            $('#rub'+i+" .rubrique_titre").stop().animate({top: '0',paddingLeft:'15px',paddingRight:'0'});
            $('#rub'+i+" .rubrique_titre").addClass('out').removeClass('on');
          }else{
            $('#rub'+i+" .rubrique_opacity").stop().animate({opacity: '0'});
          }
        }
      });
     
     
     // ***************************************** //
     // ************** TRI RECETTE ************** //
     // ***************************************** //
     
      var $container = $('#recette_tri');
      var tabBt = new Array("Entree","Plat","Dessert");

      $('#boutons_nav_interne a').click(function(){
        var selector = $(this).attr('data-filter');
        $container.isotope({ filter: selector });
        
        for(i in tabBt){
          if( "."+tabBt[i] == selector){
            $( "#"+tabBt[i] ).addClass('current');
          }else{
            $( "#"+tabBt[i] ).removeClass('current');
          }
        }
        
        return false;
      });

      $(function(){
        $container.isotope({
          itemSelector : '.resultat_rech'
        });
      });
     
     
     
      $(".accordion").accordion({ autoHeight: false , active: false ,header: 'h4'});

      // Accordeon fiche product
     	$("#descriptif_produit #accordions").accordion({ autoHeight: false, active: 0 });
     	

     $(function() {
      		var stop = false;
      		$(".fourneau_face .data-droite #accordion").accordion({ header: 'h2', autoHeight: false });
      		$(".fourneau_top .data-droite #accordion2").accordion({ header: 'h2', autoHeight: false });
	     });
	
     
     
     // ***************************************** //
     // ************* CONFIGURATEUR ************* //
     // ***************************************** //
    
    // Si on est dans le configurateur, on peut lancer les scripts
    if($(".content-view-full div").hasClass("lacancheconfigurateur")){
  
          // loader du fourneau de face
          var loading_ff = $(".fourneau_face .loader_ff");
          var loading_options_ff = $(".fourneau_face .loader_options");
          
          var loading_ft = $(".fourneau_top .loader_ft");
          var loading_options_ft = $(".fourneau_top .loader_options");
          
          // Chargement du fourneau de face au début
          var tableauCharge_face = new Array($(".fourneau_face .attribute-image .ff_couleur").css("background-image"), $(".fourneau_face .attribute-image .ff_finition").css("background-image"));
          
          
          loadRenderBegin(tableauCharge_face, ".fourneau_face .attribute-image", ".fourneau_face .data-droite .options", loading_ff, loading_options_ff);
          
           // Chargement du fourneau top au début
          var tableauCharge_top = new Array($(".fourneau_top .attribute-image .ft_vide").css("background-image"));
          loadRenderBegin(tableauCharge_top, ".fourneau_top .attribute-image", ".fourneau_top .data-droite .options", loading_ft, loading_options_ft);
     
          $(".fourneau_face #nuancier_vignette img").click(function(){
               
                    chooseCurrent($(this), ".fourneau_face #nuancier_vignette", "img", 'ff_current');

                       
                    $(".fourneau_face #nuancier_title a span").text($(this).attr("alt"));
                    // changement de la couleur du background image
                    var background_tmp = $(".fourneau_face .attribute-image .ff_couleur").css("background-image").split(".jpg");
                    background_tmp = background_tmp[0].split("/");
                    background_tmp[11] = $(this).attr("id");
                    
                    var newbackground = background_tmp.join("/")+'.jpg")';
                    
                    loadRender(newbackground, ".fourneau_face .attribute-image", '.fourneau_face .attribute-image .ff_couleur', loading_ff, background_tmp[11]);
        
          });
              
              
          $(".fourneau_face #finition_vignette img").click(function(){
                 
              $(".fourneau_face #finition_title a span").text($(this).attr("alt"));
              chooseCurrent($(this), ".fourneau_face #finition_vignette", "img", 'ff_current');
              // changement de la couleur du background image
              var background_tmp = $(".fourneau_face .attribute-image .ff_finition").css("background-image").split(".png");
              background_tmp = background_tmp[0].split("/");
              background_tmp[11] = $(this).attr("id");
              var newbackground = background_tmp.join("/")+'.png")';
              
              loadRender(newbackground, ".fourneau_face .attribute-image", ".fourneau_face .attribute-image .ff_finition", loading_ff, background_tmp[11]);
            
            
          });
          
          
          $(".fourneau_top #table_centrale_vignette img").click(function(){
             clearOptions(); 
             chooseCurrent($(this), ".fourneau_top #table_centrale_vignette", ".option-list img", 'ft_current');
             $(".fourneau_top #table_centrale_title a span").text($(this).attr("alt"));
               
              var background_tmp = $(".fourneau_top .attribute-image .ft_table").css("background-image").split(".png");
              background_tmp = background_tmp[0].split("/");
              background_tmp[10] = $(this).attr("id");
              var newbackground = background_tmp.join("/")+'.png")';
             
              loadRender(newbackground, ".fourneau_top .attribute-image", ".fourneau_top .attribute-image .ft_table", loading_ft, background_tmp[10]);
            
          });
          
         $(".fourneau_top #option_gauche_vignette img").click(function(){
         
              chooseCurrent($(this), ".fourneau_top #option_gauche_vignette", ".option-list img", 'ft_current');
             $(".fourneau_top #option_gauche_title a span").text($(this).attr("alt"));
             
              var background_tmp = $(".fourneau_top .attribute-image .ft_optgauche").css("background-image").split(".png");
              background_tmp = background_tmp[0].split("/");
              background_tmp[10] = $(this).attr("id");
              var newbackground = background_tmp.join("/")+'.png")';
              
              loadRender(newbackground, ".fourneau_top .attribute-image", ".fourneau_top .attribute-image .ft_optgauche", loading_ft, background_tmp[10]);
            
          });
          $(".fourneau_top #option_droite_vignette img").click(function(){
              
              chooseCurrent($(this), ".fourneau_top #option_droite_vignette ", "img", 'ft_current');
               $(".fourneau_top #option_droite_title a span").text($(this).attr("alt"));
             
              var background_tmp = $(".fourneau_top .attribute-image .ft_optdroite").css("background-image").split(".png");
              background_tmp = background_tmp[0].split("/");
              background_tmp[10] = $(this).attr("id");
              var newbackground = background_tmp.join("/")+'.png")';
              
              loadRender(newbackground, ".fourneau_top .attribute-image", ".fourneau_top .attribute-image .ft_optdroite", loading_ft, background_tmp[10]);
            
          });
    } // fin code configurateur
   


});


// Détermine la taille (hauteur et largeur de la fenêtre)
function StageSize(type) 
{
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
  }
  if(type == "width"){
    	return myWidth;
  }else{
    	return myHeight;
  }
  
}
// Détermine la taille (hauteur et largeur de la fenêtre)
function StageSizeOverlay(type) 
{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = $("body").width();
		myHeight = $("body").height();
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	if(type == "width"){
		return myWidth;
	}else{
		return myHeight;
	}
}
// lorsqu'on redimensionne la fenêtre, on centre l'élément sur la page  
$(window).resize(function() {
  $("#overlay").width(StageSizeOverlay("width"));
  $("#overlay").height(StageSizeOverlay("height"));
  CenterElement($(".accessoire_popup"));
});

// Détermine la taille (hauteur et largeur de la fenêtre)
function CenterElement(element) 
{ 
      posXElement =  (StageSize("width") - element.width()) /2;
      posYElement =  (StageSize("height") - element.height()) /2;
      element.css("top", posYElement).css("left", posXElement)
}

function openpopup(type, num)
{      
     switch (type)
	 {
          case "accessoires":
	          $(document).ready(function(){
	            // on redimensionne
	            $("#overlay").width(StageSizeOverlay("width"));
	            $("#overlay").height(StageSizeOverlay("height"));
	            $('#overlay').stop().fadeTo('slow','0.9').animate({
	            }, 500, function() {
	                // on centre l'élément sur la page
	                CenterElement($(".accessoire_popup"));
	                // on le fait apparaitre
	                $(".accessoire_popup").fadeTo(400, 1, function() {
	                    $("#access_"+num).show();
	                    $("#access_"+num).animate({opacity: '0.9'});
	                });
	                $(".close").bind("click", function(){
	                    $(".accessoire_popup").fadeOut("fast", function(){
	                        $("#overlay").fadeOut();
	                        $("#access_"+num).animate({opacity: '0'});
	                        $("#access_"+num).hide();
	                    });
	                });
	                $("#overlay").bind("click", function(){
	                    $(".accessoire_popup").fadeOut("fast", function(){
	                        $("#overlay").fadeOut();
	                        $("#access_"+num).animate({opacity: '0'});
	                        $("#access_"+num).hide();
	                    });
	                });
	          });          
	        });
	        break;
        default:
             alert("erreur !");
        	break;
     }
return false;
}

// Choix de l'élément current.
function chooseCurrent(this_current, class_parent, type_object, class_current)
{
	$(class_parent).children().each(function(){
		var kid = $(this);
		if(kid.attr("id") == $(this_current).attr("id")){
			kid.addClass(class_current);
		}else{
			kid.removeClass(class_current);
		}
	});
}

// Chargement du rendu au démarrage
function loadRenderBegin(tab, rendu, options, loader, loader_options) 
{
	var charge = 0;
	for(i=0;i<tab.length;i++){
		var b = tab[i].split('"').join('');
		var c = b.split(')');
		var d = c[0].split('url(');
		var url = d[1];
		$(window).load(function () {
			if(charge == tab.length -1){
				loader.hide();
				loader_options.hide();
				$(options).fadeIn("fast");
				$(rendu).fadeIn("fast");
			}else{ 
				charge++;
			}
			}).attr({ "src": '"'+url+'"' });
	}
}

// Chargement du rendu lorsqu'on change d'éléments sur le piano
function loadRender(a, rendu, classchange, loader, cond ) 
{
	// récupération de l'url du background à partir de l'élément que l'ont viens de cliquer
	var b = a.split('"').join('');
	var c = b.split(')');
	var d = c[0].split('url(');
	var url = d[1];
	var htmlStr = $(this).html();
	// on arrête les actions récursives sur le loader
	$(loader).stop();
	// si on change la table, on regarde si il y a des cas particuliers.
	if(classchange == ".fourneau_top .attribute-image .ft_table"){
		CasParticulier(classchange, cond);
		// on clange les classes.
		$(".fourneau_top #accessoires_vignette").children().each(function(){
			var kid = $(this);
			var kid_split =  kid.attr('class').split("_");
			if(kid_split[1] == cond){
				$(".fourneau_top #accessoires_vignette .access_"+cond).show();
			}else{
				$(".fourneau_top #accessoires_vignette .access_"+kid_split[1]).hide();
			}
		});
	}
	if(classchange == ".fourneau_face .attribute-image .ff_finition"){ 
		// Si on clange les finitions, on ne met pas de loader, on change de live.
		$(classchange).css('background-image','url("'+ url +'")');
		$(loader).hide();  
	}else{
		// Sinon on affiche le loader et on change le background.
		$(rendu).fadeOut( 'slow', function(){
			$(loader).fadeIn("fast");	
			$(classchange).css('background-image','url("'+ url +'")').fadeIn(200, function(){ 
				$(rendu).fadeIn("fast");
				$(loader).hide();
			});
		});
	}
}

// Nettoie les options lorsqu'on change de table
function clearOptions()
{
	// on efface le texte à coté des options à gauche et à droite
	$("#option_gauche_title a span").fadeOut("fast", function(){
	 $("#option_gauche_title a span").html(" ");
	 $("#option_gauche_title a span").show();
	});
	$("#option_droite_title a span").fadeOut("fast", function(){
	 $("#option_droite_title a span").html(" ");
	 $("#option_droite_title a span").show();
	});
	
	// on rends invisible les images sur le piano central et on enlève la classe à gauche et à droite
	$(".fourneau_top .attribute-image .ft_optgauche").fadeOut("slow", function(){
		$(".fourneau_top .attribute-image .ft_optgauche").css('background-image','url("/var/lacanche/storage/configurateur/images/options/piano/default.png")');
		$(".data-droite #option_gauche_vignette").children().each(function(){
			var kid = $(this);
			if(kid.hasClass('ft_current')){
				kid.removeClass("ft_current");
			}
		});	
	});
	$(".fourneau_top .attribute-image .ft_optdroite").fadeOut("slow", function(){
		$(".fourneau_top .attribute-image .ft_optdroite").css('background-image','url("/var/lacanche/storage/configurateur/images/options/piano/default.png")');
		$(".data-droite #option_droite_vignette").children().each(function(){
			var kid = $(this);
			if(kid.hasClass('ft_current')){
				kid.removeClass("ft_current");	
			}
		});	
	});
}

// Chargement des cas particuliers en fonction du piano
function CasParticulier(classChange, cond)
{
	switch ($(".lacancheconfigurateur").attr("id"))
	{
		case "config-chassagne": 
			tradition_radiant_induction(cond, "both"); 
			break;
		case "config-chambertin": 
			tradition_radiant_induction(cond, "both"); 
			break;
		case "config-citeaux": 
			tradition_radiant_induction_citeaux(cond); 
			break;
		case "config-fontenay": 
			tradition_radiant_induction(cond, "gauche"); 
			break;
		case "config-saulieu": 
			tradition_radiant_induction(cond, "both"); 
			break;
		case "config-savigny": 
			tradition_radiant_induction(cond, "both"); 
			break;
		case "config-sully": 
			radiant_induction_vif(cond); 
			break;
	}
}
// *************************
// Tous les cas particuliers
// *************************
function tradition_radiant_induction_citeaux(cond)
{
 /*     if(cond == "classique" || cond == "tradition")
      {
          $(".option_gauche_vignette .2foyersradiants").hide();
          $(".option_gauche_vignette .2foyersinduction").hide();
          $(".option_gauche_vignette .friteuse").hide();
          $(".option_gauche_vignette .polycuiseur").hide();
			if(cond == "classique")
			{
			  $(".option_gauche_vignette .grillelectriqueapierredelave").hide();
			  $(".option_gauche_vignette .grillgaz").hide();
			}
      }
      else{
          $(".option_gauche_vignette .2foyersradiants").show();
          $(".option_gauche_vignette .2foyersinduction").show();
          $(".option_gauche_vignette .friteuse").hide();
          $(".option_gauche_vignette .polycuiseur").hide(); 
		  $(".option_gauche_vignette .grillelectriqueapierredelave").hide();
		  $(".option_gauche_vignette .grillgaz").hide();		  
      }
*/
		$(".option_gauche_vignette .friteuse").hide();
        $(".option_gauche_vignette .polycuiseur").hide(); 
		$(".option_gauche_vignette .grillelectriqueapierredelave").hide();
		$(".option_gauche_vignette .grillgaz").hide();		
		if(cond == "tradition")
			{
			  	$(".option_gauche_vignette .2foyersradiants").hide();
          		$(".option_gauche_vignette .2foyersinduction").hide();	
			}
		else
			{
          		$(".option_gauche_vignette .2foyersradiants").show();
          		$(".option_gauche_vignette .2foyersinduction").show();	  
      		}	
			
			
			
			
			
			
			      
}
function tradition_radiant_induction(cond, where){
	if(cond == "tradition"){
		switch (where)
		{
		    case "gauche":
		        $(".option_gauche_vignette .2foyersradiants").hide();
		        $(".option_gauche_vignette .2foyersinduction").hide();
		    	break;
		    case "droite":
		        $(".option_droite_vignette .2foyersradiants").hide();
		        $(".option_droite_vignette .2foyersinduction").hide();
		    	break;
		    case "both":
		        $(".option_gauche_vignette .2foyersradiants").hide();
		        $(".option_gauche_vignette .2foyersinduction").hide();
		        $(".option_droite_vignette .2foyersradiants").hide();
		        $(".option_droite_vignette .2foyersinduction").hide();
		    	break;
		}
	}else{
		$(".option_droite_vignette .2foyersradiants").show();
		$(".option_droite_vignette .2foyersinduction").show();
		$(".option_gauche_vignette .2foyersradiants").show();
		$(".option_gauche_vignette .2foyersinduction").show();
	}
}
function radiant_induction_vif(cond)
{
      switch  (cond)
	  {
        case "induction":
        case "radiant":
            $(".option_droite_vignette .2feuxvifsde4kw").hide();
            $(".option_droite_vignette .2feuxvifsde3kw").hide();
            $(".option_droite_vignette .1feuvifde5kw").hide();
            $(".option_gauche_vignette .2feuxvifsde4kw").hide();
            $(".option_gauche_vignette .2feuxvifsde3kw").hide();
            $(".option_gauche_vignette .1feuvifde5kw").hide();

            $(".option_gauche_vignette .2foyersradiants").show();
            $(".option_gauche_vignette .2foyersinduction").show();
            $(".option_gauche_vignette .planchaelectrique").show();
        	break;
        case "classique":
        case "tradition":
            $(".option_gauche_vignette .2foyersradiants").hide();
            $(".option_gauche_vignette .2foyersinduction").hide();
            $(".option_gauche_vignette .planchaelectrique").hide();
            $(".option_gauche_vignette .1feuvifde5kw").hide();
            
            $(".option_droite_vignette .2feuxvifsde4kw").show();
            $(".option_droite_vignette .2feuxvifsde3kw").show();
            $(".option_gauche_vignette .2feuxvifsde4kw").show();
            $(".option_gauche_vignette .2feuxvifsde3kw").show();
        	break;
        default:
            $(".option_droite_vignette .2feuxvifsde4kw").show();
            $(".option_droite_vignette .2feuxvifsde3kw").show();
            $(".option_droite_vignette .1feuvifde5kw").show();
            $(".option_gauche_vignette .2feuxvifsde4kw").show();
            $(".option_gauche_vignette .2feuxvifsde3kw").show();
            $(".option_gauche_vignette .1feuvifde5kw").show();
            $(".option_gauche_vignette .2foyersradiants").show();
            $(".option_gauche_vignette .2foyersinduction").show();
            $(".option_gauche_vignette .planchaelectrique").show();
        	break;
      }
}

// ***************************************** //
// ************* ANCRE ANIMEES ************* //
// ***************************************** //

var scrolling = function(){
  var speed = 3000;
  $('a[href^="#"]').bind('click',function(){
    var id = $(this).attr('href');
    if(id != "#page"){
      if(id == '#'){
        goTo('body');
      }else{
        goTo(id);
      }
    }
    return(false);
  });
  function goTo(ancre){
    jQuery('html,body').animate({scrollTop:jQuery(ancre).offset().top},speed,'easeOutQuint',function(){
      if(ancre != 'body'){
        window.location.hash = ancre;
      }else{
        window.location.hash = '#';
      }
      jQuery(ancre).attr('tabindex','-1');
      jQuery(ancre).focus();
      jQuery(ancre).removeAttr('tabindex');
    });
  }
};

$(function(){
	scrolling();
});




// fonction de vérification d'email
function checkEmail(email){
  var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  if (!filter.test(email)){
    return false;
  }else{
    return true;
  }
}


function wlby_calc_timeout(c) {
    var timeout = (new Date).getTime();
    while (c) {
        timeout += parseFloat(getComputedStyle(c)['-webkit-animation-duration']) * 1000;
        c.timeout = Math.round(timeout);
        c = c.nextElementSibling;
    }
}
var wlby_hide_children = function(self) {
    var c = self.firstElementChild;
    while (c) {
        c.style.display = 'none';
        c = c.nextElementSibling;
    }
}
var wlby_activate_sibling = function(evt, self) {
    if (evt.srcElement != self)
        return;
    if (self.style.display == 'none')
        return;
    if (!self.timeout)
        wlby_calc_timeout(self);
	self.style.display = 'none';
    var sibling = self.nextElementSibling;
    if (!sibling)
        return;
    while ((sibling.timeout < evt.timeStamp)&&sibling.nextElementSibling)
        sibling = sibling.nextElementSibling;
//    $('.wlby_fs', sibling).css('display', 'none');
//    var n = new Number((sibling.timeout - (new Date).getTime()) / 1000);
//    sibling.style.webkitAnimationDuration = n.toString() + 's';
    sibling.style.display = 'block';
};
var wlby_activate_children = function(evt, self) {
    if (evt.srcElement != self)
        return;
    wlby_hide_children(self);
    var c = self.firstElementChild;
	if(!c)
		return;
//    $('.wlby_fs', c).css('display', 'none');
    wlby_calc_timeout(c);
    c.style.display = 'block';
	c.style.webkitAnimationDelay = '';
}
var wlby_loop_children = function(evt, self) {
    if (evt.srcElement != self)
        return;
    wlby_activate_children(evt, self);
    var c = self.firstElementChild;
    if (!c)
        return;
    c.style.webkitAnimationDelay = '0s';
}


function inputOff(type,id1,id2) {
  if($('#container_form #'+type+id1).hasClass('input')){
    $('#container_form #'+type+id1).removeClass('input');
    $('#container_form #'+type+id1).addClass('input_off');
    if(id2 != ""){
      $('#container_form #'+type+id2).removeClass('input');
      $('#container_form #'+type+id2).addClass('input_off');
    }
  }else{
    $('#container_form #'+type+id1).removeClass('input_off');
    $('#container_form #'+type+id1).addClass('input');
    if(id2 != ""){
      $('#container_form #'+type+id2).removeClass('input_off');
      $('#container_form #'+type+id2).addClass('input');
    }
  }
  
  
}
