function ExecuteScript(strId)
{
  switch (strId)
  {
      case "5bUWNZursAo":
        Script1();
        break;
      case "6EsqX6WLmbh":
        Script2();
        break;
  }
}

function Script1()
{
  console.log("SL: Start");
console.log("SL: "+window.location.search);

const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);

var p=GetPlayer();
p.SetVar("courseURL",queryString);



}

function Script2()
{
  // Send a message to the parent page
function sendMessage(n_course,enrollment_id,n_lesson){
	//console.log("sendMessage");
	//courses/2464/watch?enrollment_id=21558&lesson_id=2638
	const message = ""+n_course+"/watch?enrollment_id="+enrollment_id+"\&lesson_id="+n_lesson;
	top.postMessage(message, "https://konvoe.com");
}


console.log("SL: send complete");

var p=GetPlayer();
var courseURL = p.GetVar("courseURL");
console.log("SL: "+courseURL");

const urlParams = new URLSearchParams(courseURL);

const enrollment_id = urlParams.get('enrollment_id');
const lesson_id = urlParams.get('lesson_id');
const n_course = urlParams.get('n_course');
const n_chapter = urlParams.get('n_chapter');
const n_lesson = urlParams.get('n_lesson');

const response = fetch('https://api.konvoe.com/completecourse', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ enrollment_id, lesson_id, is_completed:1 })
});


setTimeout(function() { sendMessage(n_course,enrollment_id,n_lesson) },200);




}

