// JavaScript Document
function getLesson()
{
	var n_speciality_id = document.getElementById('n_speciality_id').value;
		
	if(document.getElementById('cod_lesson') && n_speciality_id != "")
	{
		setFocus('n_lesson_id');
		showOnePart(2, 'cod_lesson');
	}
}
function getClassBySpeciality()
{
	var n_speciality_id = document.getElementById('n_speciality_id').value;
		
	if(document.getElementById('cod_class') && n_speciality_id != "")
	{
		setFocus('n_class_id');
		showOnePart(2, 'cod_class');
	}
}

function checkSpeciality()
{
	var n_speciality_id = document.getElementById('n_speciality_id').value;
	if(n_speciality_id == '')	
		return false;
	return true;
}
function checkLesson()
{
	var n_lesson_id = document.getElementById('n_lesson_id').value;
	var n_term_id = document.getElementById('n_term_id').value;
	var flag_error = true;
	if(n_lesson_id == "")
	{
		$('show_error_n_lesson_id').style.display = 'block';
		flag_error = false;
	}
	else
	{
		$('show_error_n_lesson_id').style.display = 'none';		
	}

	if(n_term_id == "")
	{
		$('show_error_n_term_id').style.display = 'block';
		flag_error = false;
	}
	else
	{
		$('show_error_n_term_id').style.display = 'none';		
	}
	return flag_error;
}
function checkSpecialityAdmin()
{
	var n_speciality_id = document.getElementById('n_speciality_id').value;
	if(n_speciality_id != "")
		return true;
	return false
}

function getSpeciality(flag)
{
	var n_course_id = document.getElementById('n_course_id').value;
	var n_m_subject_id = document.getElementById('n_m_subject_id').value;
	if(n_course_id != "" && n_m_subject_id != "")
	{
		document.getElementById('n_speciality_id').value = '';
		if(document.getElementById('cod_lesson'))
		{
			document.getElementById('n_lesson_id').innerHTML = '';
		}		
		setFocus('n_speciality_id');
		showOnePart(flag, 'cod_speciality');
	}
		
}
function getCourse(flag)
{
	document.getElementById('n_speciality_id').innerHTML = '';

	if(document.getElementById('cod_lesson'))
	{
		document.getElementById('n_lesson_id').innerHTML = '';
	}
	var n_system_id = document.getElementById('n_system_id').value;	
	if(n_system_id != "")
	{
		setFocus('n_course_id');
		document.getElementById('n_course_id').value = '';
		showOnePart(flag, 'cod_course');
		
	}		
}
function showOnePart(flag, div)
{
	var url, pars;
	var n_system_id = document.getElementById('n_system_id').value;
	var n_course_id = document.getElementById('n_course_id').value;
	var n_m_subject_id = document.getElementById('n_m_subject_id').value;
	
	var cur_action = "&action=" + div;		

	if(flag == 1)
	{
		url = "index.php?do=codition_search" + cur_action;
		
		pars = 'n_system_id=' + n_system_id + '&n_course_id=' + n_course_id + '&n_m_subject_id=' + n_m_subject_id;
		
	}
	if(flag == 2)
	{
		var n_speciality_id = document.getElementById('n_speciality_id').value;

		url = "index.php?do=codition_search_lesson" + cur_action;	
		pars = 'n_system_id=' + n_system_id + '&n_course_id=' + n_course_id + '&n_m_subject_id=' + n_m_subject_id + '&n_speciality_id=' + n_speciality_id;
		
	}
	ShowDivGeneral(url, pars, div);
}
function getAll(flag)
{
	var url, pars;
	var n_system_id = document.getElementById('n_system_id').value;
	var n_course_id = document.getElementById('n_course_id').value;
	var n_m_subject_id = document.getElementById('n_m_subject_id').value;
	
	if(flag == 1)
	{
		url = "index.php?do=codition_search";	
		pars = 'n_system_id=' + n_system_id + '&n_course_id=' + n_course_id + '&n_m_subject_id=' + n_m_subject_id;
		
	}
	if(flag == 2)
	{
		var n_speciality_id = document.getElementById('n_speciality_id').value;
		url = "index.php?do=codition_search_lesson";	
		pars = 'n_system_id=' + n_system_id + '&n_course_id=' + n_course_id + '&n_m_subject_id=' + n_m_subject_id + '&n_speciality_id=' + n_speciality_id;
		
	}
	ShowDivGeneral(url, pars, 'codition_search');
}