/* functions to facilitate lock down on objects */

var debugLocking = false;

if(commitTimer){	
	setInterval(function () { if(typeof actionsLMSCommit !="undefined" ){actionsLMSCommit()}}, 600000);
}

function adjustScreenNavButtons(){
	if(typeof(LMSAPI)!="undefined"){
		if(useAICCRules!=true && commitTimer!=true){
			actionsLMSCommit();
		}
		checkCourseCompletion();	
	}
}

//adjustScreenNavButtons()

/* 
	isPageComplete
	Function to check if the page/section is complete
	Has the audio and and interaction been completed
	Called when interactions/audio have completed
 */
var pageCompleted = null;

/* down button tap twice fix for iPad 2021 */
var tempDownBtnNum = 0;

function isPageComplete(n){
	/* ensure the first test question shows when in the test topic and on the test intro page */
	if((pageCompleted != n) || ((pageCompleted == n) && (n == document.testIntroSubsection) && ($("#sec_" + document.testIntroSubsection).css("display") == "block"))){
		if(document.audioComplete && document.intComplete){
			/* trickle button functionality 2020 */
			if(document.lockedArr[(n-1)] === 1 && !$('#sec_'+ Number(n)).next('.section').hasClass('breaker')){
				/* screen locked or screen shows trickle button regardless of locked/unlocked but will not show for the last page in a topic */
				/* unlock the trickle button but do not mark the page complete */
				/* down button tap twice fix for iPad 2021 */
				tempDownBtnNum = n;
				setTimeout(delayDownButton, 1500);
				document.audioComplete = false;
				document.intComplete = false;
				/* mark slider visited when slider is complete */
				markSliderVisited(n);
			}
			if((document.lockedArr[(n-1)] === 0) || (document.lockedArr[(n-1)] === 1 && $('#sec_'+ Number(n)).next('.section').hasClass('breaker'))){
				/* screen unlocked or screen locked and is the last page in a topic */
				/* there is no trickle button so mark the page complete */
				markSectionComplete(n);				
				pageCompleted = n;			
			}
		}
	}else{
		document.audioComplete = false; 
		document.intComplete = false;
	}	
}

/* down button tap twice fix for iPad 2021 */
function delayDownButton()
{
	$('#sec_'+ Number(tempDownBtnNum)+' .complete_arrow').addClass('unlocked');
	/* 2021 Accessibility Update */
	$('#sec_'+ Number(tempDownBtnNum)+' .complete_arrow').attr('title', localiseString('complete_arrow'));
	$('#sec_'+ Number(tempDownBtnNum)+' .complete_arrow').attr('alt', localiseString('complete_arrow'));
}

