

$( document ).ready(function() {
	

	/*$(window).resize(function() {		
	
	});*/
	
	$('.tab_btn').click(function(e){
		
		
		$('.tab_reveal').hide();
		$('.tab_btn').css('cursor','pointer');
		var imgID = $(this).attr('id').split('btn_')[1];		
		var imgSec = imgID.split('_')[0];
		var iconItem = imgID.split('_')[1];
	
		var img_sec = '#sec_' + imgSec;
		var totalIcons = $('#sec_' + imgSec + ' .tab_btn').length;
		
		$('#tab_reveal_holder_'+imgSec).css("display","block");
		$('#tab_reveal_'+imgSec+'_'+iconItem).fadeIn(500, function(){
			if(isWeb){
				/* 20240130 accessibility 2024 */
				$(this).find('.tab_start').focus();
			}
		});
				
		if(Number($(this).attr('data-tab')) == 0){
			$(this).attr('data-tab',1);
		}
		
		/* v5 template */
		$('.tab_btn').removeClass("tab_selected");
		$(this).addClass("tab_selected");
		
		$(this).addClass("tab_visited");
		
		isTabDone(img_sec);		
		
		return false;		
	});	
	
	/* added keyboard accessibility */
	$('.tab_btn').keypress(function (e) {
		if (e.keyCode == 13 || e.keyCode == 32) {
			
			$(this).trigger('click');
		}		
	});	

	/* 20240130 accessibility 2024 */
	$('.tab_next_btn').click(function(e){
		var popID = Number($(this).parent().attr("id").split("_")[3]) + 1;
		var secID = $(this).parent().attr("id").split("_")[2];
		$("#tab_btn_"+secID+"_"+popID).focus();
	});
	
	/* 20240130 accessibility 2024 */
	$('.tab_next_btn').keypress(function (e) {
		if (e.keyCode == 13 || e.keyCode == 32) {
			$(this).trigger('click');
		}
	});
	
	setTimeout(function(){hotSpotAdjustBanner();},100); /* 20230601 Banner fix for banner position */
});




/* 
	isTabDone function 
	
	mark each hotspot as viewed when clicked
	called when hotspot clicked
*/

function isTabDone(img_sec){
	secNum = img_sec.split('_')[1]
	var hotspotDone = 0;
	var clicked = 0;
	$(img_sec).find('.tab_btn').each(function(index, element) {
				
		var data = Number($(this).attr('data-tab'));
		if(data === Number(1)){
			hotspotDone++;
			clicked = Number($('#sec_'+secNum).attr('data-clicked'));
			clicked +=1;
			$('#sec_'+secNum).attr('data-clicked',clicked);
			$(this).attr('data-tab','2');
		}
    });
					
	var totalClicked = Number($('#sec_'+secNum).attr('data-clicked'))
	var totalClicks = Number(document.clickArr[Number(secNum) - 1])
	if(totalClicked == totalClicks){	
		if(isAndroidTablet || isAndroidPhone || isMacChrome){
			document.intComplete = true;
			clearInterval(document.lockinterval)
			document.lockinterval = setInterval(function(){
				che = img_sec
				secNum = img_sec.split('_')[1]
				document.getnear(che);
				isPageComplete(secNum);
				if(($('#sec_'+(parseInt(secNum)+1)).is(':visible') || !$('#right_nav').hasClass('locked')) && document.courseLockedDown == true){
					clearInterval(document.lockinterval)
				} 
			},250)
		}else{
			document.intComplete = true;
			isPageComplete(secNum);
		}
		
		document.intComplete = true;
	
		isPageComplete(secNum);
		isHotSpotScreen = false;
	}
	
}


$('.tab_btn').attr('data-tab',0);