
// Книгообеспеченность в режиме заказа на комплектование

function change_disc(val){
// Очистить запрос дисциплин
gid('svd').src='';
gid('step3').style.display="none";
gid("fieldsp").innerHTML='';

if (val){ 
  gid('step2').style.display="";
  gid('discs').src=irbis_no_mnu+'&I21DBN=VUZ&I21DBNAM=VUZ&S21CNR=999&C21COM=S&S21FMT=komplzakdd&S21COLORTERMS=0&S21ALL=(<.>KAFCH='+val+'<.>)';
}else{ 
	gid('step2').style.display="none";
	gid('discs').src='';
	

		}
}







function prepare_disc(){
integrator='';
requestd='';
fieldsp=parent.gid("fieldsp");
sp_obj=new Array();
if (document.fil_form['IDD'] && !document.fil_form['IDD'].length) sp_obj[0]=document.fil_form['IDD'];
else sp_obj=document.fil_form['IDD'];

	for (k=0;k<sp_obj.length;k++){
	  if (sp_obj[k].checked){
	  requestd+=integrator+'<.>IDV='+toURI(sp_obj[k].value)+'<.>';
	  integrator='%2B';	
	  }
	}

fieldsp.innerHTML='';
if (requestd){
 parent.gid('step3').style.display="";
 parent.gid('svd').src=irbis_no_mnu+'&I21DBN=VUZ&I21DBNAM=VUZ&S21CNR=999&C21COM=S&S21FMT=komplzakddl&S21COLORTERMS=0&S21ALL='+requestd;
}else{
 parent.gid('step3').style.display="none";
 parent.gid('svd').src='';
 }
}



function write_fields(){
rec_fields='';
d=0;
fieldsp=parent.gid("fieldsp");
sp_obj=new Array();
if (document.fil_form['IDU'] && !document.fil_form['IDU'].length) sp_obj[0]=document.fil_form['IDU'];
else sp_obj=document.fil_form['IDU'];

	for (i=0;i<sp_obj.length;i++){
	  if (sp_obj[i].checked){
	  d++;
	  rec_fields+='<input type="hidden" name="K_R21NUM'+d+'" value="691">\n'+'<input type="hidden" name="K_R21VOL'+d+'_1" value="'+sp_obj[i].value+'">\n';
	  }
	}

if (rec_fields){
 fieldsp.innerHTML=rec_fields;
 //alert(rec_fields);
}else
	
 fieldsp.innerHTML='';

}



function preload(img){
img_n=img.split(";");
img_obj=new Array();
for(i=0; i<img_n.length; i++){
img_obj[i]=new Image;
img_obj[i].src=irbis_httpj+"/images/"+img_n[i];}
}






