 var curMenu
 var selTd
//*************************************************************************
//объект содержащий информацию о броузере
//*************************************************************************
function browserCheck(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	
	this.dom=document.getElementById?1:0
	this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1) && window.opera 
	this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1) && window.opera   
	this.ie5 = (this.agent.indexOf("msie 5")>-1 && !this.op5 && !this.op6)
	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
	this.ie6 = (this.agent.indexOf("msie 6")>-1 && !this.op5 && !this.op6)
	this.ie4=(this.agent.indexOf("msie")>-1 && document.all &&!this.op5 &&!this.op6 &&!this.ie5&&!this.ie6)
	this.ie = (this.ie4 || this.ie5 || this.ie6)
	this.mac=(this.agent.indexOf("mac")>-1)
	this.ns6=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ns4=(!this.dom && document.layers)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6)
	this.usedom= this.ns6//Use dom creation
	this.reuse = this.ie||this.usedom //Reuse layers
	this.px=this.dom&&!this.op5?"px":""
	this.hide = this.ns4?"hide":"hidden"
	this.show = this.ns4?"show":"visible";
	return this
}

//*************************************************************************
function subMenu(obj){
	
	if (curMenu){	//Определение родительского меню для открывающегося
		var parenttd

		parenttd = getAncestorElement(obj, "td");
		this.parentMenu = curMenu.getParent(parenttd)
		this.bw = curMenu.bw
	}else{
		this.parentMenu = null
		this.bw = new browserCheck();
	}
	if (this.parentMenu == null){
		Unsel()
		selTd = obj
	}
	
	this.menuid = obj.id	
	this.subtd = this.bw.dom? document.getElementById(this.menuid+"s"):document.all[this.menuid+"s"];
	this.css=!this.subtd?null:this.bw.dom||this.bw.ie4?this.subtd.style:this.subtd;
	return this;
}

//*************************************************************************
subMenu.prototype.hide = function(){
	/*cкрываем текущее подменюменю */
	this.css.visibility = this.bw.hide
	this.css.display = "none"
}
//*************************************************************************
subMenu.prototype.hideAll = function(){
	/*cкрываем текущее подменюменю */
	this.hide()
	
	if (this.parentMenu != curMenu.parentMenu){
		this.parentMenu.hideAll()
	}
}
//*************************************************************************
subMenu.prototype.show = function(){
	/*показываем текущее подменю */
	this.css.visibility = this.bw.show
	this.css.display = "inline"
//	this.className = "vis_menu"
}

//*************************************************************************
subMenu.prototype.getParent = function(obj){
	if (this.subtd == obj){
		return this
	}else{
		if (this.parentMenu == null){
			return null
		}else{
			return this.parentMenu.getParent(obj)
		}
	}

}
//*************************************************************************
subMenu.prototype.needToShow = function(){

	if (this.css.visibility != this.bw.show){
		return true;
	}else{
		return false;
	}
}
//*************************************************************************
function showSubmenu(obj){
	var menu = new subMenu(obj)
	var oldCurMenu = curMenu
	if (menu.needToShow()){
		menu.show();
		curMenu = menu
		if (oldCurMenu != curMenu.parentMenu){
			if (oldCurMenu){
				oldCurMenu.hideAll()
			}
		}
	}

}

//*************************************************************************
function makeCurrentMenu(objStr){
	var aId = objStr.split(',');
	var i;
	var obj
	for(i = 0; i < aId.length; i++){
		if (aId[i] != ""){

			obj = document.all[aId[i]];
			if (obj){
				var menu = new subMenu(obj)
				curMenu = menu
			}
		}
	}
}

//*************************************************************************
/*function insSubmenu(id){
	main_all = parent.main.document.all
	if (main_all(id+"s")){
		main_all(id+"s").innerHTML = parent.tmp.document.all("container").innerHTML
		parent.main.showSubmenu(id)
	}
}*/

//*************************************************************************
function getAncestorElement(oSel, sMatchTag){
	var oElement

	try{

		oElement = oSel.parentNode

		if (sMatchTag != ""){
			
			while (oElement!=null && oElement.tagName.toLowerCase()!=sMatchTag){
				if (oElement == document.body)		return null;
				oElement = oElement.parentNode;
			}
			return oElement
		}
	}
	catch(e){
		alert(e)
		return null
	}
	
}

function mouseMenuOver(obj, ss){
	if (obj != selTd){
		var pos
		pos = obj.className.indexOf(ss)
		if (pos == -1){
			obj.className = obj.className + ss
		}
	}
}

function mouseMenuOut(obj, ss){
	if (obj != selTd){
		var pos
		pos = obj.className.indexOf(ss)
		if (pos != -1){
			obj.className = obj.className.substr(0, pos)
		}
	}
}

function Unsel(){
	if (selTd){
		var position
		selTd.className = "menu1"
	}	
}