function downButton(){
/* trickle button functionality 2018 */
	for(var i=1; i<$('.section').length; i++){
		/* slider visited state functionality 2018 */
		/* hotspot visited state functionality 2018 */
		/* expando visited state functionality 2018 */
		if(document.lockedArr[i] === 1 && !$('.section').eq(i).next().hasClass('breaker')){
			$('#sec_'+(i+1)).find('.complete_arrow').show();
			/* trickle button functionality 2020 */
			if (((i + 1) > document.testIntroSubsection) && ((i + 1) < (document.testResultsSubsection + 1)))
			{
				/* test question */
				for (var j = 0; j < document.assessQuesDownArrowClicked.length; j++)
				{
					if (document.assessRandomQuesArr[j] == (i+1))
					{
						if (document.assessQuesDownArrowClicked[j] == 1)
						{	
							/* hide the trickle button if it had been clicked for this test questions in this session */
							$('#sec_'+(i+1)).find('.complete_arrow').hide();
						}
					}
				}
			}
			/* trickle button functionality 2018 */
			if (!document.courseLockedDown)
			{
				$('.complete_arrow').eq(i-1).addClass('unlocked');
				/* 2021 Accessibility Update */
				$('.complete_arrow').eq(i-1).attr('title', localiseString('complete_arrow'));
				$('.complete_arrow').eq(i-1).attr('alt', localiseString('complete_arrow'));
			}	
			if (document.trackingArr[i] == 1)
			{
				/* trickle button functionality 2020 */
				/* hide the trickle button if the page is complete */
				$('#sec_'+(i+1)).find('.complete_arrow').hide();
			}
			/* trickle button functionality 2020 */
			if (document.assessPassmark != 0)
			{
				/* if there is a test in the course */
				var testStartSec = $('.testStartSec').attr('id').split('_')[1];
				if (currentSec == (document.topicsCount - 1))
				{
					if (document.assessQuesDownArrowClicked.length != 0)
					{	
						if ((i > testStartSec) && (i < document.testIntroSubsection) && (document.pretestAttempted == 1) && !document.takingPretest)
						{	
							/* hide the trickle button and show the next page for content pages in between the post-test topic intro and test intro if at least one trickle button on a post-test question has been clicked in this session */
							$('#sec_'+(i+1)).find('.complete_arrow').hide();
							$('#sec_'+(i+1)).next().show();
						}
					}	
				}
			}	
		}
		if(document.lockedArr[i] === 2 && !$('.section').eq(i).next().hasClass('breaker')){
			$('.complete_arrow').eq(i-1).css('display', 'block');
			$('.complete_arrow').eq(i-1).addClass('unlocked');
			/* 2021 Accessibility Update */
			$('.complete_arrow').eq(i-1).attr('title', localiseString('complete_arrow'));
			$('.complete_arrow').eq(i-1).attr('alt', localiseString('complete_arrow'));
			if (document.trackingArr[i] == 1)
			{
				$('.complete_arrow').eq(i-1).addClass('visited');
				/* 2021 Accessibility Update */
				$('.complete_arrow').eq(i-1).attr('title', localiseString('complete_arrow'));
				$('.complete_arrow').eq(i-1).attr('alt', localiseString('complete_arrow'));
			}
		}		
		if(document.lockedArr[i] === 1){
			if (document.trackingArr[i] == 1)
			{
				markSliderVisited(i+1);
				markHotspotsVisited(i+1);				
				markExpandoVisited(i+1);
			}	
		}
		if((document.lockedArr[i] === 0) || (document.lockedArr[i] === 2)){
			markSliderVisited(i+1);
			markHotspotsVisited(i+1);				
			markExpandoVisited(i+1);
		}
	}
}

