/* 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 */
		
		//console.log('SCROLL document.currentSection = ' + document.currentSection);
		
		//animateContent(document.currentSection)
		
		/* added global lockdown variable */
		if(document.courseLockedDown){
			
			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;
				document.audioComplete = true; //2019/06/04 Next arrow on unlocked screens
			}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;
				
				//console.log("page is unlocked");
				
				/*if(!$('#sec_'+ (document.currentSection)).next().hasClass('breaker') || $('#sec_'+ (document.currentSection)).hasClass('testResults') ){
			
					$('#sec_' + document.currentSection + ' .complete_arrow').css('display', 'block');
					$('#sec_' + document.currentSection + ' .complete_arrow').addClass('unlocked');
				}*/
			}
			
			
			
		}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;
			}
		}
		
		/* check to see if the slider can be unlocked */
		setTimeout(function(){
			isSliderDone();
		},200)
		
		/* page/section has already been viewed so mark as complete */
		if(document.trackingArr[document.currentSection - 1] == 1){
			//console.log("page/section has already been viewed so mark as complete");
			document.intComplete = true;
			document.audioComplete = true;
		}
		
		var className = $('#sec_'+document.currentSection).attr('class');			
			if(className.indexOf('preTopicQues') != -1){
				
				//console.log("lock question");
				document.intComplete = false;
				document.audioComplete = true;
			}
		
		isPageComplete(document.currentSection); /* check to see if section/page can be marked as complete */
		getSliderHeight();
	}

	
		$(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($(che).hasClass('preTopicQues') || $(che).hasClass('preTopicRes')){
										  //console.log("don't bookmark")
							  	}
							  	else{
									if(typeof doBookMark !="undefined" ) {
										doBookMark(che) 
									};
								}
							}
							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($(che).hasClass('preTopicQues') || $(che).hasClass('preTopicRes')){
										  //console.log("don't bookmark")
							}else{
								if(typeof doBookMark !="undefined" ) { doBookMark(che) };
							}
							get_nearest_breaker(che);
						}
						//showBanner();
					}
				}, 200));
			winHeight = $(window).height()
			//winHeightV = winHeight-64
			winHeightV = winHeight
			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')
							}
						}
						
						che = '#'+$(this).attr('id');
						/* 20221020 ensure navigation instruction is not part of tab order when it is empty at the end of the assesssment */
						$('.nav_instruction .instruction').attr('tabindex',(Number($("#left_nav").attr('tabindex'))-1));
						if($(che).next('.section').hasClass('secStart')){
							/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
							/* if a branch was previously selected in a session, enable the Home button in the footer */
							if(document.hasBranches){
								if(document.userBranch != 0){
									$('#home_nav').css("opacity","1")
									$('#home_nav').css("pointer-events","auto")
								}
							}	
							/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
							/* if on the pages before the branching page show the topic instruction and disable the Home button in the footer if a branch has not been selected in a session else show the section instruction and enable it */
							if($(che).hasClass('preBranchScreen')){
								$("#home_nav").css("visibility","visible");
								if(document.hasBranches){
									if (document.userBranch != 0)
									{
										$('.nav_instruction .instruction').html(localiseString('nav_topic_txt'));
										$('#home_nav').css("opacity","1")
										$('#home_nav').css("pointer-events","auto")
									}
									else
									{
										$('.nav_instruction .instruction').html(localiseString('nav_prebranch_txt'));
										$('#home_nav').css("opacity","0.3")
										$('#home_nav').css("pointer-events","none")
									}
								}
								console.log(che)
							/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
							/* if on the branching page clear the instruction and disable the Home button in the footer if a branch has not been selected in a session else show the branch instruction and enable it */
							} else if($(che).hasClass('branchScreen')){
								$("#home_nav").css("visibility","visible");
								if(document.hasBranches){
									if (document.userBranch != 0)
									{
										$('.nav_instruction .instruction').html(localiseString('nav_branch_txt'));
										$('#home_nav').css("opacity","1")
										$('#home_nav').css("pointer-events","auto")
									}
									else
									{
										$('.nav_instruction .instruction').html('');
										$('#home_nav').css("opacity","0.3")
										$('#home_nav').css("pointer-events","none")
									}
								}
								console.log(che)
							}
							/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
							/* if on the last page of a branch show the exit instruction and enable the Home button in the footer */
							else if($(che).hasClass("endBranch")){
								$('.nav_instruction .instruction').html(localiseString('nav_exit_txt'));
								$("#home_nav").css("visibility","visible");
								$('#home_nav').css("opacity","1")
								console.log(che)
							}
							/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
							/* if on any other page show the section instruction and enable the Home button in the footer */
							 else {
								$('.nav_instruction .instruction').html(localiseString('nav_section_txt'));
								$("#home_nav").css("visibility","visible");
								$('#home_nav').css("opacity","1")
								console.log(che)
								/* 20230427 hide nav when pre-test has been taken */
								if ((document.pretestPresent == 1) && (document.pretestAttempted == 1) && (document.topicsPretestedOut.indexOf("1") != -1)){
									$('.nav_instruction .instruction').html(test_intro_dat['pre_test_nav'][0].home_only);
								}
							}
						/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
						/* if the next page is the first page in a topic, show the topic instruction and disable the Home button in the footer */
						}else if($(che).next('.section').hasClass('breaker')){
							$('.nav_instruction .instruction').html(localiseString('nav_topic_txt'));
							$("#home_nav").css("visibility","hidden");
							console.log(che)
							/* 20230427 hide nav when pre-test has been taken */
							if ((document.pretestPresent == 1) && (document.pretestAttempted == 1) && (document.topicsPretestedOut.indexOf("1") != -1)){
									$('.nav_instruction .instruction').html(test_intro_dat['pre_test_nav'][0].home_only);
							}
						}
						/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
						/* if on any other page disable the Home button in the footer */
						else{
							$("#home_nav").css("visibility","hidden")
							console.log(che)
							/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
							/* if on the last page of the course or on the last page of a branch that indicates the end of the course show the exit instruction and enable the Home button in the footer */
							if((Number(che.split("_")[1]) == document.subsectionCount) || $("#sec_"+(Number(che.split("_")[1]))).hasClass("endCourse")) {
								$('.nav_instruction .instruction').html(localiseString('nav_exit_txt'));
								/* 20221020 ensure navigation instruction is not part of tab order when it is empty at the end of the assesssment */
								if (localiseString('nav_exit_txt') == "")
								{
									$('.nav_instruction .instruction').attr('tabindex','-1');
								}
								$("#home_nav").css("visibility","visible");
								$('#home_nav').css("opacity","1")
								console.log(che)
							}
						}
						
					}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');
								/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
								/* if a branch was previously selected in a session, enable the Home button in the footer */
								if(document.hasBranches){
									if(document.userBranch != 0){
										$('#home_nav').css("opacity","1")
										$('#home_nav').css("pointer-events","auto")
									}
								}	
								if($(che).next('.section').hasClass('secStart')){
									/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
									/* if on the pages before the branching page show the topic instruction and disable the Home button in the footer if a branch has not been selected in a session else show the section instruction and enable it */
									if($(che).hasClass('preBranchScreen')){
										$("#home_nav").css("visibility","visible");
										if(document.hasBranches){
											if (document.userBranch != 0)
											{
												$('.nav_instruction .instruction').html(localiseString('nav_topic_txt'));
												$('#home_nav').css("opacity","1")
												$('#home_nav').css("pointer-events","auto")
											}
											else
											{
												$('.nav_instruction .instruction').html(localiseString('nav_prebranch_txt'));
												$('#home_nav').css("opacity","0.3")
												$('#home_nav').css("pointer-events","none")
											}
										}
										console.log(che)
									/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
									/* if on the branching page clear the instruction and disable the Home button in the footer if a branch has not been selected in a session else show the branch instruction and enable it */
									} else if($(che).hasClass('branchScreen')){
										$("#home_nav").css("visibility","visible");
										if(document.hasBranches){
											if (document.userBranch != 0)
											{
												$('.nav_instruction .instruction').html(localiseString('nav_branch_txt'));
												$('#home_nav').css("opacity","1")
												$('#home_nav').css("pointer-events","auto")
											}
											else
											{
												$('.nav_instruction .instruction').html('');
												$('#home_nav').css("opacity","0.3")
												$('#home_nav').css("pointer-events","none")
											}
										}
										console.log(che)
									/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
									/* if on the last page of a branch show the exit instruction and enable the Home button in the footer */										
									} else if($(che).hasClass("endBranch")){
										$('.nav_instruction .instruction').html(localiseString('nav_exit_txt'));
										$("#home_nav").css("visibility","visible");
										$('#home_nav').css("opacity","1")
										console.log(che)
										/* 20230427 hide nav when pre-test has been taken */
										if ((document.pretestPresent == 1) && (document.pretestAttempted == 1) && (document.topicsPretestedOut.indexOf("1") != -1)){
											$('.nav_instruction .instruction').html(test_intro_dat['pre_test_nav'][0].home_only);
										}
									}
									/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
									/* if on any other page show the section instruction and enable the Home button in the footer */
									 else {
										$('.nav_instruction .instruction').html(localiseString('nav_section_txt'));
										$("#home_nav").css("visibility","visible");
										$('#home_nav').css("opacity","1")
										console.log(che)
										/* 20230427 hide nav when pre-test has been taken */
										if ((document.pretestPresent == 1) && (document.pretestAttempted == 1) && (document.topicsPretestedOut.indexOf("1") != -1)){
											$('.nav_instruction .instruction').html(test_intro_dat['pre_test_nav'][0].home_only);
										}
									}
								/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
								/* if the next page is the first page in a topic, show the topic instruction and disable the Home button in the footer */
								}else if($(che).next('.section').hasClass('breaker')){
									$('.nav_instruction .instruction').html(localiseString('nav_topic_txt'));
									$("#home_nav").css("visibility","hidden");
									console.log(che)
									/* 20230427 hide nav when pre-test has been taken */
									if ((document.pretestPresent == 1) && (document.pretestAttempted == 1) && (document.topicsPretestedOut.indexOf("1") != -1)){
										$('.nav_instruction .instruction').html(test_intro_dat['pre_test_nav'][0].home_only);
									}
								} 
								else{
									/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
									/* if on any other page disable the Home button in the footer */
									$("#home_nav").css("visibility","hidden")
									/* custom branching based on CITI071: Module 6: common topic, a branching topic with branching screentype, two branches, no assessement 2023 */
									/* if on the last page of the course or on the last page of a branch that indicates the end of the course show the exit instruction and enable the Home button in the footer */
									if((Number(che.split("_")[1]) == document.subsectionCount) || $("#sec_"+(Number(che.split("_")[1]))).hasClass("endCourse")) {
										$('.nav_instruction .instruction').html(localiseString('nav_exit_txt'));
										/* 20221020 ensure navigation instruction is not part of tab order when it is empty at the end of the assesssment */
										if (localiseString('nav_exit_txt') == "")
										{	
											$('.nav_instruction .instruction').attr('tabindex','-1');
										}
										$("#home_nav").css("visibility","visible");
										$('#home_nav').css("opacity","1")
										console.log(che)
									}
								}
								
								if (($('.sec_rest_wrapper '+che).hasClass('testResults')) && (!document.takingPretest))
								{
									$('.topic_nav_bar .branding').css('display','block');
								}
								else {
									$('.topic_nav_bar .branding').css('display','block');
								}	
							}else{
							}
						}				
					}
					animateContent(Number(che.split("_")[1]));
				}
			});		
			$(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.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 */	
			if($(".burger_index").is(":visible")){
			}else{
				$('.bar_robot').removeClass('displayBlock').addClass('displayNone');
				$(".topic_index .bar_close").css("display","none !important");
				$(".menu_items .bar_close").css("display","none !important");
			}
		}else{
			
			
			if($(".burger_index").is(":visible")){
			
				
			}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 
			
			
			
			if(iOSVersion < 13){
				$('.bar_robot').css('top',($(parent.parent.document).scrollTop())-1+'px');
			}else{
				$('.bar_robot').css('top','-1px');
			}
			$('.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');
            
            //$(".burger_index").css('top',($(parent.parent.document).scrollTop())+64+'px');
			/*if(iOSVersion < 13){
				console.log("hello")
				$(".burger_index").css('top',($(parent.parent.document).scrollTop())+'px');
				$('.bar_robot').css('top',($(parent.parent.document).scrollTop())-1+'px');
			}else{
				$(".burger_index").css('top','0px');
				$('.bar_robot').css('top','-1px');
			}*/
			
			$(".burger_index").css('top','0px');
			$('.bar_robot').css('top','-1px');
			
			$('.bar_robot').removeClass('displayNone').addClass('displayBlock');
		}
		//$('.bar_robot').removeClass('displayNone').addClass('displayBlock');
		$('.bar_robot').css('top','-1px');
		$('.bar_robot').css('z-index',300);
		
		// 20200520 fix to remove language wrapper
	}
	
});

