var BranchOpenClass = 'BranchOpen';
var BranchCloseClass = 'BranchClose';

var VacancyCloseClass = 'VacancyClose';
var VacancyOpenClass = 'VacancyOpen';

function ShowHide(obj, SubMenuId) {
	var SubMenu = document.getElementById(SubMenuId);
	if (SubMenu == null) return;
	
	SubMenu.style.display = (SubMenu.style.display == 'none') ? 'block':'none';
	obj.parentNode.className = (obj.parentNode.className == BranchOpenClass) ? BranchCloseClass : BranchOpenClass;
}

function ShowHideVacancy(obj, VacancyId) {
	var All = document.getElementsByTagName('DIV');

	for (i=0; i<All.length; i++) {
		if (All.item(i).className == 'VacancyDesc') All.item(i).style.display = 'none';
	}
	
	var Vacancy = document.getElementById(VacancyId);
	if (Vacancy == null) return;

	Vacancy.style.display = (Vacancy.style.display == 'none') ? 'block':'none';
	// obj.parentNode.className = (Vacancy.style.display == 'none') ? VacancyCloseClass : VacancyOpenClass;
	// obj.parentNode.className = (obj.parentNode.className == VacancyOpenClass) ? VacancyCloseClass : VacancyOpenClass;
}

function UnderLine(obj, flag) {
	if (obj == null) return;
	obj.style.textDecoration = flag ? 'underline' : 'none';
}

function GoTo(A){
  var title = document.title;
  var Where = A.href;
  if (Where == null || Where == '') {
    return true;
  } else {
  document.location.replace(Where);
  document.title = title;
  return false; }
}  // Go

function GoTop(){
  scrollTo(0,0);
  return false;
}  // GoTop

function isEmail(email) {
	if (email.indexOf('@') == -1 || email.indexOf('.') == -1 || email.indexOf('href') != -1) return false; else return true;
} // isEmail

function Empty(s) {
	var re = /[\s,\r,\n,\t]/g;
	if (s.replace(re, '') != '') return false; else return true;
} // Empty

function confirmDelete(msg) {
	if (msg==null) msg = 'Удалить запись';
	return confirm(msg);
} // confirmDelete

function itemWindow(id) {
	if (id != '')	window.open('/item-photo.php?id=' + id,null,'toolbar=0, location=0, menubar=0, status=1, directories=0, resizable=0, width=426, height=460');
}

function itemWindow2(id) {
	if (id != '')	window.open('/item-photo.php?series=' + id,null,'toolbar=0, location=0, menubar=0, status=1, directories=0, resizable=0, width=426, height=460');
}

function Search() {
	var Query = document.getElementById('SearchText').value;
	if (!Empty(Query) && Query != '' && Query != 'Поиск по сайту') document.getElementById('SF').submit();
}