//Script written by vad.ru & heoh.ru
ie = (document.all)? true : false;
nn4 = (document.layers)? true : false;
nn5 = (parseInt(navigator.appVersion)>=5)? true : false;
opera = (document.appName == "Opera" && parseInt(navigator.appVersion)>=4)? true : false;

var active = ''
showActive()

var pLayer;

	if (nn4) {
		layerRef="document.";
		styleSwitch="";
	}
	if (ie) {
		layerRef="";
		styleSwitch=".style";
	}
	if (nn5 || opera) {
		layerRef="document.getElementById('";
		styleSwitch="').style";
	}


var opened = new Array();

function deleteByKey( key)
{
for(i=0;i<opened.length;i++)
	{
	if( opened[i] == key)
		{
		opened = (opened.slice( 0,i)).concat( opened.slice( i+1, opened.length))
		}
	}
}

function show( img, show, menuNum) {
	if( show ) {
		hideAllOpened()
		
	/*
	if( ie )
	{
	*/
		iW = "document.body.clientWidth";
		iH = "document.body.clientHeight";
	/*
	}
	else
	{
	iW = "window.innerWidth";
		iH = "window.innerHeight";
	}
	*/
	ClWidth=eval(iW);
	ClHeiht=eval(iH);
	
	// Указано количество менюшек
	menucount = 4;
	//x1 = (20-(menuNum*4))+Math.round((ClWidth*(21*(menuNum-1)))/100);
	//x1 = 4 + Math.round(ClWidth/5)*(menuNum-1);
	x1 = 4 + Math.round(ClWidth/4)*(menuNum-1);

		if( typeof( menuNum) != 'undefined' && img != active) {
			if ( img > '' ) {
				if ( opera ) {
					eval(layerRef+'id'+img+styleSwitch+".top=245");
				} else {
					eval(layerRef+'id'+img+styleSwitch+".top=245");
					//eval(layerRef+'id'+img+styleSwitch+".left=20+"+((menuNum-1)*200));
					eval(layerRef+'id'+img+styleSwitch+".left="+x1);
				}
				eval(layerRef+'id'+img+styleSwitch+".visibility='visible'");
				if ( ie ) {
					//document.all('td'+img).style.backgroundImage = 'url(images/menu_bg_c.gif)';
				}
			}
		}
		if( typeof(MyTimeout) != 'undefined') {clearTimeout( MyTimeout)}
		opened[opened.length] = img
	} else {
		//document.images[img].src = img_empty
		if ( img > '' ) {		
			eval(layerRef+'id'+img+styleSwitch+".visibility='hidden'");
			deleteByKey( img )
		}
		if ( ie ) {		
			//document.all('td'+img).style.backgroundImage = 'url(images/menu_bg.gif)';		
		}
	}
}

function showActive()
{
if( active != '')
	{
	show( active, true )
	}
}

function hide( img )
{
MyTimeout = setTimeout( "show( '"+img+"', false);showActive();", 2000)
}

function hideAllOpened()
{
for(i=0;i<opened.length;i++)
	{
	show( opened[i], false )
	}
}

function menuOver()
{
if( typeof(MyTimeout) != 'undefined') {clearTimeout( MyTimeout)}
if( typeof(MenuTimeout) != 'undefined') {clearTimeout( MenuTimeout)}
}
function menuOut()
{
MenuTimeout = setTimeout( 'hideAllOpened();showActive();', 2000)
}

function search_onclick() {
	if ( !document.search.searchString.value > "" ) {
		alert("Введите ключевые слова для поиска")
		return false;
	}
}

