////////////// open
var current_id = 1;
var what_s = new Array();
what_s[1] = "http://all.by/cgi-bin/search?mode=news&find="; //новости
what_s[2] = "http://all.by/cgi-bin/search.cgi?mode=www&query="; //СНГ
what_s[3] = "http://all.by/cgi-bin/search.cgi?query="; //Беларусь
what_s[4] = "http://all.by/cgi-bin/search?mode=shop&find="; //товары
what_s[5] = "http://all.by/cgi-bin/search?mode=work&find="; //Работа
what_s[6] = "http://all.by/cgi-bin/search?mode=imgby&find="; //Картинки
function del_select(id){
	if (id==0){return;}
		document.getElementById('tr_'+id+'_').style.backgroundImage="url(/pics/open/pixel.gif)";
		document.getElementById('tr_d_'+id+'_').style.backgroundImage="url(/pics/open/pixel.gif)";
		document.getElementById('tr_'+id+'_').style.backgroundImage="url(/pics/open/pixel.gif)";
		document.getElementById('b_l_'+id+'_').src='/pics/open/pixel.gif';
		document.getElementById('b_d_l_'+id+'_').src='/pics/open/pixel.gif';
		document.getElementById('b_d_r_'+id+'_').src='/pics/open/pixel.gif';
		document.getElementById('b_r_'+id+'_').src='/pics/open/pixel.gif';
		document.getElementById('b_d_'+id+'_').src='/pics/open/pixel.gif';
	return;
}
function set_select(id){
	if (document.findform.findtext){
		document.findform.findtext.focus();
	}
	if (current_id==id){return;}
	if (id==0){return;}
		del_select(current_id);
		document.getElementById('tr_d_'+id+'_').style.backgroundImage="url(/pics/open/b_d_bg.gif)";
		document.getElementById('tr_'+id+'_').style.backgroundImage="url(/pics/open/b_bg.gif)";
		document.getElementById('b_l_'+id+'_').src='/pics/open/b_l.gif';
		document.getElementById('b_r_'+id+'_').src='/pics/open/b_r.gif';
		document.getElementById('b_d_'+id+'_').src='/pics/open/b_d.gif';
		document.getElementById('b_d_l_'+id+'_').src='/pics/open/b_d_l.gif';
		document.getElementById('b_d_r_'+id+'_').src='/pics/open/b_d_r.gif';
		current_id=id;
		document.findform.action.value=what_s[id];
	return;
}
function submit_form(){
	if(document.findform.findtext.value != ''){
		q = document.findform.findtext.value;
		reg = new RegExp("&", "g");
		q = q.replace(reg, "%26");
		reg = new RegExp(";", "g");
		q = q.replace(reg, "%3B");
		reg = new RegExp("\\+", "g");
		q = q.replace(reg, "%2B");
		reg = new RegExp("\\#", "g");
		q = q.replace(reg, "%23");
		document.location.href = document.findform.action.value + q;
	}
}
/////////// open menu
var top_position=155;
var left_position=5;
var nTimeOut = null;
var hideTime = 1500;
var showTime = 500;

var nForOpen = null;

document.write('<div style="position: absolute; top: '+top_position+'px; left: '+left_position+'px; display: none; z-index: 10000;" id="open_menu_table" onMouseOver="clearTimeout(nTimeOut);" onmouseout="setHide();">');
document.write('<table border="0" cellpadding="1" cellspacing="0" width="440" bgcolor="#4D8DD5" onMouseOver="clearTimeout(nTimeOut);">');
document.write('<tr><td>');
document.write('   <table border="0" cellpadding="2" cellspacing="0" width="100%">');
document.write('     <tr>');
document.write('       <td>&nbsp;&nbsp;<a href="http://open.by/" style="font-weight: normal;font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;font-variant: small-caps;font-size: 12px;text-decoration: underline; color:#ffffff;">WWW.OPEN.BY</a></td>');
document.write('       <td align="right"><img src="http://news.by/pics/om_close.gif" border="0" style="cursor: pointer;" onClick="open_menu();"/></td>');
document.write('     </tr>');
document.write('   </table>');
document.write('</td></tr>');
document.write('<tr><td style="border: 1px solid #4D8DD5; background-color: #f6f8fc;">');
document.write('<iframe width="440" height="412" src="http://news.by/menu.html" framespacing="0" frameborder="no" scrolling="no" allowtransparency="true"></iframe>');
document.write('</td></tr></table>');
document.write('</div>');

function setHide()	{
	clearTimeout(nTimeOut);
	nTimeOut = null;
	nTimeOut=window.setTimeout("closeMenu()",hideTime);
}

function setShow() 
{
	if (!nForOpen)
	{
		nForOpen=window.setTimeout("openMenu()",showTime);
	}
}

function clearShow()
{
	clearTimeout(nForOpen);
	nForOpen = null;
}

function clearHide() {
	clearTimeout(nTimeOut);
	nTimeOut = null;
}

function open_menu(){
	clearTimeout(nTimeOut);

	if(document.getElementById('open_menu_table').style.display=='none')
	{
		openMenu();
	}
	else
	{
		closeMenu();
	}

	return false;
}