function request_decrypt(request){
pref=new Array();
pref[0]=new Array('T=','ЗАГЛАВИЕ','ЗАГЛАВИЯ');
pref[1]=new Array('D=','ДИСЦИПЛИНА','ДИСЦИПЛИНЫ');
pref[2]=new Array('SP=','СПЕЦИАЛЬНОСТЬ','СПЕЦИАЛЬНОСТИ');
pref[3]=new Array('A=','АВТОР','АВТОРЫ');
pref[4]=new Array('T=','ЗАГЛАВИЕ','ЗАГЛАВИЯ');
pref[5]=new Array('K=','КЛЮЧЕВЫЕ СЛОВА','КЛЮЧЕВЫЕ СЛОВА');
pref[6]=new Array('O=','ИЗДАТЕЛЬСТВО','ИЗДАТЕЛЬСТВА');
pref[7]=new Array('G=','ГОД ИЗДАНИЯ','ГОДЫ ИЗДАНИЯ');
pref[8]=new Array('R=','РУБРИКА','РУБРИКИ');
pref[9]=new Array('V=','ВИД ИЗДАНИЯ','ВИДЫ ИЗДАНИЯ');
pref[10]=new Array('HD=','ХАРАКТЕР ДОКУМЕНТА','ХАРАКТЕРЫ ДОКУМЕНТА');
pref[11]=new Array('MHR=','МЕСТО ХРАНЕНИЯ','МЕСТА ХРАНЕНИЯ');
pref[12]=new Array('I=','СИСТЕМНЫЙ ШИФР','СИСТЕМНЫЕ ШИФРЫ');
pref[13]=new Array('TJ=','ЗАГЛАВИЕ СТАТЬИ','ЗАГЛАВИЯ СТАТЕЙ');
pref[14]=new Array('VR=','ВИД ДОКУМЕНТА','ВИДЫ ДОКУМЕНТОВ');
pref[15]=new Array('KAF=','КАФЕДРА','КАФЕДРЫ');
integrator2='';
prf_last='';
multi=request.split('*');
for(i in multi){
	addi=multi[i].split('+');
	prf_find=false;
	for(d in pref){	
		if (multi[i].indexOf(pref[d][0])>0){
			prf_decript=(addi.length>1) ? pref[d][2]+': ' : pref[d][1]+': ';
			prf_decript=(prf_last!=pref[d][0]) ? prf_decript : '';
			document.writeln(integrator2+'<b>'+prf_decript+'</b>');	
			integrator2='<b> И </b>'
			prf_find=true;
			prf_last=pref[d][0];
			break;
		}		
	}
	
	if (prf_find){
		integrator='';
		for(k in addi){	
		document.writeln(integrator+'"'+addi[k].replace(/(.*=)|(\<\.\>)|(\))|\$|(\/\(.*\))/g,'')+'"');	
		integrator='<b> ИЛИ </b>';
		}
	}
}

}





function fel(arr,el){
	for(c in arr){
		if (arr[c]==el) return c;
	
	}
return false;
}



function author_process(send_form){
 
ua=navigator.userAgent;
msie5 = (ua && ( parseFloat(navigator.appVersion)==4) && (ua.indexOf("Opera") < 0 ) && (
ua.indexOf("MSIE 5") > 0 ));

at=document.mainsearch.A_S21STR;
pm=document.mainsearch.A_S21P01;
inn=document.getElementById("a_comm");
inn.innerHTML="";

if (at.value && !msie5 && (!pm.value || send_form) ) {
	
	pm.value=(send_form)? 'SF' : "1";
	na='';
	mode='';
	tmp=at.value.replace(/(\.|\s|^)([A-zА-я])/g, upper_reg);
	at.value=''; // Требуется только для корректной работы в Opera 7.5
	at.value=tmp;


	 if((n=find_inn(at.value))){
	    mode=(n[1].length>1 || n[2].length>1) ? '1' : ''; 
			na=n[0]+', '+n[1].charAt(0)+'.';
			na+=(n[2]) ? ' '+n[2].charAt(0)+'.' : '';
	 }

    var scr=document.createElement('script');
		scr.type = 'text/javascript';
		scr.src = irbis_no_mnu+"&C21COM=F&I21DBN=AT_JS&I21DBNAM="+realbase+"&AUTORO="+toURI(at.value)+"&AUTORN="+toURI(na)+"&MODE="+mode+'&no_html=1';
		document.getElementsByTagName('body').item(0).appendChild(scr);  
		

 } else {if (msie5) pm.value="1"; if (send_form) document.mainsearch.submit();}

}



function reader_flk(){
mf=document.make_reader;
var mes="";
if (!mf.R_R21VOL1_1.value) mes="Фамилия";
if (!mf.R_R21VOL2_1.value) mes="Имя";
if (!mf.R_R21VOL3_1.value) mes="Отчество";
//if (!mf.R_R21VOL10_1.value) mes="E-Mail";
if (mes) {alert("Поле "+mes+"  является обязательным для заполнения"); return false;}
else 
	return true;

}