/* 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','-1px');
		if(isiPad || isiPhone){
			if(iOSVersion < 13){
				$(parent.parent.document).scrollTop(0); // fix to scroll topic content when scrolling on menu 
			}else{
				$(window).scrollTop(0); 
			}
		}		
	}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');
		}else{
            
        }
	}
	
	// 20200520 fix to remove language wrapper
}


function showImages(el) {
	
	$(el).each(function(){
		
		$(this).addClass("pullDown");
		
	});
}
function showRows(el) {

	$(el).each(function(){

		$(this).addClass("fadeIn");
		
	});
}

function checkToAnimate(sec){
	
	//console.log("sec = " + sec)
	
	if(isWeb || isAndroidTablet || isAndroidPhone){
		windowTop = Math.max($('body').scrollTop(), $('html').scrollTop());	
	}else{
		windowTop = $(parent.parent.document).scrollTop();
	}
	
	var container = $("#sec_"+sec).find('.container').eq(0)
	var distance = 250
	if(document.topic_intro === "no"){
		distance = -$(window).height()
	}else{
		distance = 250
	}
		
	if ($("#sec_"+sec+" .toFade").length > 0){ 
		if (windowTop > Math.round($(container).offset().top)+distance){
			showImages("#sec_"+sec+" .toFade");
		}
	}
	
	
	if ($("#sec_"+sec+" .tableRow").length > 0){ 
		//console.log("sec " + sec)
		if (windowTop > Math.round($(container).offset().top)+distance){
			showRows("#sec_"+sec+" .tableRow");
		}
	}
	
	
	
}

/*

// IE Jumpping elements Scroll Fix
// Fix for "jumpy" background on IE11
if(navigator.userAgent.match(/Trident\/7\./)) { // if IE
	$('body').on("mousewheel", function () {
	// remove default behavior
	event.preventDefault();

	//scroll without smoothing
	var wheelDelta = event.wheelDelta;
	var currentScrollPosition = window.pageYOffset;
	window.scrollTo(0, currentScrollPosition - wheelDelta + 5);
	});
} 

*/



