
function checkForTimetableDetail()
{
	
	var s_user_id = document.getElementById('s_user_id').value;
	s_user_id = encodeURIComponent(s_user_id);
	var n_date = document.getElementById('n_date').value;

	var n_location_id='';
	if(document.getElementById('n_location_id') != null)
		n_location_id = document.getElementById('n_location_id').value;

	var flag_error = true;
	if(s_user_id == "")
	{
		$('show_error_s_user_id').style.display = 'block';
		flag_error = false;
	}
	else
	{
		$('show_error_s_user_id').style.display = 'none';		
	}
	
	if(n_date == "")
	{
		$('show_error_n_date').style.display = 'block';
		flag_error = false;
	}
	else
	{
		$('show_error_n_date').style.display = 'none';		
	}

	if(n_location_id == "")
	{
		$('show_error_n_location_id').style.display = 'block';
		flag_error = false;
	}
	else
	{
		$('show_error_n_location_id').style.display = 'none';		
	}

	return flag_error;}

function ShowLocationFromBranch()
{
	if($('n_location_id'))
		setFocus('n_location_id');
	var n_branch_id = document.getElementById('n_branch_id').value;

	var url = "index.php?do=admin_time_table_detail";	
	url += '&n_branch_id=' + n_branch_id + '&action=show_room';
	load_pages(url, 'div_location_id');
}

function editAdminTimetable(time_table_id, edit)
{
	var oForm = document.admin_form;
	oForm.time_table_id.value = time_table_id;
	oForm.edit.value = edit; 
	oForm.action = "?do=admin_time_table_detail";
	oForm.submit();					
}
function editAdminTimetableEnter(time_table_id, edit)
{
	var oForm = document.admin_form;
	oForm.time_table_id.value = time_table_id;
	oForm.edit.value = edit; 
	oForm.action = "?do=admin_time_table";
	oForm.submit();					
}

function editAdminTimetableDetail(time_table_detail_id, edit)
{
	var oForm = document.admin_form;
	oForm.time_table_detail_id.value = time_table_detail_id;
	oForm.edit.value = edit; 
	oForm.submit();					
}

function delAdminTimetable()
{
	var n_lesson_id = document.getElementById('n_lesson_id').value;
	var n_term_id = document.getElementById('n_term_id').value;

	var codition = '&n_lesson_id=' + n_lesson_id + '&n_term_id=' + n_term_id;
	deleteGeneral('admin_time_table', 'show_admin_time_table', codition);
}

function delAdminTimetableDetail()
{
	var s_user_id = document.getElementById('s_user_id').value;
	s_user_id = encodeURIComponent(s_user_id);
	var n_location_id='';
	if(document.getElementById('n_location_id') != null)
		n_location_id = document.getElementById('n_location_id').value;

	var n_date = document.getElementById('n_date').value;
	var n_time_table_id = document.getElementById('n_time_table_id').value;

	var codition = '&n_location_id=' + n_location_id + '&n_date=' + n_date + '&s_user_id=' + s_user_id + '&n_time_table_id=' + n_time_table_id;
	deleteGeneral('admin_time_table_detail', 'show_admin_time_table', codition);
}

function showTimetableAdmin()
{
	var dt_start_date = document.getElementById('dt_start_date').value;
	var dt_end_date = document.getElementById('dt_end_date').value;
	var res_compare = compareDateDMY(dt_start_date, dt_end_date);
	if(res_compare && res_compare > 0)
	{
		$('error_compare_date').style.display = 'block';
	}
	else
	{
		$('error_compare_date').style.display = 'none';
		
		var pars = '&dt_start_date=' + dt_start_date + '&dt_end_date=' + dt_end_date;
		searchAll('admin_time_table','show_admin_time_table','search',pars);
		//ShowDivGeneral(url, pars, 'show_admin_time_table');		
	}
}
function showTimetableDetailAdmin()
{
	var s_user_id = document.getElementById('s_user_id').value;
	s_user_id = encodeURIComponent(s_user_id);
	var n_date = document.getElementById('n_date').value;
	
	var n_location_id='';
	if(document.getElementById('n_location_id') != null)
		n_location_id = document.getElementById('n_location_id').value;
		
	var n_branch_id = document.getElementById('n_branch_id').value;
	var n_time_table_id = document.getElementById('n_time_table_id').value;

	
	var url = "index.php?do=admin_time_table_detail";	
	var pars = 'n_date=' + n_date + '&s_user_id=' + s_user_id + '&n_branch_id=' + n_branch_id + '&n_location_id=' + n_location_id + '&n_time_table_id=' + n_time_table_id + '&action=search&index_paging=1';

	ShowDivGeneral(url, pars, 'show_admin_time_table');
}