function find_inn(author){
re=new RegExp("(?:([A-zА-я\-]+)\,? ([A-zА-я\-]*)\.? ?([A-zА-я\-]*)\.?)|(?:([A-zА-я\-])\. ?([A-zА-я]?)\.? ([A-zА-я\-]+))");
return (re.exec(author)) ? new Array(RegExp.$1+RegExp.$6,RegExp.$2+RegExp.$4,RegExp.$3+RegExp.$5) : null;
}

function upper_reg($0,$1,$2){
	sp=($1=='.')? $1+' ' : $1;
	return sp+$2.toUpperCase();
}




function toURI(str){
l="АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯЁ ,.абвгдежзийклмнопрстуфхцчшщъыьэюяё+(<.>)";    
     
  lDec="C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF A8 20 2C 2E E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF B8 2B 28 3C 2E 3E 29".split(" ");	for (newstr='',j=0;j<str.length;j++) {
		for (i=0;i<l.length;i++) {
		  if (l.charAt(i)==str.charAt(j)) break;
		}
	 newstr+=(l.length>i) ? '%'+lDec[i] : str.charAt(j);
	}
return newstr;
}

function account_add(account,addition){
return Number(document.getElementById(addition).value)+Number(account)+0;
}





function resize_win2(win_table){
//outerWidth - не работает в Explorer
//window.screen.availHeight - недостаточно точное значение
//screenX - расстояние от левого угла
//window.document.body.clientWidth
//document.body.offsetHeight
// document.body.clientHeight -- текущее значение, учитывая размер окна
x=(window.innerWidth) ? window.innerWidth : window.document.body.clientWidth;
y=(window.innerHeight) ? window.innerHeight : window.document.body.clientHeight;


hscreen=window.screen.availHeight;
wscreen=window.screen.availWidth;



tblh=gid(win_table).clientHeight;
//nnn=gid(win_table).innerHeight;


ua=navigator.userAgent;
opera7 = (ua && (ua.indexOf("Opera") > 0 ));
msie7 = (ua.indexOf("MSIE 7.") > 0 && !opera7);
msie = (ua.indexOf("MSIE 6.") > 0 && !opera7);
mozilla = (ua.indexOf("Firefox") > 0 );


if (!msie7 && !msie) mozpos=20; else mozpos=0;

	if (tblh){
		 newy=((tblh+20)>hscreen) ? hscreen-150 : tblh+mozpos;
			 window.moveTo((wscreen/2)-(x/2),(hscreen/2)-(newy/2));
	      if (!msie7) 
	      	window.resizeBy(0,newy-y);		
	      else 		{			 
				  window.resizeTo(gid(win_table).clientWidth+22,gid(win_table).clientHeight+80);
				}

	}
}


 
function print_list(){
		document.getElementById('print_button').style.display="none";
		window.print();
		document.list_form.submit();
}


