// JavaScript Document
var res_alpha=true; // глобалка для validate
function validate_alpha2(id_in){ // допустимы только русские буквы, дефис и пробел или пустая строка
	document.res_alpha=true;
	
	test_value = document.getElementById(id_in).value;
	test_value = test_value.trim(); // удаляем начальные и конечные пробелы
	
	if (test_value.length ==0){return;} // нет данных
	
	if(test_value.search(/^[А-Яа-я]/) <0){ // проверка - в начале слова - Русская буква
	document.res_alpha=false;
	}
	if(test_value.search(/[^(А-Яа-я\-\s)]/) >=0){ //есть что-то, кроме разрешенного
	document.res_alpha=false;
	}
	if(test_value.search(/[А-Яа-я]$/) <0){ // проверка - в конце слова - буква
	document.res_alpha=false;
	}
	if(!document.res_alpha){
	window.alert("Допустимы только русские буквы, дефис и пробел!");
	document.getElementById(id_in).focus();}
	return;
} // end function validate_alpha2

function validate_alpha(id_in){ // допустимы только русские буквы и дефис или пустая строка
	document.res_alpha=true;
	
	test_value = document.getElementById(id_in).value;
	test_value = test_value.trim(); // удаляем начальные и конечные пробелы
	
	if (test_value.length ==0){return;} // нет данных
	
	if(test_value.search(/^[А-Яа-я]/) <0){ // проверка - в начале слова - буква
	document.res_alpha=false;
	}
	if(test_value.search(/[^(А-Яа-я\-)]/) >=0){ //есть что-то, кроме разрешенного
	document.res_alpha=false;
	}
	if(test_value.search(/[А-Яа-я]$/) <0){ // проверка - в конце слова - буква
	document.res_alpha=false;
	}
	if(!document.res_alpha){
	window.alert("Допустимы только русские буквы и дефис!");
	document.getElementById(id_in).focus();}
	return;
} // end function validate_alpha

function validate_year(id_in){ // допустимы только четыре цифры года (от 1800 до 2007) или пустая строка
tst_year = 0;
document.res_alpha=true;
if (document.getElementById(id_in).value.length ==0){return;} // нет данных
if(document.getElementById(id_in).value.search(/^(\d{4})/)< 0){ //
document.res_alpha=false;
} else {
tst_year = parseInt (document.getElementById(id_in).value);
}
if(tst_year<1800 || tst_year>2007){
document.res_alpha=false;
}
if(!document.res_alpha){
window.alert("Допустимы только четыре цифры года (от 1800 до 2007)!");
document.getElementById(id_in).focus();
}
return;
} // end function validate_year

function reset_search(){  // сброс формы поиска
document.getElementById("s_family").value="";
document.getElementById("s_name").value="";
document.getElementById("s_otch").value="";
document.getElementById("year1").value="";
document.getElementById("year2").value="";
document.getElementById("s_b_place").value="";
document.getElementById("kriterii").value="1";
//document.all["s_nath"].value="";
document.getElementById("s_ar_place").value="";
document.getElementById("ar_year1").value="";
document.getElementById("ar_year2").value="";
}

function validate_search(){ // проверка формы (есть ли критерии отбора?
document.res_alpha=false;
if (document.getElementById("s_family").value.length > 0){document.res_alpha=true;}
if (document.getElementById("s_name").value.length > 0){document.res_alpha=true;}
if (document.getElementById("s_otch").value.length > 0){document.res_alpha=true;}
if (document.getElementById("year1").value.length > 0){document.res_alpha=true;}
if (document.getElementById("year2").value.length > 0){document.res_alpha=true;}
if (document.getElementById("s_b_place").value.length > 0){document.res_alpha=true;}
//if (document.all["s_nath"].value.length > 0){document.res_alpha=true;}
if (document.getElementById("s_ar_place").value.length > 0){document.res_alpha=true;}
if (document.getElementById("ar_year1").value.length > 0){document.res_alpha=true;}
if (document.getElementById("ar_year2").value.length > 0){document.res_alpha=true;}
if(!document.res_alpha){
window.alert("Не заданы критерии отбора!");
document.getElementById("s_family").focus();
}
} // end function validate_search()

function show_page(numpage){
document.getElementById("form_search").out_page.value = ""+numpage;
document.getElementById("form_search").submit();
}