/* 
	markSectionComplete	
	Function to mark page as complete in the LMS
	And display the next section	
	Called from isPageComplete
*/
function markSectionComplete(n){
	//alert('markSectionComplete ' + n);
	if ((document.currentSection < document.testIntroSubsection) || (document.currentSection >= document.testResultsSubsection))
	{
		/* test out: if there is a pre-test in the course */
		if (document.pretestPresent == 1)
		{
			/* test out: if the pre-test is not being currently taken and it is not the post-test results then mark this page as complete */
			if (!document.takingPretest) {
				document.trackingArr[n - 1] = 1; /* to keep each section unlocked once completed */
			}
		}
		else {
			/* ensure to not track the post-test results page as visited to ensure down arrow shows properly 062122 */
			if (n != document.testResultsSubsection)
			{
				document.trackingArr[n - 1] = 1; /* to keep each section unlocked once completed */
			}	
		}	
		if(!isWeb){
			/* mobile devices so commit tracking data */
			recordPercentComplete(n, document.subsectionCount, false);
			courseWriteTimer(true);			
			/* applied to fix issue with progress not updating in LMS */
			/*if(error_tracking){
				actionsLMSCommit();
			}*/			
		}else{
			trackSectionComplete(n);
		}
	}
	document.audioComplete = false;
	document.intComplete = false;
	var currClassName = $('#sec_'+ n).attr("class");
	if ((currClassName.indexOf('testStart') != -1) && (currClassName.indexOf('testStartSec') == -1)) {
		/* test intro */
		var color1 = "bgColor1";
		var color2 = "bgColor2"
		if($('.testStart .background_stretch .background_stretch_bg').hasClass('bgColor1')){
			color1 = "bgColor2";
			color2 = "bgColor2"
		}else{
			color1 = "bgColor2";
			color2 = "bgColor2"
		}

		for (var i = 0; i < document.assessRandomQuesArr.length; i++) 
		{
			var secNum = document.assessRandomQuesArr[i];
			$("#testQues" + (i + 1)).replaceWith($("#sec_" + secNum));
			$("#sec_" + secNum + " .background_stretch .background_stretch_bg").removeClass("bgColor1");
			$("#sec_" + secNum + " .background_stretch .background_stretch_bg").removeClass("bgColor2");
			if ((i + 1)%2 == 0)
			{
				$("#sec_" + secNum + " .background_stretch .background_stretch_bg").addClass(color1);
			}
			else
			{
				$("#sec_" + secNum + " .background_stretch .background_stretch_bg").addClass(color2);
			}			
			$("#sec_" + secNum + " .testQuesLabel").html(localiseString('test_question') + " " + (i + 1) + " " + localiseString('test_of') + " " + document.assessTotalQues);
		}
		setTabIndex(); /* 20180501 Accessibility Reapply tab index when assessment is randomised */
		for (var k = (document.testIntroSubsection + 1); k < document.testResultsSubsection; k++)		
		{		
			if (!document.assessAttempted)
			{
				$("#sec_"+k).css("display","none");
			}	
		}
		var nextSection = document.assessRandomQuesArr[0];
		/* randomise assessment question options */
		if(document.assessOptRandomize){			
			$(".testQues:eq(0) .grid .container .optionHolder").not('.optionsNoRand').shuffleOptions('.qOption');
		}
		$('.testQues:eq(0)').show()
	}
	else if (currClassName.indexOf('testQues') != -1) {
		/* test question */
		/* ensure current test question number is not lost in fast scrolling */		
		var tempCurrQues = $("#sec_" + n + " .testQuesLabel").html().split(" ")[1];
		if (document.currentAssessQues != tempCurrQues) {
			document.currentAssessQues = tempCurrQues;
		}
		var nextSection = document.assessRandomQuesArr[document.currentAssessQues];
	}
	else if (currClassName.indexOf('testStartSec') == -1) {		
		if (((Number(n) + 1) != document.testIntroSubsection) || $('#sec_'+ document.assessRandomQuesArr[0]).css('display')==='none')
		{
			var nextSection = Number(n) + 1;		
		}		
	}
	var prevSection = $('#sec_'+ nextSection).prev('.section');
	if ((document.testIntroSubsection != null) & (nextSection == document.subsectionCount))
	{
		prevSection = $('#sec_'+ document.assessRandomQuesArr[document.assessRandomQuesArr.length - 2]);
	}
	if(prevSection.css('display')==='block'){
		/* updated unlock code to handle when screen is fullscreen and therefore scroll not working */
		var className = $('#sec_'+ nextSection).attr("class");
		if(className.indexOf('breaker') == -1){
			for(var i=nextSection; i<= document.lockedArr.length; i++){
				if(!$('#sec_'+ (i)).hasClass('breaker') || $('#sec_'+ (i)).hasClass('testResults') ){
					if(!$('#sec_'+ i).is('.testQues:eq(0)')){
						$('#sec_'+ i).css('display', 'block')
					}
				}
				if(document.lockedArr[i-1] == 0 && !$('#sec_'+ (i)).hasClass('breaker')){
					$('#sec_'+ (i)).css('display','block');
				}else{
					break;
				}
			}
			$('#sec_'+ nextSection +' .grid .h2_inner').css({ 
				opacity:1
			});			
			var nextElem = ('#sec_'+ nextSection +' .grid .h2_inner').split(".h2_inner");
			nextElem = nextElem[0] + ".grid_inner";
			$(nextElem).css({ 
				opacity:1
			});
			$('#sec_'+ nextSection +' .grid .h2_inner').next().css({ 
				opacity:1
			});
			checkBoxInView(nextSection)
		}
		/* Updated unlock code to handle when screen is fullscreen and therefore scroll not working */		
	}
	/* trickle button functionality 2020 */
	document.topic_complete.push(1)
	progress(n)
	unlockTopic(n);	
	if(isAndroidTablet || isAndroidPhone || isMacChrome){
			$('html,body').scrollTop(windowTop -1)
	}
	/* slider visited state functionality 2018 */	
	markSliderVisited(n);
	getSliderHeight() // slider height fix
	//20210318 desktop portrait fix
	portraitTestFix();
	
	
	if(document.hasBranches){
		if($('#sec_'+ n).hasClass("end_shared")){
			endSharedContent();
		}
		
		if($('#sec_'+ n).hasClass("end_branch")){
			endBranch(n);
		}
	}
	
	
}