function make_win(mode,par,waiting){
	cmd_str=new Array();
	cmd_str[3]= new Array('Предварительный_заказ_на_абонементе',irbis_no_mnu+'&I21DBN=AB_ZAK&I21DBNAM='+realbase+'&C21COM=F&Z21MFN='+par[0]+ident,"status=no,location=no,directories=no,toolbar=no,resizable=yes",630,250);
	cmd_str[7]= new Array('Печать_записей',irbis_no_mnu+'&I21DBN='+par[0]+'_PRINT&S21FMT='+par[1]+'&S21CNR=500&S21COLORTERMS=0&C21COM=S&S21SRW='+par[2]+'&S21ALL='+par[3]+'&SAME_SEARCH='+par[4]+ident,"status=no,location=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes",620,440);
	cmd_str[8]= new Array('Удаление_записи',irbis_no_mnu+'&I21DBN='+par[0]+'_DEL&C21COM=R&P_R21IFP=1&P_R21UPD=2&P_R21MFN='+par[1]+ident,"status=no,location=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes",200,200);


	x=cmd_str[mode][3];
	y=cmd_str[mode][4];
	cx=screen.width/2-(x/2);
	cy=screen.height/2-(y/2);
	adr=(waiting) ? '' : cmd_str[mode][1]; 	
	var load_window=window.open(adr,cmd_str[mode][0],cmd_str[mode][2]+',width='+x+',height='+y+',top='+cy+',left='+cx); 
 load_window.focus();

	if (load_window == null) {
        alert('Отключите блокировку всплывающих окон в своём браузере! Всплывающие окна необходимы для корректной работы сайта!');
	return;
	}

  
  if (waiting){
	  load_window.document.writeln('<html><body><div style="position: absolute;width:100%; height:100%; z-index:0;" id="progress_bar" ><table  style="width:100%; height:100%;"><tr><td align=center><div style="background-color: white"><table style="border: 4px double black; background-color: white"><tr><td align=center ><span style="font-size: 11pt; margin:10px; font-weight:bold">Ждите... '+waiting+'</span><br><img src="{httpjpath}/images/progbar.gif"></td></tr></table></div></td></tr></table></div></body></html>');
		load_window.document.location=cmd_str[mode][1];
  }
  
}

	



function reload_search_rez(){
  if (opener){
	rez_form=opener.document.go_reference;
		if (rez_form){
			rez_form.S21STN.value=rez_form.STN_BACK.value; 
			rez_form.submit();
		}	
	}
}


function s_by_req(my_req) {
 document.go_reference.SAME_SEARCH.value='';
 document.go_reference.S21ALL.value=my_req;
 document.go_reference.submit();
}

function fulltext_search(my_req) {
 document.go_reference.S21ALL.value='';
 document.go_reference.S21SRW.value='';
 document.go_reference.S21STN.value='1';
 document.go_reference.SAME_SEARCH.value='1';
 document.go_reference.FT_REQUEST.value=my_req;
 document.go_reference.submit();
}


function another_base_search(base) {
 document.go_reference.I21DBN.value=base;
 document.go_reference.I21DBNAM.value=base;
 document.go_reference.submit();
}

function change_sort(stw_name){
 document.go_reference.S21SRW.value=stw_name;
 document.go_reference.S21STN.value='1';
 document.go_reference.submit();
}

function s_by_term(prf,term) {
 document.go_reference.SAME_SEARCH.value='';
 document.go_reference.S21ALL.value="(<.>"+prf+term+"<.>)";
 document.go_reference.submit();
}




function copy_search_term(){
document.gsearch.T21TRM.value=document.gsearch.S_DIC_TERM.value;
}

function SSForm(r_number){
if (document.go_reference.MFN && document.go_reference.SEL_MFN) print_bo();
document.go_reference.S21STN.value=r_number;
//Страховка от проблем при history back, связанных с динамической модификацией поля 
if (document.go_reference.REQ_BACK) document.go_reference.S21ALL.value=document.go_reference.REQ_BACK.value; 
document.go_reference.submit();
}


function rub_s(my_req) {
 req_parts=my_req.split('@');
 document.rub_mainsearch.S21ALL.value='<.>'+req_parts[0]+'<.>';
 document.rub_mainsearch.S21FMT.value=req_parts[1];
 if (!req_parts[2]){

	 document.rub_mainsearch.I21DBN.value=document.rub_keywordssearch.I21DBN.value;
	 document.rub_mainsearch.I21DBNAM.value=document.rub_keywordssearch.I21DBNAM.value;
	}
 document.rub_mainsearch.submit();
}

