<!--

//------------ подсветка в верхнем меню -----------//

function topMenuOver ( Item , All ) {
	if ( Item < 1 || Item > All ) return false;
	Obj = document.getElementById("topmenuTd" + Item);
	if ( Obj != undefined )
		Obj.className = "topmenuhover";
	if (Item == 1){
		Obj = document.getElementById("topmenuSeparator" + Item);
		if ( Obj != undefined && Item != itemCurrent - 1) 
			Obj.className = "topmenuhover";
		}
	else if (Item == All){
		Obj = document.getElementById("topmenuSeparator" + (Item - 1));
		if ( Obj != undefined && Item != itemCurrent + 1) 
        	Obj.className = "topmenuhover";
		} 	
	else {
		Obj = document.getElementById("topmenuSeparator" + (Item - 1));
		if ( Obj != undefined && Item != itemCurrent + 1)
			Obj.className = "topmenuhover";
		Obj = document.getElementById("topmenuSeparator" + Item);
		if ( Obj != undefined && Item != itemCurrent - 1)
			Obj.className = "topmenuhover";
		}
	return false;
	}
	
function topMenuOut ( Item , All ) {
	if ( Item < 1 || Item > All ) return false;
	Obj = document.getElementById("topmenuTd" + Item);
	if ( Obj != undefined )
		Obj.className = "empty";
	if (Item == 1){
		Obj = document.getElementById("topmenuSeparator" + Item);
		if ( Obj != undefined && Item != itemCurrent - 1) 
			Obj.className = "topmenu";
		}
	else if (Item == All){
		Obj = document.getElementById("topmenuSeparator" + (Item - 1));
		if ( Obj != undefined && Item != itemCurrent + 1) 
        	Obj.className = "topmenu";
		} 	
	else {
		Obj = document.getElementById("topmenuSeparator" + (Item - 1));
		if ( Obj != undefined && Item != itemCurrent + 1)
			Obj.className = "topmenu";
		Obj = document.getElementById("topmenuSeparator" + Item);
		if ( Obj != undefined && Item != itemCurrent - 1)
			Obj.className = "topmenu";
		}
	return false;
	}
	
//-------------- выпадающая менюшка ----------//

var curMenu = -1;
var curTotal = 5;

var debugMessage = "";

function OffsetLeft( obj ) {
    var coordLeft = 0;
    while( obj.offsetParent != null ) {
        coordLeft += obj.offsetLeft * 1;
        if ( obj.style.position == "absolute" || obj.tagName == "BODY" )
            break;
        obj = obj.offsetParent;
    }
    return coordLeft;
}

function OffsetTop( obj ) {
    var coordTop = 0;
    while( obj.offsetParent != null ) {
        coordTop += obj.offsetTop * 1;
        if ( obj.style.position == "absolute" || obj.tagName == "BODY" )
            break;
        obj = obj.offsetParent;
    }
    return coordTop;
}

function GetFinish( obj ) {
    return OffsetTop(obj) * 1 + obj.offsetHeight * 1;
}

function PullDown() {
	obj = document.getElementById("topmenuTd" + curMenu.toString());
	curLeft = OffsetLeft(obj) * 1 - 3;
    curTop = OffsetTop(obj) * 1 + obj.offsetHeight * 1;
    curWidth = obj.offsetWidth * 1;
	maxWidth = curWidth;
	for( var i = 1 ; i <= curTotal ; i++ ) {
        obj = document.getElementById("s" + curMenu.toString() + "_" + i.toString());
		objWidth = obj.offsetWidth * 1;
		if ( objWidth > maxWidth ) maxWidth = objWidth;
		}
	//alert(curMenu);
	if ( curMenu > 4 ) curLeft = curLeft + curWidth - maxWidth - 1;
	for( var i = 1 ; i <= curTotal ; i++ ) {
		obj = document.getElementById("submenu" + curMenu.toString() + "_" + i.toString());
		obj.style.width = maxWidth;
		obj = document.getElementById("s" + curMenu.toString() + "_" + i.toString());
		obj.style.width = maxWidth;
		obj = document.getElementById("popupMenu" + curMenu.toString() + "_" + i.toString());
		obj.style.left = curLeft;
        obj.style.top = curTop;
        obj.style.width = maxWidth;
		obj.style.zIndex = curTotal - i + 2;
        obj.style.position = "absolute";
        obj.style.visibility = "visible";
		curTop = GetFinish(obj);
		}
   }

function HideMenu() {
    if ( curMenu < 0 ) return;
    for( var i = 1 ; i <= curTotal ; i++ ) {
        obj = document.getElementById("popupMenu" + curMenu.toString() + "_" + i.toString());
        obj.style.visibility = "hidden";
    	}
    curMenu = -1;
	}

function ShowMenu( ind, total ) {
	if ( curMenu == ind ) return;
    if ( curMenu > 0 ) HideMenu();
    curMenu = ind;
	curTotal = total;
    PullDown();
	}

function OnClick() {
    if ( curMenu >= 0 )
        HideMenu();
	}

document.onclick =  OnClick;

//---------- подсветка подпунктов в выпадающей менюшке -----//

function popupMenuOver ( Div, Item , All ) {
	if ( Item < 1 || Item > All ) return false;
	Obj = document.getElementById("submenu" + Div + "_" + Item);
	if ( Obj != undefined )
		Obj.className = "topmenuhover";
	Obj = document.getElementById("submenuborder" + Div + "_" + Item);
	if ( Obj != undefined )
		Obj.className = "popupmenuborderhover";
	return false;
	}
	
function popupMenuOut ( Div, Item , All ) {
	if ( Item < 1 || Item > All ) return false;
	Obj = document.getElementById("submenu" + Div + "_" + Item);
	if ( Obj != undefined )
		Obj.className = "popupmenubg";
	Obj = document.getElementById("submenuborder" + Div + "_" + Item);
	if ( Obj != undefined )
		Obj.className = "popupmenuborder";
	return false;
	}
	
//-->
