// JavaScript Document

function s(x,p) {
	dom='/cgi-bin/fs.cgi?mode=d&dom=';
	page='/cgi-bin/fs.cgi?mode=p&dom=';
	if(p==0)	x=dom+x;
	if(p==1)	x=page+x;
	open(x,null,"WIDTH=500,HEIGHT=400,toolbar=yes,menubar=no,resizable=yes,scrollbars=yes");
}

function st(id) {
	url='/cgi-bin/st_r.cgi?id='+id;
	open(url,null,"left=10,top=10,WIDTH=750,HEIGHT=450,toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes");
}

function checkempty() {
	if (document.searchform.query.value == "") {
		alert("Не могу выполнить пустой запрос!");
		return false;
	} else { return true; }
}

function check200() {
	if (document.addform.descr.value.length >250) {
		alert('Превышен предел 250 символов!');
		return false;
	} else { return true; }
}

function checkempty1() {
	if (document.searchform1.query.value == '') {
		alert('Не могу выполнить пустой запрос!');
		return false;
	} else { return true; }
}

function checkempty2() {
	if (document.searchform2.query.value == '') {
		alert('Не могу выполнить пустой запрос!');
		return false;
	} else { return true; }
}
////////////// open
var current_id = 1;
var what_s = new Array();
what_s[1] = "http://all.by/cgi-bin/search.cgi?query="; //Беларусь
what_s[2] = "http://all.by/cgi-bin/search.cgi?mode=www&query="; //СНГ
what_s[3] = "http://all.by/cgi-bin/search?mode=news&find="; //новости
what_s[4] = "http://all.by/cgi-bin/search?mode=shop&find="; //товары
what_s[5] = "http://all.by/cgi-bin/search?mode=work&find="; //Работа
function del_select(id){
	if (id==0){return;}
		document.getElementById('tr_'+id+'_').style.backgroundImage="url(http://all.by/pics/open/pixel.gif)";
		document.getElementById('tr_d_'+id+'_').style.backgroundImage="url(http://all.by/pics/open/pixel.gif)";
		document.getElementById('tr_'+id+'_').style.backgroundImage="url(http://all.by/pics/open/pixel.gif)";
		document.getElementById('b_l_'+id+'_').src='http://all.by/pics/open/pixel.gif';
		document.getElementById('b_d_l_'+id+'_').src='http://all.by/pics/open/pixel.gif';
		document.getElementById('b_d_r_'+id+'_').src='http://all.by/pics/open/pixel.gif';
		document.getElementById('b_r_'+id+'_').src='http://all.by/pics/open/pixel.gif';
		document.getElementById('b_d_'+id+'_').src='http://all.by/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(http://all.by/pics/open/b_d_bg.gif)";
		document.getElementById('tr_'+id+'_').style.backgroundImage="url(http://all.by/pics/open/b_bg.gif)";
		document.getElementById('b_l_'+id+'_').src='http://all.by/pics/open/b_l.gif';
		document.getElementById('b_r_'+id+'_').src='http://all.by/pics/open/b_r.gif';
		document.getElementById('b_d_'+id+'_').src='http://all.by/pics/open/b_d.gif';
		document.getElementById('b_d_l_'+id+'_').src='http://all.by/pics/open/b_d_l.gif';
		document.getElementById('b_d_r_'+id+'_').src='http://all.by/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 != ''){
		c = '';
		if(document.findform.chapter.checked){
		   c = '&chapter=' + document.findform.chapter.value;
		}
		q = document.findform.findtext.value;
		reg = new RegExp("&", "g");
		q = q.replace(reg, "%26");
		reg = new RegExp(";", "g");
		q = q.replace(reg, "%3B");
		document.location.href = document.findform.action.value + q + c;
	}
}