function hyper_numbers(code, numbers_string){
numbers=numbers_string.split('*');
numbers.sort(my_sort);
hyper1='<a href="javascript: s_by_term('+"'I=','"+code+'/';
hyper2="')"+'" title="Переход к описанию номера журнала">';

 for(ytemp='',yr='',i=0;i<numbers.length;i++,yr=''){
	
	y=numbers[i].substring(0,4);
	n=numbers[i].substring(5);
	
		if (y!=ytemp){	
			yr='<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+hyper1+y+'$'+hyper2+y+'</a>: ';
			ytemp=y;
		}

 nr=hyper1+numbers[i]+hyper2;
 document.write(yr+nr+n+'</a> ');
   
 }
}

function my_sort(n1,n2){
	return (n_conv(n1)>n_conv(n2)) ? 1 : -1;
}

function n_conv(str){
re=new RegExp("([0-9]{4})\/([0-9]+)");
return (re.exec(str)) ? Number(RegExp.$1+'000')+Number(RegExp.$2) : null;
}



function hs_obj(hide_show_par,obj_id){
		document.getElementById(obj_id).style.display=(hide_show_par==0) ? "none" : "" ;		
}


function author_field(author){
 na='';
	 if (author){
		 author=author.replace(/(\.|\s|^)([A-zА-я])/g, upper_reg);
		 
		 if((n=find_inn(author))){
				na=n[0]+' '+n[1].charAt(0)+'.';
				na+=(n[2]) ? ' '+n[2].charAt(0)+'.' : '';
		 }
	}
	return na;
}

function make_bo_submit_ed(){
	mf=document.make_bo;
	if (mf.R_R21VOL1_1.value) mf.R_R21NUM1.value="702";
	/*if (mf.R_R21VOL2_3.value){	
		mf.R_R21VOL5_1.value="SPEC";
		mf.R_R21NUM2.value="461";
		mf.R_R21SUB2_1.value="C";
		mf.R_R21VOL2_1.value+="^D"+mf.R_R21VOL3_1.value+"^G"+mf.R_R21VOL3_2.value+"^H"+mf.R_R21VOL3_3.value;
		
		mf.R_R21VOL3_1.value="";
		mf.R_R21VOL3_2.value="";
		mf.R_R21VOL3_3.value="";
	}*/
	var mes="";
	if (!mf.R_R21VOL3_3.value) mes="Год";
	if (!mf.R_R21VOL2_1.value) mes="Заглавие";
	if (mes) {
		alert("Поле "+mes+"  является обязательным для заполнения"); return false;
}else{
	mf.R_R21VOL1_2.value=author_field(mf.R_R21VOL1_2.value);
	return true;
}

}


function print_bo(sel_type){

var terms=document.go_reference.SEL_MFN.value.split(" ");
if (document.go_reference.MFN){
	
	if (!document.go_reference.MFN.length && document.go_reference.MFN){
		terms[terms.length+1]=document.go_reference.MFN.value;
	}else{
		for (i=0,d=0; i<document.go_reference.MFN.length; i++){ 
		  if (document.go_reference.MFN[i].checked){ 
		   terms[terms.length+(d++)]=document.go_reference.MFN[i].value;
		  }
		}
	}
	
}

if (document.go_reference.SAME_SEARCH) full_search=document.go_reference.SAME_SEARCH.value;
if ((sel_type=="2"||sel_type=="3") && !terms.join()) alert("Для выбранного режима печати требуется отобрать записи"); 
 else{
	if (sel_type){
	 s_expression="";
	 if (sel_type=="1"){
	  s_expression=document.go_reference.SEL_ALL.value;
	} else {
	 integrator="%2B";
	 if (sel_type=="3"){
	 	s_expression=document.go_reference.SEL_ALL.value; 
	 	integrator="^";
		if (document.go_reference.SAME_SEARCH.value){
			alert("В режиме ранжированного поиска исключение записей из списка печати невозможно!"); 
			return;
		}
	 }
	  for(i=0; i<terms.length; i++){
	  	if(terms[i]) s_expression+=integrator+"<.>MFN="+terms[i]+"<.>";
	  }  
	  full_search='';
   }
   
	
	make_win(7,[document.go_reference.I21DBNAM.value,document.go_reference.PRINT_FORMAT.value,'avhead',s_expression,full_search]);

	}else{
   document.go_reference.SEL_MFN.value=terms.join(" ");
	}
}


}



