var submenus = new Array();
function getLayer(name) {
return (document.all)?document.all[name]:document.getElementById(name);
}
function showMenu(name) {
getLayer(name).style.visibility='visible';
}
function hideAll(name) {
getLayer(name).style.visibility='hidden';
}
function SubCat(obj,TotalSecCount) {
layerId=obj.id+'Sub';
if (obj.src.indexOf('_h')!=-1) {
    obj.src=obj.src.replace('_h.gif','.gif');
    SetCookie(obj.id,'hidden');
    hideLayer(layerId);
    (eval(layerId).length)?(hideChildren(eval(layerId),false)):'';
    }
    else {
    obj.src=obj.src.replace('.gif','_h.gif');
    hideAll(TotalSecCount);
    SetCookie(obj.id,'visible');
    showLayer(layerId);
    (eval(layerId).length)?hideChildren(eval(layerId),true):'';
    }
}
function hideAll(TotalSecCount) {
    for (var i=1;i<=TotalSecCount;i++)
        {
        name='sections'+i+'Sub';
        getLayer(name).style.visibility='hidden';
        getLayer(name).style.position='absolute';
        }
}
function hideLayer(name) {
    getLayer(name).style.visibility='hidden';
    getLayer(name).style.position='absolute';
}
function showLayer(name) {
    getLayer(name).style.visibility='visible';
    getLayer(name).style.position='static';
}
function hideChildren(charr,state) {
for (var i=0;i<charr.length;i++) {
    if (state) {
        if (GetCookie(charr[i])=='visible') {
            getLayer(charr[i]).src=getLayer(charr[i]).src.replace('.gif','_h.gif');
            showLayer(charr[i]+'Sub');
            }
        }
        else {
        if (GetCookie(charr[i])=='visible') {
            getLayer(charr[i]).src=getLayer(charr[i]).src.replace('_h.gif','.gif');
            hideLayer(charr[i]+'Sub');
            }
        }
    }
}
    function showLetter(letter) {
    p=document.location.toString().split('#');
    if (p[0]) {
        document.location=p[0]+letter;
        }
    else {
        document.location=location+letter;
        }
    }

function makePopUp(urlValue,widthValue,heightValue) {
    var leftPos = (screen.availWidth-widthValue) / 2;
    var topPos = (screen.availHeight-heightValue) / 2;
    NewWidthValue=widthValue+20;
    NewHeightValue=heightValue+20;
    return window.open(urlValue, 'PopUpWindow','width='+NewWidthValue+',height='+NewHeightValue+',menubar=0,scrollbars=auto,resizable=yes,statusbar=no,location=no,titlebar=0,toolbar=0,status=0,top=' + topPos + ',left=' + leftPos);
}

function RePopUp(oLink) {
	if (oLink.target == 'PopUp') {
		if (oLink.href.match(/(jpg)|(png)|(gif)$/i)) {
			oIm = new Image();
			oIm.src = oLink.href;
			win = makePopUp(oLink.href,(oIm.width ? oIm.width : 400) + 12,(oIm.height ? oIm.height : 330) + 31);
			win.document.open("text/html");
			win.document.write('<html><head><title>Просмотр картинки</title></head><script language="JavaScript" type="text/javascript">function GetLayer(name) {return ((eval(document.all))?(document.all[name]):(document.getElementById(name)))} function doR () { window.resizeTo(GetLayer(\'pimg\').width+12,GetLayer(\'pimg\').height+31)}</script><body onload="doR();" bgcolor="#ffffff" style="margin:0px;text-align:center;"><a href="#" onclick="window.close()"><img src="'+oLink.href+'" name="pimg" id="pimg" alt="Close window" border="0"/></a></body></html>');
			win.document.close();
		} else {
			makePopUp(oLink.href,400,330);
		}	
		return false;
	}
	return true;
}

function checkSearchForm(txtField) {
  if (txtField.value == '') {
    event.returnValue=false;
    alert("Пожалуйста, введите ключевое слово для поиска!");
  }
}