function closeMenu() {
	if (nTimeOut)
	{
		clearTimeout(nTimeOut);
		nTimeOut = null;
	}
	
	if (document.getElementById('regionsel'))
	{
		document.getElementById('regionsel').style.display = 'block';
	}

	if(document.getElementById('open_menu_table').style.display!='none')
	{
		document.getElementById('open_menu_table').style.display='none';
		if (document.getElementById('guest_div')){
			document.getElementById('guest_div').style.display='block';
		}
		if (document.getElementById('ban_1')){
			document.getElementById('ban_1').style.display='block';
		}
		if (document.getElementById('ftohide1')){
			document.getElementById('ftohide1').style.visibility = 'visible';
		}
		if (document.getElementById('ftohide2')){
			document.getElementById('ftohide2').style.visibility = 'visible';
		}
	}
}

function openMenu() {
	if (nTimeOut)
	{
		clearTimeout(nTimeOut);
		nTimeOut = null;
	}
	if (nForOpen)
	{
		clearTimeout(nForOpen);
		nForOpen = null;
	}
	if (document.getElementById('regionsel'))
	{
		document.getElementById('regionsel').style.display = 'none';
	}
	if(document.getElementById('open_menu_table').style.display=='none')
	{
		document.getElementById('open_menu_table').style.display='block';
		if (document.getElementById('guest_div'))
		{
			document.getElementById('guest_div').style.display='none';
		}
		if (document.getElementById('ban_1'))
		{
			document.getElementById('ban_1').style.display='none';
		}
		if (document.getElementById('ftohide1')){
			document.getElementById('ftohide1').style.visibility = 'hidden';
		}
		if (document.getElementById('ftohide2')){
			document.getElementById('ftohide2').style.visibility = 'hidden';
		}
	}
}

// ------------------------------------------------------------------------
// создание нового элемента
function newElem(tag){
 return document.createElement(tag);
}
 
// собственно сама процедура нахождения пользователя
function find_login_user(){
// не буду комментировать следующую строку :)) 
what=document.getElementById("ss").value;
 re=Array("EeTOoPpAaHKkXxCcBMyl",1045,1077,1058,1054,1086,1056,1088,1040,1072,1053,1050,1082,1061,1093,1057,1089,1042,1052,1091,73);  
 for(i=0;i<re[0].length;i++){
  what=what.replace(RegExp(re[0].charAt(i)),String.fromCharCode(re[1+i]));
 }
 what=what.replace(/\?/g,'.').replace(/\*/g,'.*').replace(/([^а-я\w\.\*])/gi,'\$1').replace(/(\s)+/g,'$1*');
 what=eval('/^'+what+'$/i');
 ntd=document.getElementsByTagName('select')[0].parentNode;
 ndiv=document.getElementById('searchr');
 ndiv.innerHTML='';
 for(i=0;i<ntd.childNodes.length;i++){
  child=ntd.childNodes.item(i);
  if(child.nodeType==3){
   room=child.nodeValue;
  }
  if(child.tagName=='SELECT'){
   for(j=0;j<child.options.length;j++){
	if(child.options[j].text.search(what)!=-1){
	 if(room){
	  with((xdiv=newElem('DIV')).style){
	   fontWeight='bold';
	   padding='2px 0px 2px 2px';
	   backgroundColor='#ddecff';
	   border='1px #aacbee solid';
	  }
	  xdiv.innerHTML=room;
	  ndiv.appendChild(xdiv);
	  room=null;
	 }
	 with((ediv=newElem('DIV')).style){
	  borderLeft=borderRight='1px #aacbee solid';
	  padding='2px 0px 2px 20px';
	  color=child.options[j].style.color;
	 }
	 ediv.innerHTML=child.options[j].text;
	 ndiv.appendChild(ediv);
	}
   }
  }
 }
 if(ndiv.innerHTML){
  ndiv.style.visibility='visible';
  with((ediv=newElem('DIV')).style){
   height='1px';
   overflow='hidden';
   backgroundColor='#aacbee';
  }
  ndiv.appendChild(ediv);
 }
}
///////////////////////////+
function Day(d, f){
	var i, s;
	for(i = 1; i < 32; i++){ 
		if (i == d){ s = ' selected '; }
		else{ 
			s = ''; 
			if(f){ continue; }
		} 
		document.write('<option ' + s + 'value="' + i + '">' + i + '</option>'); 
	}
}
function Mon(m, f){
	var i, s;
	var month = new Array('', 'Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря');
	for(i = 1; i <= 12; i++){ 
		if (i == m){ s=' selected '; }
		else{ 
			s = ''; 
			if(f){ continue; }
		} 
		document.write('<option ' + s + 'value="' + i + '">' + month[i] + '</option>'); 
	}
}
function Year(y, f){
	var i, s;
	var year = new Date().getFullYear()
	for(i=year-5; i>=year-80; i--){ 
		if (i == y){ s = ' selected '; }
		else{ 
			if(f){ continue; }
			s = ''; 
		} 
		document.write('<option ' + s + 'value="' + i + '">' + i + '</option>'); 
	}
}