function make_bo_submit(){
mf=document.make_bo;
if (mf.R_R21VOL1_1.value) mf.R_R21NUM1.value="702";
var mes="";
if (!mf.R_R21VOL3_3.value) mes="Год";
if (!mf.R_R21VOL2_1.value) mes="Заглавие";
if (!mf.R_R21VOL4_2.value) mes="Книжный магазин";
if (!mf.R_R21VOL3_2.value) mes="Издательство";
if (mes) {alert("Поле "+mes+"  является обязательным для заполнения"); return false;}
}


function ChangeStyle(cur_element,mode){


myel=gid(cur_element.id+"T").style;
mhelp=(gid(cur_element.name+"D"))? gid(cur_element.name+"D").style : null;
//document.activeElement и tagName - в Mozilla всегда false. Не работает.
field_true=(cur_element.id.slice(0,1)=='F');
	if (mode=="1" && field_true){	
		
		
			for(i=1;gid('F'+i+'T');i++){
				gid('F'+i+'T').style.backgroundColor = "";
				gid('F'+i+'T').style.border = "";
					for(d=1;gid('R_R21VOL'+i+'_'+d+'D');d++){
			    	gid('R_R21VOL'+i+'_'+d+'D').style.display="none";
					}
			}	

		myel.backgroundColor = "#FFD7E0"
		myel.border = "2px solid Black"
		if (mhelp) mhelp.display=""
	
	
	}

}


function gid(element_id){
return document.getElementById(element_id);
}


function ActiveKey(){
if (!document.activeElement && document.mainsearch && window.event){
	if (window.event.keyCode==1072) {document.mainsearch.A_S21STR.focus(); 
		document.activeElement.value="";}
	if (window.event.keyCode==1079) document.mainsearch.T_S21STR.focus();
	if (window.event.keyCode==1102) document.mainsearch.K_S21STR.focus(); 
}
else{ 
if (window.event){
	if (window.event.keyCode==27 && document.mainsearch) document.mainsearch.reset();
	if (window.event.keyCode==1087 && (!document.activeElement || document.activeElement.tagName!="INPUT")) document.location=irbis_no_mnu+"&C21COM=F&I21DBN="+realbase+"_PROF&I21DBNAM="+realbase;
}
//alert(document.activeElement.tagName);
//alert(window.event.keyCode);
}
}	

function PasteLogic(log){
ms=document.mainsearch;
if (ms.TRUNCATION.checked) rs="$";  else rs="";
if (!ms.S21ALL.value) log="";
if (ms.USER_TERM.value)  ms.S21ALL.value+= log +"(<.>"+ ms.PREFIX.value + ms.USER_TERM.value + rs+"<.>)";
ms.USER_TERM.value = "";
}


function reset_search_arrow(){
 if (document.getElementById("search_arrow")){ 
       document.getElementById("search_arrow").style.top = document.body.scrollTop+300+"px"; 
// scrollTop+300; не действует в Mozille
 }
}



function show_hide(layer){
  if (document.getElementById(layer).style.display=="none"){
    document.getElementById(layer).style.display=""; 
  if (document.getElementById("img_"+layer)) 
    document.getElementById("img_"+layer).src=irbis_httpj+"/images/arrow_up.gif"; 
  return 1;
  } 
else 
 {document.getElementById(layer).style.display="none"; 
  if (document.getElementById("img_"+layer)) 
   document.getElementById("img_"+layer).src=irbis_httpj+"/images/arrow_down.gif";
  return 0;}
}


function tune_search(layer,row){
 document.cookie=layer+"="+ show_hide(layer)+"; expires=Thu, 01-Jan-10 00:00:01 GMT";
}