/*

    resetCourse funciton
    Called when user fails assessment 
    and attempts match document.assessAttempts
    
    Funciton will reset users tracking data and lock down course and menu.

*/

function resetCourse(){
    
    document.menuLockedDown = true;
    document.courseLockedDown = true;
    document.assessAttempts = 0;
    
    
    for (var i = 0; i < document.trackingArr.length; i++){
		if(document.hasBranches){
			if(i == 1){
        		document.trackingArr[i] = 0;
			}else{
				document.trackingArr[i] = 0;	
			}
		}else{
			document.trackingArr[i] = 0;
		}
    }		
    
    //var sTopics = "";
	
	var sSecs = "";
    
    var sRecordedPages = "";
    var sPages = "";
    var i = 0;
    var sNewString = "";		
    sRecordedPages = jftrim(actionsLMSGetSuspendData());		

    document.build_menu_data = sRecordedPages
    /* check to see if suspend data has %_Data: */
    var re = /%_Data:([01]*)/im
    var res = re.exec(sRecordedPages)
    
    /*for(var j = 0; j!= document.topicsCount; j++){
        sTopics += "0";
    }*/
	
    
    for (i=0; i<document.subsectionCount; i++) {
        if(i == 0){
            sPages += "1";
        }else{
			if(document.hasBranches){
				if(i == 1){
					sPages += "0"
				}else{
					sPages += "0";
				}
			}else{
            	sPages += "0";
			}
        }
    }
    
    /* 20230804 tracking fixes: confidence and inline/kc questions only answered once, all questions have unique cmi.interactions IDs and resetting course after max assessment attempts */
    if (document.pretestPresent == 1)
	{
		if(document.trackBadges || document.hasBranches){/* 20200730 Badges */
			/* test out: store if the pre-test has been attempted and the topics that have been tested out of in suspend data */
			sRecordedPages = document.pretestAttempted + "|" + document.topicsPretestedOut + "%_Data:" + sPages + '%' + document.badgeData + '%' + document.userBranch + '%' + document.assessAttempts + '%' + document.allTimeAssessAttempts + '%' + document.userConfidence + '%' + document.trackQuests; /* 20230607 track inline questions in suspend_data to be able to display question summary */
		}
		else{
			/* test out: store if the pre-test has been attempted and the topics that have been tested out of in suspend data */
			sRecordedPages = document.pretestAttempted + "|" + document.topicsPretestedOut + "%_Data:" + sPages + '%' + document.assessAttempts + '%' + document.allTimeAssessAttempts + '%' + document.userConfidence + '%' + document.trackQuests; /* 20230607 track inline questions in suspend_data to be able to display question summary */
		}	
	}else {
		if(document.trackBadges || document.hasBranches){/* 20200730 Badges */
			sRecordedPages = "%_Data:" + sPages + "%" + document.badgeData + '%' + document.userBranch + '%' + document.assessAttempts + '%' + document.allTimeAssessAttempts + '%' + document.userConfidence + '%' + document.trackQuests; /* 20200730 Badges */ /* 20230607 track inline questions in suspend_data to be able to display question summary */
		}else{				
			sRecordedPages = "%_Data:" + sPages + '%' + document.assessAttempts + '%' + document.allTimeAssessAttempts + '%' + document.userConfidence + '%' + document.trackQuests; /* 20230607 track inline questions in suspend_data to be able to display question summary */
		}
	}
    
	if(lms_type == "scorm_2004"){
		actionsLMSSetValue('cmi.location', '');	
	}else{
		actionsLMSSetValue('cmi.core.lesson_location', '');	
	}
	
	int_tracking.int_lesson_location = "#sec_2"
	document.currentSection = 2;
	
	doBookMark(int_tracking.int_lesson_location)
    
    actionsLMSSetSuspendData(sRecordedPages);
	actionsLMSCommit();
    lockMenu();
    resetInteractions();
	/* ensure branch completion is reset when post-test is failed maximum times and course is reset 062122 */
	resetBranch();
	/* 20230804 tracking fixes: confidence and inline/kc questions only answered once, all questions have unique cmi.interactions IDs and resetting course after max assessment attempts */
	/* 20230607 disable inline questions that have already been answered when returning to course */
	disableQuests();
	$('.hotword').attr('data-hotword',0);
	$('.popup_pop').attr('data-link',0);
	$('.hotspot_btn').attr('data-hotspot',0);

	hidePage();
}

