// Stop tutor
//function stopTutor() {
	if (document.getElementById('jstopgame')) {
		try {document.getElementById('invisiblock').remove();} catch{}
		try {$('body').removeClass('stop-scrolling');} catch{}
		try {document.getElementById('click1').remove();} catch{}
		//setCookie('tutor', 3, 999999999);
		//clearInterval(stI);
	}
//}
//var stI = setInterval(stopTutor, 1000);

// Close Tutor
function closeTut() {
	document.getElementById('clo1').remove();
}

// Pointer finger
var toPoint = '';

function setPointer() {
	try {
		if (parseInt(click1.style.top) <= parseInt(window.scrollY+30)) {
			window.location.href = root;
			clearInterval(inter);
		}
		
		var rect = toPoint.getBoundingClientRect();
		var right = rect.right + window.scrollX;
		var bottom = rect.bottom + window.scrollY;

		click1.style.top = bottom-10+'px';
		click1.style.left = right-10+'px';	
	}
	catch {}
	//console.log(parseInt(click1.style.top)+' <= '+parseInt(window.scrollY+30));
}
var inter = setInterval(setPointer, 25);

window.scroll({top: 0,left: 0,behavior: "smooth"});

// Tutor
var tut = getCookie('tutor');
if (tut == 'ready') {
	if (strstr(window.location.href, 'song/7029/142359')) {
		$('body').append('<div id="invisiblock"></div>');
		//$('body').addClass('stop-scrolling');

		$('body').append('<div id="click1" class="click"></div>');
		var click1 = document.getElementById('click1');
		click1.style.position = "absolute";
		click1.style.zIndex = "9";
		
		var word1 = document.getElementById('wo3');
		var word2 = document.getElementById('wo250');
		var word3 = document.getElementById('wo433');
		try{word1.style.zIndex = "5"; word1.style.position = "relative";}catch{window.location.href = root;}
		word1.classList.add('wog');
		word1.classList.add('glow');
		
		toPoint = word1;

        $('body').append('<div id="clo1" class="clo">'+LANG2[0]+'</div>');
        var clo1 = document.getElementById('clo1');

		word1.addEventListener("click", step1Delay);
		function step1Delay() {
			int1 = setInterval(step1, 500);
		}
		word2.addEventListener("click", step2Delay);
		function step2Delay() {
			int2 = setInterval(step3, 500);
		}
		word3.addEventListener("click", step3Delay);
		function step3Delay() {
			int3 = setInterval(step5, 500);
		}

		function step1() {
			window.scroll({top: word1.getBoundingClientRect().top-window.screen.height/2,left: 0,behavior: "smooth"});

			word1.style.zIndex = "0";
			//document.getElementsByClassName('close')[1].style.pointerEvents = "none";
			but = document.getElementById('jswa');
			but.parentNode.style.zIndex = "5";
			but.classList.add('glow');
			toPoint = but;
			but.href = 'javascript:void(0)';
			but.addEventListener("click", step2);
			if (int1) {clearInterval(int1)}
            clo1.innerHTML = ''+LANG2[1]+'';
		}

		function step2() {
			but.parentNode.remove();
			word2.style.zIndex = "9"; word2.style.position = "relative";
			word2.classList.add('wog');
			word2.classList.add('glow');
			toPoint = word2;

			//$('body').removeClass('stop-scrolling');
			window.scroll({top: word2.getBoundingClientRect().top-window.screen.height/2,left: 0,behavior: "smooth"});
			//$('body').addClass('stop-scrolling');

            clo1.innerHTML = ''+LANG2[2]+'';
		}

		function step3() {
			word2.style.zIndex = "0";
			but = document.getElementById('jswa');
			but.parentNode.style.zIndex = "5";
			but.classList.add('glow');
			toPoint = but;
			but.href = 'javascript:void(0)';
			but.addEventListener("click", step4);
			if (int2) {clearInterval(int2)}
            clo1.remove();
		}

		function step4() {
			but.parentNode.remove();
			word3.style.zIndex = "5"; word3.style.position = "relative";
			word3.classList.add('wog');
			word3.classList.add('glow');
			toPoint = word3;

			//$('body').removeClass('stop-scrolling');
			window.scroll({top: 99999,left: 0,behavior: "smooth"});
			//$('body').addClass('stop-scrolling');
		}

		function step5() {
			word3.style.zIndex = "0";
			but = document.getElementById('jswa');
			but.parentNode.style.zIndex = "5";
			but.classList.add('glow');
			toPoint = but;
			but.href = 'javascript:void(0)';
			but.addEventListener("click", step6);
			if (int3) {clearInterval(int3)}
		}

		function step6() {
			but.parentNode.remove();
			but = document.getElementById('jsdb');
			but.style.zIndex = "5"; but.style.position = "relative";
			toPoint = but;
			but.classList.add('glow');
			but.href = 'javascript:void(0)';
			but.addEventListener("click", step7);
		}

		function step7() {
			setCookie('tutor', 1, 999999999);
			location.href = root+'songdone/7029/142359';
		}

	}
}
else if (tut == 1) {
	if (strstr(window.location.href, 'songdone/7029/142359')) {
		$('body').append('<div id="invisiblock"></div>');
		//$('body').addClass('stop-scrolling');

		$('body').append('<div id="click1" class="click"></div>');
		var click1 = document.getElementById('click1');
		click1.style.position = "absolute";
		click1.style.zIndex = "9";

        but = document.getElementById('jsdb');
        but.style.zIndex = "5"; but.style.position = "relative";
		toPoint = but;
		but.classList.add('glow');

        $('body').append('<div id="clo1" class="clo">'+LANG2[3]+'</div>');
        var clo1 = document.getElementById('clo1');

    }
    else if (strstr(window.location.href, 'school')) {
		$('body').append('<div id="invisiblock"></div>');
		//$('body').addClass('stop-scrolling');

        but = document.getElementById('jsm5');

		$('body').append('<div id="click1" class="click"></div>');
		var click1 = document.getElementById('click1');
		click1.style.position = "absolute";
		click1.style.zIndex = "9";

        but.style.position = "relative";
        but.style.zIndex = "6";
		$('#jsm5img').addClass('pulse');

        $('body').append('<div id="clo1" class="clo">'+LANG2[4]+'</div>');
        var clo1 = document.getElementById('clo1');

    }
    else if (strstr(window.location.href, 'learn?supermode')) {
		//$('body').append('<div id="invisiblock"></div>');
		
		$('body').addClass('stop-scrolling');

        but = document.getElementById('jsdb');
		toPoint = but;
		but.classList.add('glow');
        but.style.position = "relative";
        but.style.zIndex = "6";

        $('body').append('<div id="clo1" class="clo">'+LANG2[5]+'</div>');
        var clo1 = document.getElementById('clo1');

		setCookie('tutor', 2, 999999999);
    }
    
}
else if (tut == 2) {
    if (strstr(window.location.href, 'supermode=1&mode=4') && strstr(document.body.innerHTML, 'xpbar')) { // FINAL!!!
        function finishTutor() {
            window.location.href = root;
        }
	
		$('body').append('<div id="invisiblock"></div>');
		//$('body').addClass('stop-scrolling');

        $('body').append('<div id="clo1" class="clo">'+LANG2[6]+' <br> <a id="finbut" class="button_mid" href="javascript: void(0)" onclick="finishTutor()">'+LANG2[7]+'</a></div>');
        var clo1 = document.getElementById('clo1');

        but = document.getElementById('finbut');
        but.style.position = "relative";
        but.style.zIndex = "6";

        setCookie('tutor', 3, 999999999);

    }
}