//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( typeof( menuNum) != 'undefined' && img != active) {
			if ( img > '' ) {
				eval(layerRef+'id_'+img+styleSwitch+".visibility='visible'");
			}
		}
		if( typeof(MyTimeout) != 'undefined') {clearTimeout( MyTimeout)}
		opened[opened.length] = img
	} else {
		if ( img > '' ) {		
			eval(layerRef+'id_'+img+styleSwitch+".visibility='hidden'");
			deleteByKey( img )
		}
	}
}

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

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

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();', 300)
}

