$("body").on("contextmenu", function(e) {
  return false;
});

   var today = new Date();
   var dd = today.getDate();
   var mm = today.getMonth()+1; //January is 0!
   var yyyy = today.getFullYear();
   if(dd<10) {
     dd='0'+dd
   }

   if(mm<10) {
     mm='0'+mm
   }

   today = dd+'/'+mm+'/'+yyyy;
   document.getElementById("date").innerHTML = today;
   var myVar=setInterval(function(){myTimer()},1000);

   function myTimer() {
       var d = new Date();
       document.getElementById("hour").innerHTML = d.toLocaleTimeString();
   }

   var date = new Date();
   var options = {weekday: "long", year: "numeric", month: "long", day: "2-digit"};
   document.getElementById("dateFull").innerHTML = date.toLocaleDateString("fr-FR", options)

   window.onload = function() {
    $("#iframeCDWALL").ready(function() {
        var head = $("#iframeCDWALL").contents().find("head");
        head.append(
          '<style>body { scale: 0.73; } .all-wall { top: 0; left: -185px; position: absolute; }</style>');
    });
   }


function sendVolValue1() {
  var x = document.getElementById("slider1").value;
  var audio1 = document.getElementById("iframeCDWALL").contentWindow.document.getElementById("audioVol1");
  audio1.innerHTML = x;
  $(audio1).click();
  var display1 = document.getElementById("display1");
  display1.innerHTML = x+'%';
}

function sendVolValue2() {
  var x = document.getElementById("slider2").value;
  var audio2 = document.getElementById("iframeCDWALL").contentWindow.document.getElementById("audioVol2");
  audio2.innerHTML = x;
  $(audio2).click();
  var display2 = document.getElementById("display2");
  display2.innerHTML = x+'%';
}

function sendVolValue3() {
  var x = document.getElementById("slider3").value;
  var audio3 = document.getElementById("iframeCDWALL").contentWindow.document.getElementById("audioVol3");
  audio3.innerHTML = x;
  $(audio3).click();
  var display3 = document.getElementById("display3");
  display3.innerHTML = x+'%';
}

function sendVolValue4() {
  var x = document.getElementById("slider4").value;
  var audio4 = document.getElementById("iframeCDWALL").contentWindow.document.getElementById("audioVol4");
  audio4.innerHTML = x;
  $(audio4).click();
  var display4 = document.getElementById("display4");
  display4.innerHTML = x+'%';
}


function onoffCD1() {
  var iframe = document.getElementById("iframeCDWALL");
  var playpause1 = iframe.contentWindow.document.getElementById("playStopWall1");
  $(playpause1).click();
  var onoffBtn1 = document.getElementById('onoffBtn1').textContent;
  if (onoffBtn1 === "OFF") {
    $('#onoffBtn1').text('ON');
    $('#onoffBtn1').css({"backgroundColor" : "#FF0000"});
  }else{
    $('#onoffBtn1').text('OFF');
    $('#onoffBtn1').css({"backgroundColor" : "#2E79BD"});
  }
}

function end1() {
  $('#onoffBtn1').text('OFF');
  $('#onoffBtn1').css({"backgroundColor" : "#2E79BD"});
}

function onoffCD2() {
  var iframe = document.getElementById("iframeCDWALL");
  var playpause2 = iframe.contentWindow.document.getElementById("playStopWall2");
  $(playpause2).click();
  var onoffBtn2 = document.getElementById('onoffBtn2').textContent;
  if (onoffBtn2 === "OFF") {
    $('#onoffBtn2').text('ON');
    $('#onoffBtn2').css({"backgroundColor" : "#FF0000"});
  }else{
    $('#onoffBtn2').text('OFF');
    $('#onoffBtn2').css({"backgroundColor" : "#2E79BD"});
  }
}

function end2() {
  $('#onoffBtn2').text('OFF');
  $('#onoffBtn2').css({"backgroundColor" : "#2E79BD"});
}

function onoffCD3() {
  var iframe = document.getElementById("iframeCDWALL");
  var playpause3 = iframe.contentWindow.document.getElementById("playStopWall3");
  $(playpause3).click();
  var onoffBtn3 = document.getElementById('onoffBtn3').textContent;
  if (onoffBtn3 === "OFF") {
    $('#onoffBtn3').text('ON');
    $('#onoffBtn3').css({"backgroundColor" : "#FF0000"});
  }else{
    $('#onoffBtn3').text('OFF');
    $('#onoffBtn3').css({"backgroundColor" : "#2E79BD"});
  }
}

