// JavaScript Document

var cur=-1, timer;

// --------------------------------------------------------------------------------------
// function work with menu

function menu_sel(num) {
ofsL = 0;
ofsT = 0;
if (cur!=num && cur!=-1 && timer) {
	clearTimeout(timer);
	if (document.all('div'+cur)) eval("div"+cur+".style.display='none'");
}
if (cur!=-1) clearTimeout(timer);
if (document.all('div'+num)) {
	obj1 = document.getElementById('m'+num);
	obj2 = document.getElementById('m'+num);

	while(obj2.tagName != 'BODY')
		{
		if (obj2.tagName == 'TABLE' || obj2.tagName == 'TD')
			{
			ofsL += obj2.offsetLeft
			ofsT += obj2.offsetTop
			}
		obj2 = obj2.parentElement;
		}
	eval("div"+num+".style.display='block'");		
	eval("div"+num+".style.left="+(ofsL+obj1.clientWidth));
	eval("div"+num+".style.top="+ofsT);
	}
cur=num;
}

function menu_unsel(num) {
s_code="";
if (document.all('div'+num)) s_code+="div"+num+".style.display=\"none\"; ";
s="eval('"+s_code+"cur=-1;')";
timer=setTimeout(s,150);
}

function div_sel(num) {
if (timer) clearTimeout(timer);
}

function div_unsel(num) {
s="eval('div"+num+".style.display=\"none\"; m"+num+".style.background=\"#ffffff\"; cur=-1; m"+num+".style.color=\"#ffffff\"')";
timer=setTimeout(s,150);	
}

function cat_sel(obj) {
obj.style.background='#ffffff';
obj.style.color='#FFFFFF';
}
	
function cat_unsel(obj) {
obj.style.background='#ffffff';
obj.style.color='#ffffff';
}

// ---------------------------------------------------------------------------------------------

function ShowDiv(obj) 
{
oList=document.getElementById("b-"+obj.id.substr(2));
if (oList) {
	if(oList.className=="tocItemHide"){
		oList.className="tocItemShow";
	}
	else{
		oList.className="tocItemHide";
	}
}
}

function openwin(url, h, w, sc) {
	window.open(url,'_blank','top='+(window.screen.height-h)/2+',left='+(window.screen.width-w)/2+',height='+h+',width='+w+',status=no,toolbar=no,scrollbars='+sc+',titlebar=no,directories=no,resizable=no menubar=no,location=no');
	return;
}

function searchSubmit() {
	pobj=opener.hidenSearchForm;
	obj=document.searchForm;
	i=0;
	while(i<(obj.length-1)) {
	pobj[i].value=obj[i].value;
	++i;
	}
	pobj.submit();
}

function reloadCat(obj,s) {
	if (obj.selectedIndex==0) retCat(s); 
		else document.all('showCat').src='search_win_dyn.php?cat='+obj.value+'&do='+s;
	if (s=1) retCat(2); 
}
function retCat(s) {
	if (s==1) nm="Категория"; 
		else nm="Бренд";
	document.all('td'+s).innerHTML=nm+"<br><select disabled class=\"sfield\"><option selected>Везде</option></select>";
}