function nextStep( step, module_id, elem ) {
	
	var text = elem.innerHTML;
	elem.innerHTML = '<img src="http://i.online.ua/teaching/ajax-loader.gif" alt="" />';
	
	if ( step == 5 ) {
		JsHttpRequest.query(
			'http://www.online.ua/_ajax/teaching/five_step/',
			null,
	        function(responseJS, responseText) {
				if ( responseText == 'true' ) {
					JsHttpRequest.query(
						'http://www.online.ua/_ajax/teaching/next_step/',
						{ 'step' : step, 'module_id' : module_id },
				        function(responseJS, responseText) {
							JsHttpRequest.query(
								'http://www.online.ua/_ajax/teaching/get_slide/',
								{ 'step' : step, 'module_id' : module_id },
						        function(responseJS, responseText) {
									document.getElementById( 'teaching-content' ).innerHTML = responseText;
									document.getElementById( 'teaching-content' ).parentNode.className = 'teaching';
								},
						        true
						    );
						},
				        true
				    );
				} else {
					elem.innerHTML = text;
					alert( 'Необходимо выполнить описанные действия' );
				}
			},
	        true
	    );
	} else if ( step == 11 ) {
		JsHttpRequest.query(
			'http://www.online.ua/_ajax/teaching/eleven_step/',
			null,
	        function(responseJS, responseText) {
				if ( responseText == 'true' ) {
					JsHttpRequest.query(
						'http://www.online.ua/_ajax/teaching/next_step/',
						{ 'step' : step, 'module_id' : module_id },
				        function(responseJS, responseText) {
							JsHttpRequest.query(
								'http://www.online.ua/_ajax/teaching/get_slide/',
								{ 'step' : step, 'module_id' : module_id },
						        function(responseJS, responseText) {
									document.getElementById( 'teaching-content' ).innerHTML = responseText;
									document.getElementById( 'teaching-content' ).parentNode.className = 'teaching';
								},
						        true
						    );
						},
				        true
				    );
				} else {
					elem.innerHTML = text;
					alert( 'Необходимо выполнить описанные действия' );
				}
			},
	        true
	    );
	} else {
		JsHttpRequest.query(
			'http://www.online.ua/_ajax/teaching/next_step/',
			{ 'step' : step, 'module_id' : module_id },
	        function(responseJS, responseText) {
				JsHttpRequest.query(
					'http://www.online.ua/_ajax/teaching/get_slide/',
					{ 'step' : step, 'module_id' : module_id },
			        function(responseJS, responseText) {
						document.getElementById( 'teaching-content' ).innerHTML = responseText;
						if ( step == 7 || step == 19 ) {
							document.getElementById( 'teaching-content' ).parentNode.className = 'teaching teaching-type-2';
						} else if ( step == 13 || step == 15 || step == 18 ) {
							document.getElementById( 'teaching-content' ).parentNode.className = 'teaching teaching-type-5';
						} else {
							document.getElementById( 'teaching-content' ).parentNode.className = 'teaching';
						}
					},
			        true
			    );
			},
	        true
	    );
	}

    return false;
	
}

function fourStep() {
	
	JsHttpRequest.query(
		'http://www.online.ua/_ajax/teaching/four_step/',
		null,
        function(responseJS, responseText) {
			return true;
		},
        true
    );
	
	return true;
	
}

function endTeaching() {
	
	if ( confirm( 'Вы действительно хотите завершить обучение?' ) ) {
	
		JsHttpRequest.query(
			'http://www.online.ua/_ajax/teaching/end_teaching/',
			null,
	        function(responseJS, responseText) {
				var teaching = document.getElementById( 'teaching' );
				teaching.parentNode.removeChild(teaching);
				return true;
			},
	        true
	    );
	
	}
	return false;
	
}

function closeTeaching() {
	var teaching = document.getElementById( 'teaching' );
	teaching.parentNode.removeChild(teaching);
	return false;
}

function showTeaching() {
	
	JsHttpRequest.query(
		'http://www.online.ua/_ajax/teaching/show_teaching/',
		null,
        function(responseJS, responseText) {
			window.location.reload(true);
			return true;
		},
        true
    );
	
	return false;
	
}

function teachingSetHome() {
	
	JsHttpRequest.query(
		'http://www.online.ua/_ajax/teaching/set_home/',
		null,
        function(responseJS, responseText) {
			JsHttpRequest.query(
				'http://www.online.ua/_ajax/teaching/next_step/',
				{ 'step' : 17, 'module_id' : 1 },
		        function(responseJS, responseText) {
					window.location.href = '/homepage/';
				},
		        true
		    );
		},
        true
    );
	
	return false;
	
}

function saveOption( s, name, param, lang ) {
	var text = "Вы действительно хотите скрыть этот блок?";
	if ( lang == "ua" ) text = "Ви дійсно бажаєте приховати цей блок?";
	if ( confirm( text ) ) {
	    JsHttpRequest.query(
	        '/ajax/options_save/',
	        {name:name, param:param},
	        function(responseJS, responseText) {
	        	var el = document.getElementById( 'teaching_mode' );
	        	if ( el != 'undefined' ) el.parentNode.removeChild(el);
	        },
	        true
	    );
	}
    return true;
}

function closeTeachingPromo() {
	JsHttpRequest.query(
		'http://www.online.ua/_ajax/teaching/close_teaching_promo/',
		null,
        function(responseJS, responseText) {
			window.location.reload(true);
			return true;
		},
        true
    );
	
	return false;
}