/*
    retakeCourse funciton
    Called on click of button on results page after user fails assessment 
    and attempts match document.assessAttempts
    
    Funciton will take user back to menu
    
*/

function retakeCourse(){
    var sec_saver = currentSec;
	currentSec = 0;
	startedTopic(currentSec);
	target = 'left_nav';
	op= 'right'		
	nav = true
	cloneOne(target, sec_saver, nav, op)
    retakeAssessment();
    
    $('.topic_nav_button').css('visibility','visible')

    //$('#home_nav').trigger('click');
    
}

/*
    lockMenu Function
    Lockdown all but first menu item
    
    //20190205 Updated to reset progress and lock icons
*/
function lockMenu(){
    for (var i = 0; i <= document.topicsCount+1; i++){	
        
        if(i == 0 || i == 1){
			
			if(document.hasBranches){
				
				if(i ==1){
					$('.select_bottom:eq('+i+') img').attr('src', 'images/custom_int/topic_launch.png');
					/* 20230804 tracking fixes: confidence and inline/kc questions only answered once, all questions have unique cmi.interactions IDs and resetting course after max assessment attempts */
					$('.select_bottom:eq('+i+') img').hover(function () {
						$(this).attr('src' ,'images/custom_int/topic_launch_rollover.png');
					});
					$('.select_bottom:eq('+i+') img').mouseout(function(){
						$(this).attr('src' ,'images/custom_int/topic_launch.png');
					});
				}
				
			}else{
				if(i == 0){
					$('.select_bottom:eq('+i+') img').attr('src', 'images/custom_int/topic_launch.png');
					/* 20230804 tracking fixes: confidence and inline/kc questions only answered once, all questions have unique cmi.interactions IDs and resetting course after max assessment attempts */
					$('.select_bottom:eq('+i+') img').hover(function () {
						$(this).attr('src' ,'images/custom_int/topic_launch_rollover.png');
					});
					$('.select_bottom:eq('+i+') img').mouseout(function(){
						$(this).attr('src' ,'images/custom_int/topic_launch.png');
					});
				}
				/* 20230804 tracking fixes: confidence and inline/kc questions only answered once, all questions have unique cmi.interactions IDs and resetting course after max assessment attempts */
				if(i == 1){
					$('.topic_select .overlay').eq(i).css('display', 'block');
            		$('.select_bottom:eq('+i+') img').attr('src', 'images/general_int/topic_locked.png');					
				}
			}
            
        }else{
            
			if(document.hasBranches){
				
				if(i != 1){
					$('.topic_select .overlay').eq(i).css('display', 'block');
            		$('.select_bottom:eq('+i+') img').attr('src', 'images/general_int/topic_locked.png');
				}
				
			}else{
			
            	$('.topic_select .overlay').eq(i).css('display', 'block');
            	$('.select_bottom:eq('+i+') img').attr('src', 'images/general_int/topic_locked.png');
            
			
			}

        }
        
        
    }
	
	
	$(".select_bottom").find('.topic_duration').each(function(index, element) {	

		if(document.hasBranches){
			if(index != 0){
		
				var txt = $(this).attr('data-duration')
				$(this).html(txt);
				$(this).removeClass("topic_duration_complete");
			}
		}else{
			var txt = $(this).attr('data-duration')
			$(this).html(txt);
			$(this).removeClass("topic_duration_complete");
		}
	});
	
	
	/*if(document.hasBranches){
	
		$(".select_bottom").find('.topic_duration').each(function(index, element) {	

			var txt = $(this).html();		
			$(this).attr('data-duration', $(this).html());
		});	
	}else{
		$(".select_bottom").find('.topic_duration').each(function(index, element) {	

			var txt = $(this).html();		
			$(this).attr('data-duration', $(this).html());
		});	
	}*/
	
	
    $('.progress').attr('alt', localiseString('topic_not_started'));
	$('.progress').attr('title', localiseString('topic_not_started'));
    
    
    $('.progress').removeClass('progress_started');
    $('.progress').removeClass('progress_complete');
  
}