function end3() {
  $('#onoffBtn3').text('OFF');
  $('#onoffBtn3').css({"backgroundColor" : "#2E79BD"});
}

function onoffCD4() {
  var iframe = document.getElementById("iframeCDWALL");
  var playpause4 = iframe.contentWindow.document.getElementById("playStopWall4");
  $(playpause4).click();
  var onoffBtn4 = document.getElementById('onoffBtn4').textContent;
  if (onoffBtn4 === "OFF") {
    $('#onoffBtn4').text('ON');
    $('#onoffBtn4').css({"backgroundColor" : "#FF0000"});
  }else{
    $('#onoffBtn4').text('OFF');
    $('#onoffBtn4').css({"backgroundColor" : "#2E79BD"});
  }
}

function end4() {
  $('#onoffBtn4').text('OFF');
  $('#onoffBtn4').css({"backgroundColor" : "#2E79BD"});
}

function mute1() {
   var iframe = document.getElementById("iframeCDWALL");
   var audio1 = iframe.contentWindow.document.getElementById("wallaudio1");
   var mute1 = document.getElementById('muteBtn1').textContent;
   if (mute1 === "MUTE") {
     $('#muteBtn1').text('UNMUTE');
     audio1.muted = true;
     document.getElementById("muteBtn1").style.boxShadow = "0px 0px 10px #fff";
   }else{
     $('#muteBtn1').text('MUTE');
     audio1.muted = false;
     document.getElementById("muteBtn1").style.boxShadow = "";
   }
}

function mute1() {
   var iframe = document.getElementById("iframeCDWALL");
   var audio1 = iframe.contentWindow.document.getElementById("wallaudio1");
   var mute1 = document.getElementById('muteBtn1').textContent;
   if (mute1 === "MUTE") {
     $('#muteBtn1').text('UNMUTE');
     audio1.muted = true;
     document.getElementById("muteBtn1").style.boxShadow = "0px 0px 10px #fff";
   }else{
     $('#muteBtn1').text('MUTE');
     audio1.muted = false;
     document.getElementById("muteBtn1").style.boxShadow = "";
   }
}

function mute2() {
   var iframe = document.getElementById("iframeCDWALL");
   var audio2 = iframe.contentWindow.document.getElementById("wallaudio2");
   var mute2 = document.getElementById('muteBtn2').textContent;
   if (mute2 === "MUTE") {
     $('#muteBtn2').text('UNMUTE');
     audio2.muted = true;
     document.getElementById("muteBtn2").style.boxShadow = "0px 0px 10px #fff";
   }else{
     $('#muteBtn2').text('MUTE');
     audio2.muted = false;
     document.getElementById("muteBtn2").style.boxShadow = "";
   }
}

function mute3() {
   var iframe = document.getElementById("iframeCDWALL");
   var audio3 = iframe.contentWindow.document.getElementById("wallaudio3");
   var mute3 = document.getElementById('muteBtn3').textContent;
   if (mute3 === "MUTE") {
     $('#muteBtn3').text('UNMUTE');
     audio3.muted = true;
     document.getElementById("muteBtn3").style.boxShadow = "0px 0px 10px #fff";
   }else{
     $('#muteBtn3').text('MUTE');
     audio3.muted = false;
     document.getElementById("muteBtn3").style.boxShadow = "";
   }
}

function mute4() {
   var iframe = document.getElementById("iframeCDWALL");
   var audio4 = iframe.contentWindow.document.getElementById("wallaudio4");
   var mute4 = document.getElementById('muteBtn4').textContent;
   if (mute4 === "MUTE") {
     $('#muteBtn4').text('UNMUTE');
     audio4.muted = true;
     document.getElementById("muteBtn4").style.boxShadow = "0px 0px 10px #fff";
   }else{
     $('#muteBtn4').text('MUTE');
     audio4.muted = false;
     document.getElementById("muteBtn4").style.boxShadow = "";
   }
}

window.addEventListener('load', (event) => {
  setTimeout(function(){
    $("head").append("<script src=\"js/audio-peek-settings.js\"></script>");
  }, 2000);
});
