﻿// функция извлекает индекс из названия элемента в массиве
// "show_sections_18" => "18"
function extract_id(instr)
{
	return instr.substring(instr.indexOf('_')+1, instr.length);
}

// Функция снятия выделения с блока вакансии
function deselect_vacancy(id)
{
	if (id == null)
	{
		return;
	};
	YAHOO["module_" + id].hide();
	document.getElementById("vacancyLayer_" + id).className = 'candidate_vacancy_container';
	if (document.getElementById("vacancySalary_" + id) != null)
	{
		document.getElementById("vacancySalary_" + id).className = 'candidate_vacancy_salary';
	};
};

// Функция выделения блока вакансии
function select_vacancy(id)
{
	if (id == null)
	{
		return;
	};
	YAHOO["module_" + id].show();
	document.getElementById("vacancyLayer_" + id).className = 'candidate_vacancy_container candidate_vacancy_a';
	if (document.getElementById("vacancySalary_" + id) != null)
	{
		document.getElementById("vacancySalary_" + id).className = 'candidate_vacancy_salary candidate_vacancy_salary_a';
	};
};

function vacancy_data_action(e, module)
{
	current_id = extract_id(module.id);
	if (module.cfg.getProperty("visible") == false)
	{
		select_vacancy(current_id);
		document.getElementById("vacancySalary_"+current_id+"_n").style.display = "none";
		document.getElementById("vacancySalary_"+current_id+"_a").style.display = "block";
	}
	else
	{
		deselect_vacancy(current_id);
		document.getElementById("vacancySalary_"+current_id+"_a").style.display = "none";
		document.getElementById("vacancySalary_"+current_id+"_n").style.display = "block";
	};
};

function validate_form()
{
	if (! frm.check())
	{
		YAHOO.util.Dom.get('find').disabled = true;
	}
	else
	{
		YAHOO.util.Dom.get('find').disabled = false;
	};
}