function verifyCompatibleBrowser(){
  isDOM=(document.getElementById)?true:false
  isOpera=isOpera5=window.opera && isDOM
  isOpera6=isOpera && window.print
  isOpera7=isOpera && navigator.userAgent.indexOf("Opera 7") > 0 || navigator.userAgent.indexOf("Opera/7") >= 0
  isMSIE=isIE=document.all && document.all.item && !isOpera
  isNC=navigator.appName=="Netscape"
  isNC4=isNC && !isDOM
  isNC6=isMozilla=isNC && isDOM
  if(!isDOM && !isNC && !isMSIE && !isOpera){
  	alert('Обнаружен неподдерживаемый браузер. К сожалению этот код врядле будет работать :(');
  }
}
function show_sam(e){verifyCompatibleBrowser();if(!isMSIE){winOptions='height=600,top=50,left=50,width=800px,toolbar=no;menubar=no,location=no,directories=no,resizeable=no,scrollbars=yes';winTitle=window.open(e,'myWin',winOptions);}if(isMSIE){winOptions='top=50px;left=50px;dialogWidth=700px;dialogHeight=550px;toolbar=no;menubar=no;location=no;directories=no;resizeable=no;scrollbars=no;help=no';winTitle=window.showModalDialog(e,'myWin',winOptions);}}
function show_trans(){winOptions='height=500px,top=140,left=750,width=180px,toolbar=no,menubar=no,location=no,directories=no,resizeable=no,scrollbars=no';winTitle=window.open("trans_tab.html","myWin",winOptions);}
//function setCookie(e){
//	time=dd=mm=yy="";
//	time=new Date();
//	dd=time.getDate();
//	mm=time.getMonth()+1;
//	yy=time.getYear();
//	document.cookie=e.substring(0,e.length-5)+'='+yy+''+mm+''+dd;

//}
/*
function getCookie(Name) {
	var search = Name + "=";
	if (document.cookie.length > 0) { 
		// if there are any cookies      
		offset = document.cookie.indexOf(search)       
		if (offset != -1) { 
		// if cookie exists          
			offset += search.length          
		// set index of beginning of value         
			end = document.cookie.indexOf(";", offset)          
		// set index of end of cookie value         
			if (end == -1)          
				end = document.cookie.length         
			return unescape(document.cookie.substring(offset, end))      
		}    
	}
}

function hello(e){
	if (getCookie(e)) return (getCookie(e));
	else {
		winOptions='height=400px,width=700px,top=50,left=50,toolbar=no,menubar=no,location=no,directories=no,resizeable=no,scrollbars=no';
		winTitle=window.open("new_user.html","myWin",winOptions);
	}
}
*/

