/* functions to control vertical scrolling of content */

$( document ).ready(function() {	
	var che;
	var swap_vid = true
	var section_breaks = breakers;

	function animate_this_temp(elem){
		if(!isIE8){
			$(elem).css({ 
				/*opacity:1,	*/			
			});
			var nextElem = elem.split(".h1_inner");
			nextElem = nextElem[0] + ".grid_inner";
			$(nextElem).css({ 
				/*opacity:1*/
			});					
			/*$(elem).animate({ 
				opacity:1,				
				}, 500, function() {
				var nextElem = elem.split(".h1_inner");
				nextElem = nextElem[0] + ".grid_inner";
				$(nextElem).animate({ 
					opacity:1
					}, 500, function() {
				})
			})*/
		}
	}
	
	function animate_this_h2(elem){
		if(!isIE8){
			$(elem).css({ 
				/*opacity:1*/
			});
			var nextElem = elem.split(".h2_inner");
			nextElem = nextElem[0] + ".grid_inner";
			$(nextElem).css({ 
				/*opacity:1*/
			});
			$(elem).next().css({ 
				/*opacity:1*/
			});
			$(elem).animate({ 
				opacity:1
				}, 500, function() {
				var nextElem = elem.split(".h2_inner");
				nextElem = nextElem[0] + ".grid_inner";
				$(nextElem).animate({ 
					/*opacity:1*/
					}, 500, function() {
				})					
				$(elem).next().animate({ 
					/*opacity:1*/
					}, 500, function() {
				})					
			})		
		}
	}

	$('.squaredBox, .hotspot_btn, .hotword, .expando_btn, .slide_right, .slide_left, .squaredBoxTest').on("click", function () {
		che = '#'+$(this).closest('.section').attr('id')
		//alert('che ' + che);
		$('.bar_robot').removeClass('displayNone').addClass('displayBlock')
		get_nearest_breaker(che);
		if(isAndroidTablet || isAndroidPhone || isMacChrome){
			setTimeout(function(){
				$('html,body').scrollTop(windowTop -1)
			},50)
		}
	});
	
	document.getnear = function(che){get_nearest_breaker(che)}

	function get_nearest_breaker(che){	
		numeric_che = String(che.split('_')[1])
		if(numeric_che == '1'){
			$('.menu_items ul li.first').removeClass('active')
			$('.menu_items ul li.first .bord').removeAttr('style')
			//$('#temp_1 .v_txt').addClass('active')
		}else if(jQuery.inArray(numeric_che, section_breaks) !== -1){
			if(numeric_che>=Number(section_breaks[section_breaks.length-1])){
				$('.menu_items ul li.last').removeClass('active')
				$('.menu_items ul li.last .bord').removeAttr('style')
				//$('#temp_1 .v_txt').addClass('active')
			}else{
				menu_clicker('#goto_'+numeric_che)
			}			
		}else{
			for(vv=0;vv<=section_breaks.length-1;vv++){
				index_number = Number(section_breaks[vv])
				index_next = Number(section_breaks[vv+1])
				if(numeric_che>index_number && numeric_che<index_next){
					menu_clicker('#goto_'+index_number)
					break;
				}
			}
		}
						
		document.currentSection = Number(numeric_che);  /* set the current section value */		
		

		/* trickle button functionality 2018 */
		if ((document.currentSection >= document.testIntroSubsection) && (document.currentSection < (document.testResultsSubsection + 1)))
		{			
			for (var i = document.testIntroSubsection; i < (document.testResultsSubsection + 1); i++)
			{	
				if (i !== document.currentSection)
				{		
					/* test intro */
					if (i == document.testIntroSubsection)
					{
						/* trickle button functionality 2020 */
						/* hide trickle button on the test intro */
						$('#sec_'+i+' .complete_arrow').hide();
						/* 2021 Accessibility Update */
						setTabIndex();						
					}
					else
					{
						/* test questions which could be randomized */
						if ($('#submit_btn_' + i).css('display') == "none")
						{				
							/* trickle button functionality 2020 */
							/* hide trickle button on all test questions */
							$('#sec_'+i+' .complete_arrow').hide();							
							var quesIndex = 0;
							for (k = 0; k < document.assessRandomQuesArr.length; k++)
							{									
								if (document.assessRandomQuesArr[k] == i)
								{
									quesIndex = k;
								}
							}	
							if ($('#sec_'+(document.assessRandomQuesArr[quesIndex + 1])).css('display') == 'none')
							{
								/* show the trickle button on this test question if the next question is not displayed */
								$('#sec_'+i+' .complete_arrow').show();
							}	
						}						
					}
				}	
				else
				{
					/* test topic intro and content pages before the test intro */
					if (i == document.testIntroSubsection)
					{
						var testStartSecNum = $('.testStartSec').attr('id').split('sec_')[1];
						for (var j = testStartSecNum; j < document.testIntroSubsection; j++)
						{
							/* trickle button functionality 2020 */
							/* hide the trickle button for all completed test topic intro and content pages before the test intro */
							$('#sec_'+j+' .complete_arrow').hide();													
						}
					}
				}	
			}
		}
		else
		{
			for (var i = 3; i < (document.currentSection + 1); i++)			
			{
				/* content pages outside of the test */
				var prevSec = '#'+($('#sec_'+ i).prev('.section').attr('id'));			
				if (document.trackingArr[i-2] == "1")
				{
					/* trickle button functionality 2020 */
					/* hide the trickle button for all other completed content pages outside of the test */
					$(prevSec+' .complete_arrow').hide();
					/* slider visited state functionality 2018 */
					markSliderVisited(i-1);
					/* hotspot visited state functionality 2018 */
					markHotspotsVisited(i-1);
					/* expando visited state functionality 2018 */
					markExpandoVisited(i-1);
					if ($('.sec_rest_wrapper #sec_'+ i).next().hasClass('breaker') && document.trackingArr[i-1] == "1")
					{					
						/* slider visited state functionality 2018 */
						markSliderVisited(i);
						/* hotspot visited state functionality 2018 */	
						markHotspotsVisited(i);
						/* expando visited state functionality 2018 */
						markExpandoVisited(i);
					}	
				}	
			}
		}	
		
		//alert('document.currentSection = ' + document.currentSection);
		
		/* added global lockdown variable */
		if(document.courseLockedDown){
		//alert(document.currentSection);
			/* if the current section has audio play it, if not mark audio as complete */
			if(document.audioArr[document.currentSection - 1] == 1){
				playAudio(numeric_che); /* play audio */
				//$(".audioControlHolder").css("visibility","visible"); /* display audio controls */				
			}else{				
				if(audioSection == null){
					//$(".audioControlHolder").css("visibility","hidden"); /* hide audio controls */
					//document.audioComplete = true;
				}
				document.audioComplete = true;
			}
			
			/* if the current section doesn't have an interaction mark it as complete */
			if(document.intArr[document.currentSection - 1] == 0){
				document.intComplete = true;
			}else{
				//document.intComplete = false;
			}			
			/* if the page/section is not locked mark audio and interaction as complete */
			if(document.lockedArr[document.currentSection - 1] == 0){
				document.intComplete = true;
				document.audioComplete = true;
			}
		}else{			
			/* if in assessment, make sure page is locked */
			var className = $('#sec_'+document.currentSection).attr('class');			
			if(className.indexOf('testQues') != -1){
				document.intComplete = false;
				document.audioComplete = true;
			}else{
				document.intComplete = true;
				document.audioComplete = true;
			}				
			/* if the current section has audio play it, if not mark audio as complete */
			if(document.audioArr[document.currentSection - 1] == 1){
				playAudio(numeric_che); /* play audio */
				$(".audioControlHolder").css("visibility","visible"); /* display audio controls */
			}else{
				$(".audioControlHolder").css("visibility","hidden"); /* hide audio controls */
				document.audioComplete = true;
			}
		}
		
		if ($('#sec_'+document.currentSection).hasClass('testResults')){
			if(document.attestationPresent){
				/* ensure nav bar and down arrow on post-test results does not show and hide continuously when scrolling up and down 061022 */
				if ($('#sec_'+ document.subsectionCount).css('display') == 'none')
				{
					/* ensure on passed post-test results to show the attestation if already submitted or show the down arrow and hide the nav bar if not 062122 */
					if(document.assessPercentageScore>=document.assessPassmark)
					{	
						/* ensure to clear post-test attempts when test is passed or max attempts reached 062122 */
						document.assessAttempts = 0;
						if (document.trackingArr[document.subsectionCount - 2] == "1")
						{
							$('#sec_'+ document.subsectionCount).css('display', 'block');
							$('#sec_'+ document.testResultsSubsection + ' .complete_arrow').hide();
						}
						else 
						{
							$('.topic_nav_bar').css('display','none');
							$('#sec_'+ document.testResultsSubsection + ' .complete_arrow').show();
						}
					}
				}
				if(document.assessPercentageScore>=document.assessPassmark){
					document.intComplete = true;
					document.audioComplete = true;
				}else{
					
					//20220426 Added to reset the course tracking when user fails assessment 3 times, forcing user back through the course
					if(document.assessAttempts == document.maxAssessAttempts){
						var lesson_status = actionsLMSGetLessonStatus();
						if(lesson_status != "completed" && lesson_status != "passed"){
							resetCourse();
						}
						/* ensure to clear post-test attempts when test is passed or max attempts reached 062122 */
						else
						{
							document.assessAttempts = 0;
						}
					}
				}
			}
			
			
			
		}
		
		/* check to see if the slider can be unlocked */
		setTimeout(function(){
			isSliderDone();
		},250)
		
		/* page/section has already been viewed so mark as complete */
		if(document.trackingArr[document.currentSection - 1] == 1){
			document.intComplete = true;
			document.audioComplete = true;
		}
		isPageComplete(document.currentSection); /* check to see if section/page can be marked as complete */
	}

	/* applied fix to ensure content is displayed on saba cloud for iPad due to issue with scrollTop on iPad when frames are used */
	if(isWeb || isAndroidTablet || isAndroidPhone){
		$(window).scroll(function(){
			$('.v_menu').removeClass('chapters_buger_visible')
			clearTimeout($.data(this, 'scrollTimer'));
				$.data(this, 'scrollTimer', setTimeout(function() {
					if(che != 'undefined' && che != null){						
						/* test out: if there is a pre-test in the course */
						if (document.pretestPresent == 1)
						{
							/* test out: if not currently taking the pre-test bookmark the page */
							if (!document.takingPretest)
							{
								if($(che).hasClass('testQues') || $(che).hasClass('testResults')){
									if(typeof doBookMark !="undefined" ) {doBookMark('#'+$('.testStart').attr('id')) };
								}else if(che === '#topic_intro'){
								if(typeof doBookMark !="undefined" ) doBookMark('#topic_intro+'+currentSec) 
								}else{
									if(typeof doBookMark !="undefined" ) { doBookMark(che) };
								}
							}
							
							else
							{	
								
							}
							get_nearest_breaker(che);
						}	
						else 
						{
							if($(che).hasClass('testQues') || $(che).hasClass('testResults')){
								if(typeof doBookMark !="undefined" ) {doBookMark('#'+$('.testStart').attr('id')) };
							}else if(che === '#topic_intro'){
							if(typeof doBookMark !="undefined" ) doBookMark('#topic_intro+'+currentSec) 
							}else{
								if(typeof doBookMark !="undefined" ) { doBookMark(che) };
							}
							get_nearest_breaker(che);
						}
					}
				}, 200));
			winHeight = $(window).height()
			winHeightV = winHeight-64
			windowTop = Math.max($('body').scrollTop(), $('html').scrollTop());	
					
			$('.section').each(function (index) 
			{
				if($(this).is(":visible"))
				{					
					var container = $(this).find('.container').eq(0)
					
					if($(this).hasClass('breaker'))
					{
						if(document.topic_intro === "no")
						{
							if (windowTop > ($(container).position().top)-550){
								che = '#'+$(this).attr('id')
							}
							
						}else{
							if (windowTop > ($(container).position().top)+400){
								che = '#'+$(this).attr('id')
							}
						}
					}else{
						var distance = 250
						if(document.topic_intro === "no"){
							distance = -$(window).height()
						}else{
							distance = 250
						}
						if (windowTop > Math.round($(container).offset().top)+distance)
						{
							che = '#'+$(this).attr('id')
							//alert('che = ' + che);
							var nav_height = $(window).scrollTop() > $(document).height()-$(window).height() -500
							if(nav_height && $('.sec_rest_wrapper '+che).next().hasClass('breaker') ||  nav_height && $('.sec_rest_wrapper '+che).next().hasClass('topic_nav_bar') || nav_height && $('.sec_rest_wrapper '+che).hasClass('testResults'))
							{
								
								$('.topic_nav_bar').css('display','block');
								
								if (($('.sec_rest_wrapper '+che).hasClass('testResults'))){
									if(document.attestationPresent){										
										/* ensure nav bar and down arrow on post-test results does not show and hide continuously when scrolling up and down 061022 */
										if ($('#sec_'+ document.subsectionCount).css('display') == 'none')
										{	
											/* ensure on passed post-test results to show the attestation if already submitted or show the down arrow and hide the nav bar if not 062122 */
											if(document.assessPercentageScore>=document.assessPassmark)
											{	
												/* ensure to clear post-test attempts when test is passed or max attempts reached 062122 */	
												document.assessAttempts = 0;
												if (document.trackingArr[document.subsectionCount - 2] == "1")
												{
													$('#sec_'+ document.subsectionCount).css('display', 'block');
													$('#sec_'+ document.testResultsSubsection + ' .complete_arrow').hide();
												}
												else 
												{
													$('.topic_nav_bar').css('display','none');
													$('#sec_'+ document.testResultsSubsection + ' .complete_arrow').show();
												}
											}else{
												$('.topic_nav_bar').css('display','none'); /* 20220629 Fix to stop nav bar being visisble of results slide when there is an attestation */
											}
										}
									}
									
								}
								
								if (($('.sec_rest_wrapper '+che).hasClass('testResults')) && (!document.takingPretest))
								{
									$('.topic_nav_bar .branding').css('display','block');
								}
								else {
									$('.topic_nav_bar .branding').css('display','none');
								}	
							}else{
							}
						}				
					}
					animateContent(Number(che.split("_")[1]));
					/* 20231018 video and audio accessibility */
					$(che).find('.video_player').each(function(index, element) {
						$(this).attr('tabindex', $(this).attr('data-tab'));
					});
					$(che).find('.audio_player').each(function(index, element) {
						$(this).attr('tabindex', $(this).attr('data-tab'));
					});
				}
			});		
			$(che).data('visited', true)					
		}).scroll();
	}else{
		
		// iOS13 Fix 
		var winFrame;
		
		if(iOSVersion < 13){
			winFrame = window.top;
		}else{
			if(iOSApp){
				winFrame = window;
			}else{
				winFrame = window;
			}
		}
		// iOS13 Fix 
	
		$(winFrame).scroll(function(){				
			/* updated to match web version */
			hideBanner(); /* banner fix for iPad and iPhone */				
			$('.v_menu').removeClass('chapters_buger_visible')
			clearTimeout($.data(this, 'scrollTimer'));
				$.data(this, 'scrollTimer', setTimeout(function() {
					/* test out: if there is a pre-test in the course */
					if (document.pretestPresent == 1)
					{
						/* test out: if not currently taking the pre-test bookmark the page */
						if (!document.takingPretest)
						{
							if(che != 'undefined' && che != null){
								if($(che).hasClass('testQues') || $(che).hasClass('testResults')){
									if(typeof doBookMark !="undefined" ) {doBookMark('#'+$('.testStart').attr('id')) };
								}else if(che === '#topic_intro'){
										if(typeof doBookMark !="undefined" ) doBookMark('#topic_intro+'+currentSec) 
								}else{
									if(typeof doBookMark !="undefined" ) { doBookMark(che) };
								}
							}
						}
						get_nearest_breaker(che);
					}
					else
					{
						if(che != 'undefined' && che != null){
							if($(che).hasClass('testQues') || $(che).hasClass('testResults')){
								if(typeof doBookMark !="undefined" ) {doBookMark('#'+$('.testStart').attr('id')) };
							}else if(che === '#topic_intro'){
									if(typeof doBookMark !="undefined" ) doBookMark('#topic_intro+'+currentSec) 
							}else{
								if(typeof doBookMark !="undefined" ) { doBookMark(che) };
							}
						}	
						get_nearest_breaker(che);
					}
					showBanner(); /* banner fix for iPad and iPhone */						
				}, 200));					
			
			// iOS13 Fix 
			if(iOSVersion < 13){
				winHeight = $(window.top).height()
				winHeightV = 608;			
				windowTop = $(parent.parent.document).scrollTop();
			}else{
				
				winHeight = $(window).height()
				//winHeightV = winHeight-64
				winHeightV = winHeight
				windowTop = Math.max($('body').scrollTop(), $('html').scrollTop());	
			}
			// iOS13 Fix 
			
			$('.section').each(function (index) 
			{
				if($(this).is(":visible")){						
					var container = $(this).find('.container').eq(0)						
					if($(this).hasClass('breaker'))
					{
						if(document.topic_intro === "no")
						{
							if (windowTop > ($(this).position().top)-500){
								che = '#'+$(this).attr('id')
							}								
						}else{
							if (windowTop > ($(this).position().top)+400){
								che = '#'+$(this).attr('id')
							}
						}
					}else{
						var distance = 250
						if(document.topic_intro === "no"){
							if(iOSApp){
								//distance = -window.top.innerHeight;
								distance = -$(window.top).height()
							}else{
								distance = -$(window.top).height()
							}
						}else{
							distance = 250
						}
						//if (windowTop > ($(this).position().top)+distance){
						//if (windowTop > ($(this).position().top)+0)
						if (windowTop > Math.round($(container).offset().top)+distance){ /* iOS bookmark fix */
							
							che = '#'+$(this).attr('id')
							var nav_height = $(window).scrollTop() > (($(document).height()-$(window).height()) -500)
							
							if(nav_height && $('.sec_rest_wrapper '+che).next().hasClass('breaker') ||  nav_height && $('.sec_rest_wrapper '+che).next().hasClass('topic_nav_bar') || $('.sec_rest_wrapper '+che).hasClass('testResults'))	{
								console.log('shownav')
								$('.topic_nav_bar').css('display','block');
								
								if (($('.sec_rest_wrapper '+che).hasClass('testResults'))){
									if(document.attestationPresent){										
										/* ensure nav bar and down arrow on post-test results does not show and hide continuously when scrolling up and down 061022 */
										if ($('#sec_'+ document.subsectionCount).css('display') == 'none')
										{	
											/* ensure on passed post-test results to show the attestation if already submitted or show the down arrow and hide the nav bar if not 062122 */
											if(document.assessPercentageScore>=document.assessPassmark)
											{	
												/* ensure to clear post-test attempts when test is passed or max attempts reached 062122 */
												document.assessAttempts = 0;
												if (document.trackingArr[document.subsectionCount - 2] == "1")
												{
													$('#sec_'+ document.subsectionCount).css('display', 'block');
													$('#sec_'+ document.testResultsSubsection + ' .complete_arrow').hide();
												}
												else 
												{
													$('.topic_nav_bar').css('display','none');
													$('#sec_'+ document.testResultsSubsection + ' .complete_arrow').show();
												}
											}else{
												$('.topic_nav_bar').css('display','none'); /* 20220629 Fix to stop nav bar being visisble of results slide when there is an attestation */
											}
										}
									}
								}
								
								if (($('.sec_rest_wrapper '+che).hasClass('testResults')) && (!document.takingPretest))
								{
									$('.topic_nav_bar .branding').css('display','block');
								}
								else {
									$('.topic_nav_bar .branding').css('display','none');
								}	
							}else{								
							}
						}				
					}
					animateContent(Number(che.split("_")[1]));
				}
			});
			/* updated to match web version */
			$(che).data('visited', true)				
		}).scroll();		
	}
	
	function menu_clicker(clicked){		
		if($(clicked+' .bord').attr('style') != 'undefined' && $(clicked+' .bord').attr('style') != null && $(clicked+' .bord').attr('style') != 0){			
		}else{
		apply_active = clicked
		$('.v_menu .menu_items ul li').css('color','#ffffff')
		$('#vto_'+clicked.split('_')[1]).css('color','#ffffff')
		this_width = String($(clicked).width())
		minus_width = this_width.split('px')[0]
		new_width = -Math.abs(250-minus_width)
		active_width = $('.active .bord').width()
		$('.active .bord').animate({ 
			backgroundPosition:active_width
		}, 50, function() {
			$('.active .bord').removeAttr('style')
			$('.active').removeClass('active')
			$(apply_active).addClass('active')
			$(apply_active).children(':first').css('background-position','-250px')
			$(apply_active).children(':first').animate({ 
				backgroundPosition:new_width
			}, 150, function() {
				});	
			});
		}
	}
	
	$('.menu_items ul li').hover(
 		function() {
			$(this).children(':first').addClass('bord_over')
			$(this).addClass('lightfont')
  		}, function() {
    		$(this).children(':first').removeClass('bord_over')
			$(this).removeClass('lightfont')
  		}
	);
	
    $('.menu_items ul li').click(function(){
		if($(this).attr('id').split('_')[0]=='vto')	{
			$('.v_menu').removeClass('chapters_buger_visible')
		}				
		li_id = '#'+$(this).attr('id')	
		gotoPlace = '#sec_'+$(this).attr('id').split('_')[1]
		$('html, body').animate({
        	scrollTop: $(gotoPlace).offset().top
    	}, 750, function() {
			})
	});

	$('.chapters_burger').click(function(){
		$('.v_menu').addClass('chapters_buger_visible')
	})
	
	$('.burger_close').click(function(){
		$('.v_menu').removeClass('chapters_buger_visible')
	})

	/* commented out to stop flickering on iPhone and iPad */
	/*var bar_robot = $(window).scrollTop();
	if(isiPad || isAndroidTablet || isiPhone){
		$(window).scroll(function() {
			if($(window).scrollTop() > bar_robot)
			{
			   // $('.bar_robot').fadeOut();  
			}
			else
			{
				//$('.bar_robot').fadeIn();
			}
			//bar_robot = $(window).scrollTop();
		});
	}
	*/

	/* added functionality to reposition banner of devices when using Saba */
	if(isiPad || isiPhone){
		var scrolling = false;		
		var scrollInt;		
		$(".topic_index .bar_close").css("display","none !important");
		$(".menu_items .bar_close").css("display","none !important");				
		$(window).on("scrollstart",function(){			
			if(index == false){ /* added condition for menu screen */
				clearTimeout(scrollInt);
				$('.bar_robot').removeClass('displayBlock').addClass('displayNone');
				$(".topic_index .bar_close").css("display","none !important");
				$(".menu_items .bar_close").css("display","none !important");
			}else{
				$('.bar_robot').removeClass('displayBlock').addClass('displayNone');
				if(!scrolling){
					topic_height(); /* fix for iPad menu position issue */
				}
			}
		}); 
	  
		/*$(window).on("scrollstop",function(){
			if(index == false){ // added condition for menu screen
				scrollInt = setTimeout(function(){
					$('.bar_robot').css('top',($(parent.parent.document).scrollTop())-1+'px');
					$('.bar_robot').removeClass('displayNone').addClass('displayBlock');
				},500);

				$(".topic_index .bar_close").css("display","none !important");
				$(".menu_items .bar_close").css("display","none !important");
			}else{
				$('.bar_robot').removeClass('displayBlock').addClass('displayNone');
			}
		});*/	
	
		window.top.onorientationchange = function () {
			var orientTop = window.top.orientation;
			if ((orientTop == 0) || (orientTop == 180)) {
				showBanner()
			}
			else if ((orientTop == -90) || (orientTop == 90)) {
				showBanner()
			}
		}
	}

	/* banner fix for iPad and iPhone */
	function hideBanner(){		
		if(index == false){ /* added condition for menu screen */				
			$('.bar_robot').removeClass('displayBlock').addClass('displayNone');
			$(".topic_index .bar_close").css("display","none !important");
			$(".menu_items .bar_close").css("display","none !important");
		}else{
			$('.bar_robot').removeClass('displayBlock').addClass('displayNone');			
			topic_height(); /* fix for iPad menu position issue */
		}
	}

	function showBanner(){
	
		if(index == false){ /* added condition for menu screen */
			// iOS13 Fix to show banner
			if(iOSVersion < 13){
				$('.bar_robot').css('top',($(parent.parent.document).scrollTop())-1+'px');
			}else{
				// iOS13 Fix to show banner
				if(iOSApp){
					$('.bar_robot').css('top',($(parent.parent.document).scrollTop())-1+'px');
					//setTimeout(function(){hotSpotAdjustBanner();},100);
				}else{
					$('.bar_robot').css('top','-1px');
				}
			}// iOS13 Fix to show banner
			
			$('.bar_robot').removeClass('displayNone').addClass('displayBlock');
			$(".topic_index .bar_close").css("display","none !important");
			$(".menu_items .bar_close").css("display","none !important");
		}else{
			$('.bar_robot').removeClass('displayBlock').addClass('displayNone');
		}
	}
	
	/* close button is always hidden */
	/*if(isWeb){	
		$(".topic_index .bar_close").addClass('displayBlock');
		$(".bar_close").addClass('displayBlock');
		
		$('.bar_close').attr('style', 'display: block !important');
	}else{
		$(".bar_close").addClass('displayNone')
		}*/	
});

/* reposition banner when navigating menu */
function rePosBanner(){	
	if(window.top !== window.self) {
		if(index == false){
			$('.bar_robot').css('display','block');
			$('.bar_bot').css('display','block');
			$(".bar_bot").removeClass('displayNone').addClass('displayBlock');
			$(".bar_robot").removeClass('displayNone').addClass('displayBlock');
		}
		$('.bar_robot').css('top',0+'px');
		if(isiPad || isiPhone){
			if(iOSVersion < 13){ // iOS13 Fix to show banner
				$(parent.parent.document).scrollTop(0); /* fix to scroll topic content when scrolling on menu */
			}else{
				if(iOSApp){
					$(parent.parent.document).scrollTop(0);
				}else{
					$(window).scrollTop(0);  // iOS13 Fix to show banner
				}
			}
		}		
	}else{
		if(index == false){
			$('.bar_robot').css('display','block');
			$('.bar_bot').css('display','block');
			$(".bar_bot").removeClass('displayNone').addClass('displayBlock');
			$(".bar_robot").removeClass('displayNone').addClass('displayBlock');
		}
	}
}