/*
    resetInteractions Functions
    Will reset all interactions to their intial states, and reset unlocking data 
    so user has to complete them before moving forward

*/
function resetInteractions(){
    
    document.audioComplete = false; 
    document.intComplete = false;
    
    $(".section").attr('data-clicked',0); 
    $('.hotspot_btn').attr('data-hotspot',0);
    $('.slider_txt').attr('data',0);
    $('.expando_btn').attr('data',0);
    $('.submit_btn').attr('data',0);
	/* 091523 reset flip cards on retake of course */
	$('.flip_card').attr('data-flip',0);
    
    $('.complete_arrow').removeClass('unlocked');
    
    
    /* Slider */
    for(var i = 0; i!= currSlideArr.length; i++){
        currSlideArr[i] = undefined;
    }
    $('.slide_focus').removeClass('focus');
	/* ensure activities are reset after reaching limit of post-test attempts 060822 */
	$('.slide_left').removeClass('visited');
	$('.slide_left').removeClass('visited_disabled');
    $('.slide_left').addClass('disabled');	
    $('.slide_right').removeClass('disabled');
	$('.slide_right').removeClass('visited');
	$('.slide_right').removeClass('visited_disabled');
	/* 2021 Accessibility Update */
	$('.slide_left').attr('title', localiseString('slide_left_locked'));
	$('.slide_left').attr('alt', localiseString('slide_left_locked'));
	$('.slide_right').attr('title', localiseString('slide_right'));
	$('.slide_right').attr('alt', localiseString('slide_right'));    
    
    $('.sec_rest_wrapper').find('.section').each(function(index, element) {
        
        $(this).find('.slider_txt').each(function(index, element) {	

            $(this).css('display','none');

            if(index == 0){
                $(this).removeClass('slider_current');
                $(this).removeClass('slider_hidden');
                $(this).addClass('slider_current');
                $(this).css('display','block');
            }else{
                $(this).removeClass('slider_hidden');
                $(this).removeClass('slider_current');
                $(this).addClass('slider_hidden');
            }

        });
        $(this).find('.slide_focus').each(function(index, element) {	
            if(index == 0){
                $(this).addClass('focus')
            }
        });
    });
    
    
    /* Slider */
    
    
    /* Inline Questions */
    
    $('.section').find('.submit_btn').each(function(index, element) {
        
        var secNum = Number($(this).attr('id').split('_')[2]);
		/* 20230721 Updated to use data in config */
		var secId = "sec_"+secNum;

        if(secNum < document.testIntroSubsection){

			var tNum = inline_ques_dat[secId][0].topic_num;
            resetInQues(secNum,tNum);
        }
        /* 20230721 Updated to use data in config */
    });

    /* Inline Questions */
    
    
    /* Hospots */
    
    $('.hotspot_btn_label').addClass('hotspot_btn_label_cutoff');
    $('.hotspot_btn_label').removeClass('hotspot_visited');
    $('.hotspot_reveal').hide();
    $('.hotspot_btn_ind').hide();
    
	$('.section').find('.hotspot_btn').each(function(index, element) {
    
        var imgEle, img, ext
        $(this).find('img').each(function(index, element) {
            imgEle = $(this);
            img = $(this).attr('src').split('.')[0];
            ext = $(this).attr('src').split('.')[1];
        });

        if(img.indexOf('_visited') != -1){
            img = img.split('_visited')[0];
            $(imgEle).attr('src', img + '.' + ext);
        }
        
    });
    
    /* Hospots */
    
    
    /* Expando */
    lastExpID = "";
    /*if(document.useTransitions){
        $('.expando_reveal').children('.expando_reveal_content').hide();
    }*/
    $('.expando_reveal').hide();
	 $('.expando_reveal').children('.expando_reveal_content').show();
    $('.expando_btn').show();	
    $('.expando_btn').removeClass('expando_btn_visited');
    
    /* Expando */
    
    
    /* Video */
    $('.section').find('.video_player').each(function(index, element) {
    
        var vidID = $(this).attr('id')
        
        var video = document.getElementById(vidID);
        video.pause();
        video.currentTime = 0;
        video.load();
        
    });
	/* ensure activities are reset after reaching limit of post-test attempts 060822 */
	$('.section').find('.transcript_btn').each(function(index, element) {
		
		var secNum = Number($(this).attr('id').split('_')[2]);
		$("#transcript_" + secNum).hide();
		$("#transcript_btn_" + secNum).html(localiseString('transcript_btn'));
		/* 2021 Accessibility Update */
		$("#transcript_btn_" + secNum).attr('title',localiseString('transcript_btn'));
		$("#transcript_btn_" + secNum).attr('alt',localiseString('transcript_btn'));	
		/* 2021 Accessibility Update */					
		var btnTabIndex = $(this).attr('tabindex');
		var txtTabIndex = $("#transcript_" + secNum + " .transcript_text").attr('tabindex');			
		$(this).attr('tabindex', txtTabIndex);
		$("#transcript_" + secNum + " .transcript_text").attr('tabindex', btnTabIndex);
		
	}); 

	/* 091523 reset flip cards on retake of course */
	$('.section').find('.flip_content').each(function(index, element) {
		//20220418 FlipCard fix for JAWs
		$(this).parent().parent().removeClass("flipped");

		$(this).attr("aria-hidden", true);
		$(this).parent().parent().find(".flip_card_front").attr("aria-hidden", false);
		$(this).parent().parent().find(".flip_card_front").focus();
			
		//20220418 FlipCard fix for JAWs
		//$(this).parent().parent().find(".flip_card_back").find('.flip_content').each(function(index, element) {
			$(this).attr("aria-hidden", true);
			$(this).attr('tabindex',-1)
		//});

		// 20221025 Flipcard link fix
		$(this).find('a').each(function(index, element) {
			$(this).attr("aria-hidden", true);
			$(this).attr('tabindex',-1)
		});
			
		//20220418 FlipCard fix for JAWs
		var tabCnt = $(this).parent().parent().find(".flip_card_front").attr("data-tab");//$(this).attr("tabindex");
		$(this).attr("tabindex",-1);
		$(this).parent().parent().find(".flip_card_front").attr("tabindex", tabCnt);
	});
}