$(document).ready(()=>{

 /*  window.addEventListener('touchmove', function(e){
  if(e.touches[0].clientX>$(window).width()){
    console.log(e.touches[0]);
    e.preventDefault();
  }
 
  },{ passive: false}); */

  $("body,html").css({
"width":$(window).width()+"px"
  });
 
/* End Zoom Disable */
var content = $(".disposContent");

$(".dispElem").click((e)=>{
$(content).hide();
 $(content[parseInt($(e.currentTarget).data("elem"))]).fadeIn(600);
  $(".dispElem").removeClass("activeElem");
  $(e.currentTarget).addClass("activeElem");
});
/* End menuDownload */

$("input[type='range']").rangeslider({

  polyfill: false,

  // Default CSS classes
  rangeClass: 'rangeslider',
  disabledClass: 'rangeslider--disabled',
  horizontalClass: 'rangeslider--horizontal',
  verticalClass: 'rangeslider--vertical',
  fillClass: 'rangeslider__fill',
  handleClass: 'rangeslider__handle',

  // Callback function
  onInit: function() {
    $(".ecran").removeClass("ecranActive");
    $("#ecran1").addClass("ecranActive");
    $("#ecran2").addClass("ecranActive");
  },

  // Callback function
  onSlide: function(position, value) {
    
    switch(value){
case 1:
  $(".ecran").removeClass("ecranActive");
  $("#ecran1").addClass("ecranActive");
;break;
case 2:
    $(".ecran").removeClass("ecranActive");
    $("#ecran1").addClass("ecranActive");
    $("#ecran2").addClass("ecranActive");
;break;
case 3:
    $(".ecran").removeClass("ecranActive");
    $("#ecran1").addClass("ecranActive");
    $("#ecran2").addClass("ecranActive");
    $("#ecran3").addClass("ecranActive");
   
;break;
case 4:
    $(".ecran").removeClass("ecranActive");
    $("#ecran1").addClass("ecranActive");
    $("#ecran2").addClass("ecranActive");
    $("#ecran3").addClass("ecranActive");
    $("#ecran4").addClass("ecranActive");
;break;


    }
  },

  // Callback function
  onSlideEnd: function(position, value) {}
});

/* End Slider */


$(".plusHeader").mouseover(()=>{

  
     $(".subMenuHeader").show();
setTimeout(()=>{
  $(".subMenuHeader").css({
    "transform":"scale(1)",
  });
},100);

});
$(".subMenuHeader").mouseleave(()=>{
  $(".subMenuHeader").fadeOut();
  

});
/* show/hide subMenu End */

$('#nav-icon1,#nav-icon2,#nav-icon3,#nav-icon4').click(function(){
  $(this).toggleClass('open');
});
/* End Click MenuButton */
var faqClose="46px";
var faqOpen="400px";
$(".FAQButtons").click((e)=>{
  
  $(".FAQButtons").css({
    "height":faqClose
  });
  $($(".FAQButtons").find(".circleFAQ")).css({
    "transform":"rotateZ(0deg)"
  });
  $($(".FAQButtons").find(".circleFAQ img")).attr("src","./Images/ArrowFAQ.svg");
  
    $($(".FAQButtons").find(".ParagFb")).css({
       "visibility":"hidden"
         });
   
  $(".FAQButtons").removeClass("faqButtonActive");
 

if($(e.currentTarget).css("height")==faqClose){
   $(e.currentTarget).css({
    "height":faqOpen
  });

  $($(e.currentTarget).find(".circleFAQ").get(0)).css({
    "transform":"rotateZ(180deg)"
  });
  
    $($(e.currentTarget).find(".ParagFb").get(0)).css({
"visibility":"visible"
  });
  $(e.currentTarget).addClass("faqButtonActive");
  $(e.currentTarget).find(".circleFAQ img").attr("src","./Images/ArrowFAQPurple.svg");
 
  
}else{

  $(e.currentTarget).css({
    "height":faqClose
  });
  $($(e.currentTarget).find(".circleFAQ").get(0)).css({
    "transform":"rotateZ(0deg)"
  });
  setTimeout(()=>{
 $($(e.currentTarget).find(".ParagFb").get(0)).css({
    "visibility":"hidden"
      });
  },200);
  $(e.currentTarget).removeClass("faqButtonActive");
  
}
 

});

/* End FAQ Buttons */

var translateOffset=97;
var translateVal=0;
var size1=[0,-191,-421,-482];
var size2=[0,-186,-365,-665];
var size3=[19,-193,-393,-551,-703,-878];
 var clicksCount1=0;

$("#skateNext").click(()=>{
 var docWidth=document.documentElement.clientWidth+17;
if(docWidth>768){
if(size1.length-1>clicksCount1){
  clicksCount1++;
$(".MenuSkate").css({
  "transform":"translateX("+(size1[clicksCount1])+"px)",
});

  }

}else if(docWidth<768 && docWidth>600 ){
  
if(size2.length-1>clicksCount1){
  clicksCount1++;
$(".MenuSkate").css({
  "transform":"translateX("+(size2[clicksCount1])+"px)",
});

  }


}else if(docWidth<600){
  if(size3.length-1>clicksCount1){
    clicksCount1++;
  $(".MenuSkate").css({
    "transform":"translateX("+(size3[clicksCount1])+"px)",
  });
  $(".dispElemMobile").css({
    "visibility":"hidden"
  });
  $($(".dispElemMobile").get(clicksCount1)).css({
    "visibility":"visible"
  });

    }
}
});
function updateSize(){
  $(".dispElemMobile").css({
    "visibility":"hidden"
  });
  $($(".dispElemMobile").get(clicksCount1)).css({
    "visibility":"visible"
  });
}
if(document.documentElement.clientWidth+17<600){
  updateSize();
}


/* Prev */
$("#skatePrev").click(()=>{

  let docWidth=document.documentElement.clientWidth+17;
if(docWidth>768){

if(clicksCount1>=1){
  console.log(clicksCount1);
  clicksCount1--;
$(".MenuSkate").css({
  "transform":"translateX("+(size1[clicksCount1])+"px)",
});

}

}else if(docWidth<768 && docWidth>600 ){
  
if(clicksCount1>=1){
  clicksCount1--;
$(".MenuSkate").css({
  "transform":"translateX("+(size2[clicksCount1])+"px)",
});

  }


}else if(docWidth<600){
  if(clicksCount1>=1){
    clicksCount1--;
  $(".MenuSkate").css({
    "transform":"translateX("+(size3[clicksCount1])+"px)",
  });
  
updateSize();

    }
}
});

$(window).resize(()=>{
  clicksCount1=0;
  
  if(document.documentElement.clientWidth+17<600){
    updateSize();
    $(".MenuSkate").css({
      "transform":"translateX(19px)",
    });
    }else if(document.documentElement.clientWidth+17>600){
    $(".dispElemMobile").css({
      "visibility":"visible"
    });
    $(".MenuSkate").css({
      "transform":"translateX(0px)",
    });
  }

  $("body").css({
    "width":$(window).width()+"px"
      });
});

/* End Slider Buttons */
var isHumb=false;
$("#humbButton").click(()=>{
if(!isHumb){
  $("#DropDownMenu").fadeIn();
  isHumb=!isHumb;
}else if(isHumb){
  $("#DropDownMenu").fadeOut();
  isHumb=!isHumb;
}
});
/* End Humb Button */
var isPlus=false;
$("#plusMobile").click(()=>{
  if(!isPlus){
    $("#subMenuHeaderMobile").fadeIn();
    isPlus=!isPlus;
  }else if(isPlus){
    $("#subMenuHeaderMobile").fadeOut();
    isPlus=!isPlus;
  }
  
});
/* Language */
/* var isLg=false;
$(".drapClick").click(()=>{
if(!isLg){
  $(".languageDrop").fadeIn();
  isLg=!isLg;
}else if(isLg){
  $(".languageDrop").fadeOut();
  isLg=!isLg;
}
}); */
$(".drapClick,.arrowMobile,.arrow").mouseover(()=>{
 
    $(".languageDrop").fadeIn();
  
  });
  $(".languageDrop").mouseleave(()=>{
 
   
  $(".languageDrop").fadeOut();
  });
  

$(".LangFr").click(()=>{
$(".drapClick").attr("src",$(".LangFr").attr("src"));
$(".languageDrop").fadeOut();
});

$(".LangEn").click(()=>{
  $(".drapClick").attr("src",$(".LangEn").attr("src"));
  $(".languageDrop").fadeOut();
});
$(".LangAr").click(()=>{
  $(".drapClick").attr("src",$(".LangAr").attr("src"));
  $(".languageDrop").fadeOut();
});

/* MultiDiv */
$($(".RightFeaImages")[0]).css("display","block")
$(".multiDevices").click((e)=>{
  
    $(".multiDevices").removeClass("multiDevicesOpen");
    $(".multiDevices").css({
      "height":"47px"
        });
        
  if(parseInt(($(e.currentTarget).css("height")).replace("px",""))<=47){
    $(e.currentTarget).addClass("multiDevicesOpen");
      $(e.currentTarget).css({
    "height":"171px"
          });
          console.log("bla ");
  }else{
    $(e.currentTarget).removeClass("multiDevicesOpen");
    $(e.currentTarget).css({
      "height":"47px"
        });
        console.log(parseInt(($(e.currentTarget).css("height")).replace("px","")));
       console.log("bla bla bla ");
  }
console.log($(e.currentTarget).data("rightfea"));

  console.log($($(".RightFeaImages")[parseInt($(e.currentTarget).data("rightfea"))]));
  $(".RightFeaImages").css("display","none");
  $($(".RightFeaImages")[parseInt($(e.currentTarget).data("rightfea"))]).css("display","block");

  
});

/* Tester Button */
var inp1Valide=false;
var inp2Valide=false;
var inp3Valide=false;
$("#testerButton").click(()=>{

  console.log($("#InputPrenom").val()=="");
  if($("#InputPrenom").val()==""){
    console.log($("#InputPrenom").text());
    $("#InputPrenom").css({
"border":"2px solid red"
    });
    inp1Valide=false;
  }else if($("#InputPrenom").val()!=""){
    $("#InputPrenom").css({
      "border":"2px solid #22d022"
          });
          inp1Valide=true;
  }
/* End Test Input1*/
if($("#InputEmail").val()==""){

  $("#InputEmail").css({
    "border":"2px solid red"
        });
        inp2Valide=false;
}else{
  if(/.+@.+\.+.{1,10}/gi.test($("#InputEmail").val())){
    $("#InputEmail").css({
      "border":"2px solid #22d022"
          });
          inp2Valide=true;
  }else{
    $("#InputEmail").css({
      "border":"2px solid red"
          });
    inp2Valide=false;
  }

}
/* End Test Input2*/
if($("#InputNum").val()==""){

  $("#InputNum").css({
    "border":"2px solid red"
        });
        inp3Valide=false;
}else{
  if(/^(06)([0-9]{8})/gi.test($("#InputNum").val())){
    $("#InputNum").css({
      "border":"2px solid #22d022"
          });
          inp3Valide=true;
  }else{
    $("#InputNum").css({
      "border":"2px solid red"
          });
    inp3Valide=false;
  }

}
/* End Test Input3*/
console.log(inp1Valide);
/* All Inputs Success */
if(inp1Valide && inp2Valide && inp3Valide){
console.log("Do Something !!");
}else{
  console.log("Inputs Error !!");
}
  
});

/* End Validation */

/* countUP */
var intervalCount=120;
let tamp=0;
let maxVal1;

function count(maxVal,index){
  var inter=setInterval(()=>{
    tamp+=60;
    /* console.log(tamp+"i ****"+index); */
    
    if(tamp>=maxVal){
      tamp=maxVal;
      clearInterval(inter);
    }
$($(".countTextH span")[index]).text(parseInt(tamp));
  },intervalCount);
}


var Counted=false;
 $(window).scroll((e)=>{
   if($(document).scrollTop()>3665 && !Counted){
    for(var i=0 ;i<4;i++){
      count(parseInt($($(".countTextH span")[i]).data("maxnumber")),i);
   }
   Counted=true;
   }
 })
/* End countUp */

var input = document.querySelector("#phone");
window.intlTelInput(input, {
  initialCountry:"ma",
  localizedCountries :{ 'ma': 'Morocco' },
  preferredCountries:["ma"]
  
});
  

/* End NbrCode */
var screenToggle=true;
$(".screenNumberButton").on("click",(e)=>{
  if(screenToggle==true){
   $($(e.currentTarget).children().get(3)).css("display","block");
   
    
  }else{
    $(".ScreenNumberMenu").css("display","none");
    
  }
 screenToggle=!screenToggle;
});

$(window).click((e)=>{
 if($(e.target).parents().get(1).id!="screenNumb"){
  $(".ScreenNumberMenu").css("display","none");
  screenToggle=true;
 }

});



$(".screenLi").click((e)=>{
  console.log($($($(e.currentTarget).get(0)).parent().get(0)).children().removeClass("ecranActive"));
  //$(".screenLi").removeClass("ecranActive");
 $($(e.currentTarget).get(0)).addClass("ecranActive");
  /* $($($(".screenLi").get(parseInt($(e.currentTarget).data("sc")))).get(0)).addClass("ecranActive"); */
 console.log($(e.currentTarget).find(":nth-child(2)").get(0).innerText);

 console.log($($($(e.currentTarget).parents().get(2)).find(":nth-child(2)").get(0)).text($(e.currentTarget).find(":nth-child(2)").get(0).innerText));
 /* console.log($(".screenNumberButton>h1").text($(e.currentTarget).find(":nth-child(2)").get(0).innerText)); */
 
});
/* end ready Jquery */
});