function trans(f,r,e){
/***************************************************************************/
/* Copyright (c) 2001 Artem Sapronov (www.sapronov.com)                    */
/* Thanks: Alex Volkov (www.ambience.ru) & Sergey Kruglov (www.kruglov.ru) */
/*                                                                         */
/* Вы можете свободно использовать этот скрипт не изменяя его кода и       */
/* не удаляя этой информации из него. Good luck & enjoy!                   */
/***************************************************************************/

/* 
f - имя формы
r - имя поля откуда берем текст
e - имя поля куда помещаем результат
*/
browser();
var eee=rrr=ru_littera="";next=up=ff=non=false;en_index=0;
t=document.forms[f].elements[r].value;
var non_lit="# .,123567890!@$%^&*()_+|/\\\{}[]<>;:~№";
var en_lit=["a","b","v","g","d","e","jo","zh","z","i","j","k","l","m","n","o","p","r","s","t","u","f","kh","ts","ch","sh","sc",'"',"y","'","e","ju","ja","w","ya","4"];
var ru_lit=["а","б","в","г","д","е","ё","ж","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ч","ш","щ","ь","ы","ъ","э","ю","я","в","я","ч"];
var from_ar=new Array();to_ar=new Array();
for(i=0;i<t.length;i++){
eee=t.substring(i,i+1);c=eee.charCodeAt(0);
next_1=t.substring(i,i+2).toLowerCase();
next_2=t.substring(i+1,i+2).toLowerCase();
next_34=t.substring(i+2,i+4).toLowerCase();
prev=t.substring(i-1,i).toLowerCase();
if((c>=65&&c<=90)||(c>=97&&c<=122)||(eee=="'"||eee=='"')){from_ar=en_lit;to_ar=ru_lit;}else{from_ar=ru_lit;to_ar=en_lit;}
p1=prev.charCodeAt(0);n1=next_2.charCodeAt(0);
if(eee=="4"&&non_lit.indexOf(prev)==-1&&non_lit.indexOf(next_2)==-1&&((p1>=65&&p1<=90)||(p1>=97&&p1<=122)||(p1>=65&&p1<=90)||(n1>=97&&n1<=122))){from_ar=en_lit;to_ar=ru_lit;};
if(eee.toLowerCase()!=eee)up=true;eee=eee.toLowerCase();
if(eee=="j"&&next_2=="o")next=true;
if(eee=="z"&&next_2=="h")next=true;
if(eee=="k"&&next_2=="h")next=true;
if(eee=="t"&&next_2=="s"&&next_34!="ja")next=true;
if(eee=="c"&&next_2=="h")next=true;
if(eee=="s"&&next_2=="h")next=true;
if(eee=="s"&&next_2=="c")next=true;
if(eee=="j"&&next_2=="u")next=true;
if(eee=="j"&&next_2=="a")next=true;
if(eee=="y"&&next_2=="a")next=true;
if(next){eee=next_1;i++}
if(non_lit.indexOf(eee)<0){for(ii=0;ii<from_ar.length;ii++){
if(eee==from_ar[ii]){ru_littera=to_ar[ii];ff=true;}else ff=false;ss=t.substring(i-1,i).charCodeAt(0);
if(eee=="e"&&next_2=="t"&&(non_lit.indexOf(prev)>0||!ss||ss=="10"||ss=="13"))ru_littera="э";
if(ff)ii=from_ar.length;}if(!ff)ru_littera=eee;}else{if(eee!="#")ru_littera=eee;else{xx=t.indexOf(eee,i);xxx=t.indexOf(eee,xx+1);
if(xxx>0){ru_littera=t.substring(xx+1,xxx);i=xxx;}else ru_littera=eee;}
}if(up)ru_littera=ru_littera.toUpperCase();up=false;next=false;ff=false;rrr+=ru_littera;ru_littera='';}
document.forms[f].elements[e].value="";document.forms[f].elements[e].value=rrr;}
function Paste_f(){browser();if(isMSIE5){document.forms["trans"].en_text.createTextRange().execCommand("Paste");}else{alert ('Эта функция работает только в IE 5+')};document.forms["trans"].ru_text.focus();}
function Copy_f(){browser();if(isMSIE5){document.forms["trans"].ru_text.createTextRange().execCommand("Copy");}else{ alert ('Эта функция работает только в IE 5+')};document.forms["trans"].ru_text.focus();}
function show_trans(){winOptions='height=500px,top=140,left=750,width=180px,toolbar=no,menubar=no,location=no,directories=no,resizeable=no,scrollbars=no';winTitle=window.open("../trans_tab.html","myWin",winOptions);}
function browser() {
isDOM=document.getElementById //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
isMSIE=document.all && document.all.item //Microsoft Internet Explorer 4+
isMSIE5=isDOM && isMSIE //MSIE 5+
isOpera=isOpera5=window.opera && isDOM //Opera 5+
isOpera6=isOpera && window.print //Opera 6+
isOpera7=isOpera && navigator.userAgent.indexOf("Opera 7") > 0 || navigator.userAgent.indexOf("Opera/7") >= 0 //Opera 7
isNetscape4=document.layers //Netscape 4.*
isMozilla=isNetscape6=isDOM && (navigator.appName=="Netscape")//Mozilla или Netscape 6.*
}
//Script from tema.ru
document.onkeydown=NavigateThrough;
function NavigateThrough (event) {
	if(!document.getElementById) return;
	if(window.event) event=window.event;
	if(event.ctrlKey){
		var link=null;
		var href=null;
		switch(event.keyCode?event.keyCode:event.which?event.which:null){
			case 0x25:
				link=document.getElementById('NextLink');
				break;
			case 0x27:
				link=document.getElementById('PrevLink');
				break;
			case 0x26:
				link=document.getElementById('UpLink');
				break;
			case 0x28:
				link=document.getElementById('DownLink');
				break;
		}
		if(link&&link.href)document.location=link.href;
		if(href)document.location=href;
	}			
}

