var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
var DOM = (document.getElementById) ? 1 : 0;
var ver4 = (NS4 || IE4) ? 1 : 0;
      var  gotlayers = 1;
var CloseTmr=null;

	//	  alert (NS4 +"-"+IE4+"-"+DOM);

function overMenu(menuId,addwidth)
{
	// close all menus
		closeAll();
	// open this menu
		menuName="div_menu" + menuId;
		leftDefine2(menuId,addwidth);
		if (NS4) {
				document.layers[menuName].visibility = "show";
		} else if (DOM) {
				document.getElementById(menuName).style.visibility = "visible";

		} else {
				document.all[menuName].style.visibility = "visible";
		}	

}
function leftDefine2 (menuId,addwidth)
{
	left_margin=1;
	total_width=1003;
	if (self.innerHeight) {	
		wid = self.innerWidth;	
		y = self.innerHeight;	
	// IE 6 Strict Mode	
	} else if (document.documentElement && document.documentElement.clientHeight) {	
		wid = document.documentElement.clientWidth;	
		y = document.documentElement.clientHeight;	
	// Остальные версии IE	
	} else if (document.body) {	
		wid = document.body.clientWidth;	
		y = document.body.clientHeight;	
	}	

	if (wid<=total_width) left_margin=left_margin+addwidth; // default. resolution <972
	if (wid>total_width)
	{
		left_margin=(wid-total_width)/2+left_margin+addwidth;
	}

        atemper="div_menu" + menuId;

                        if (NS4 && document.layers[atemper]) {
                                document.layers[atemper].left = left_margin;
                        } else if (DOM && document.getElementById(atemper)) {
                                document.getElementById(atemper).style.left = left_margin;
                        } else if (document.all[atemper]){
                                document.all[atemper].style.left = left_margin;
                        }

	
}

function closeAll ()
{
    if (gotlayers) 
	{
        // step1. define left margin of menu divs
		//leftDefine();
		for (temp = 1; temp < 20; temp++)   {
        atemper="div_menu" + temp;

                        if (NS4 && document.layers[atemper]) {
                                document.layers[atemper].visibility = "hide";
                        } else if (DOM && document.getElementById(atemper)) {
                                document.getElementById(atemper).style.visibility = "hidden";
                        } else if (document.all[atemper]){
                                document.all[atemper].style.visibility = "hidden";
                        }
        }
		if(CloseTmr)clearTimeout(CloseTmr);
	}

}
function outMenu()
{
		if(CloseTmr)clearTimeout(CloseTmr);
		CloseTmr=setTimeout('closeAll()',100);

}		