function getCookie(name) {
 var prefix = name + "="
 var cookieStartIndex = document.cookie.indexOf(prefix)
  if (cookieStartIndex == -1) return null;
     var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
     if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length
     return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}



function restore_interface(){
 for (i=1;document.getElementById("sh"+i);i++){
   if (getCookie("sh"+i)=="0") show_hide("sh"+i);
 }
}





//Открывает словарь с указанным префиксом во всплывающем окне
function OpenDic(prf) {
y=530;
x=486;
cx=screen.width/2-(x/2);
cy=screen.height/2-(y/2)-30;



if (document.mainsearch.VBASE.value)

	rstring=irbis_no_mnu+'&I21DBN='+document.mainsearch.I21DBNAM.value+'&I21DBNAM='+document.mainsearch.I21DBNAM.value+'&S21ALL=(<.>VB='+document.mainsearch.VBASE.value+'<.>)&T21PRF='+prf+'&T21CNR=20&C21COM=T';
	else 
	rstring=irbis_no_mnu+'&I21DBN='+document.mainsearch.I21DBNAM.value+'&I21DBNAM='+document.mainsearch.I21DBNAM.value+'&T21PRF='+prf+'&T21CNR=20&C21COM=T';
 

	var dic =window.open(rstring,'Dictionary','width='+x+',height='+y+',scrollbars=no,resizable=no,top='+cy+',left='+cx); 
	dic.focus();
}


function alphabet(){
	var letters="АБВГДЕЖЗИКЛМНОПРСТУФХЦЧШЩЭЮЯ123456789";
	var lettersDec="%C0 %C1 %C2 %C3 %C4 %C5 %C6 %C7 %C8 %CA %CB %CC %CD %CE %CF %D0 %D1 %D2 %D3 %D4 %D5 %D6 %D7 %D8 %D9 %DD %DE %DF 1 2 3 4 5 6 7 8 9".split(" ");
	for (var i=0;i<letters.length;i++) {
	  document.writeln("<a href="+irbis_no_mnu+"&I21DBN="+document.gsearch.I21DBNAM.value+"&I21DBNAM="+document.gsearch.I21DBNAM.value+"&S21ALL="+toURI(document.gsearch.S21ALL.value)+"&S21FMT=fullwebr&T21PRF="+document.gsearch.T21PRF.value+"&T21CNR=20&T21TRM="+lettersDec[i]+"&S_DIC_TERM="+lettersDec[i]+"&C21COM=T' onclick='process_ind()'>" +letters.charAt(i)+"</a>"  )
	}
}




//Запускается при щелчке на термине словаря. 
//Формирует поисковое выражение и инициирует поиск
function lm(term) {
 msf=opener.document.mainsearch;
 msf.S21ALL.value="(<.>"+document.gsearch.T21PRF.value+term+"<.>)";
 msf.submit(); 
 self.close();
}

//Конструирует поисковое выражение из отмеченных терминов и префиксов
function addsearch(){
if (document.gsearch.T21CHK){
var integrator="";
var prf;
var s_expression="";

var terms=opener.document.mainsearch.S21ALL.value.split("<.>");
for (i=0; i<document.gsearch.T21CHK.length; i++){ 
  if (document.gsearch.T21CHK[i].checked){ 
  terms[i+terms.length]=document.gsearch.T21PRF.value+document.gsearch.T21CHK[i].value;
  }
}

terms.sort();
 
for(i=0; i<terms.length; i++){
if (terms[i]){ 
  if (terms[i].indexOf("=")>0){
    if (prf){ if (terms[i].indexOf(prf[0]+"=")<0) integrator=")*(";}
    s_expression+=integrator+"<.>"+terms[i]+"<.>";
    prf=terms[i].split("=");
    integrator="%2B";
   }
  }
}

if (s_expression)  s_expression= "("+s_expression+")";
opener.document.mainsearch.S21ALL.value=s_expression;
}
}