function setCookie(n,v,t){if(t>0){var expDate=new Date();expDate.setTime(expDate.getTime()+t*1000*60*60*24);var expires=expDate.toGMTString();document.cookie=n+"="+escape(v)+"; path="+escape('/')+"; expires="+expires;}else{document.cookie=n+"="+escape(v)+"; path="+escape('/')+"";}}
function getCookie(n){var oC=document.cookie;if(!oC||oC=="")return "";oC=oC.split(";");var i=0;var Co;while(i<oC.length){Co=oC[i].split("=")[0];if(Co.charAt(0)==" ") {Co=Co.substring(1)}if(Co==n){return unescape(oC[i].split("=")[1])}i++;}return "";}
function addopload(){} // BODY onload
function selectlabel(e) { //Функция реагирования на подписи к флажкам, как если бы кликать прямо на них.
	inputname=e.substring(0,e.length-5); //Отделяем имя флажка от имени метки
	style=document.getElementById(inputname);
	if (style.checked) {//Проверяем состояние флажка
		style.checked=false;//Если установлен - снимаем
	} else {
		style.checked=true;//Если снят - устанавливаем
	};
	gen_search_check (inputname);
}

function gen_search_check(e) { // Функция проверки данных в форме поиска однофамильцев
	if (document.getElementById(e).checked) {//Проверяем состояние флажка
		document.getElementById(e+'_sel').disabled=false;// Если установлен - снимаем disabled с соответсвующего селекта
		if (e=="f_name") {
			document.getElementById("m_name_sel").disabled=true;
			document.getElementById("m_name_all").disabled=true;
			document.getElementById("m_name_all").checked=false;
			document.getElementById("f_name_all").disabled=false;
		}
		if (e=="m_name") {
			document.getElementById("f_name_sel").disabled=true;
			document.getElementById("f_name_all").disabled=true;
			document.getElementById("f_name_all").checked=false;
			document.getElementById("m_name_all").disabled=false;
		}
	} else {
		document.getElementById(e+'_sel').disabled=true;//Если снят - устанавливаем disabled на соответсвующий селект
		if (e=="f_name") {
			document.getElementById("m_name_sel").disabled=false;
			document.getElementById("m_name_all").disabled=false;
			document.getElementById("m_name_all").checked=true;
		}
		if (e=="m_name") {
			document.getElementById("f_name_sel").disabled=false;
			document.getElementById("f_name_all").disabled=false;
		}
	}
}

function name_sel_all(e) { // Функция реакции на установку флага всех имен
	inputname=e.substring(0,6); //Отделяем имя флажка от имени метки
	if (document.getElementById(e).checked) {
		document.getElementById(inputname+'_sel').disabled=true;
	} else {
		document.getElementById(inputname+'_sel').disabled=false;
	}
}

function dis_all() {
	fieldsID=["m_name","m_name_all","m_name_sel","f_name","f_name_all","f_name_sel","cb","cb_sel","cl","cl_sel","sbmt_form"];
	for (i=0; i<fieldsID.length; i++) {
		document.getElementById(fieldsID[i]).disabled=true;
	}
}
