// (c) Арт Калошин
// Версия 1.3

var ns = (navigator.appName == 'Netscape');
var ie = (navigator.appName == 'Microsoft Internet Explorer');
var ns4 = (ns && parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5);
var ie4 = (ie && parseInt(navigator.appVersion) >= 4);
var ns5 = (ns && parseInt(navigator.appVersion) >= 5);
var oper = (window.opera != null);

// Разные константы
PI=3.1415;

function Align(v,a){
    if (v < a) { return a;}else{return v;}
}

function AreaWidth(){
    if(oper || ns4){ return(window.innerWidth); }
    else if(ie4){ return(document.body.clientWidth); }
}

function AreaHeight(){
    if(ns4 || oper){ return(window.innerHeight);}
    else if(ie4){ return(document.body.clientHeight); }
}

function LMoveTo(ly,X,Y){
	if(ie4){
		document.all[ly].style.pixelLeft=X;
		document.all[ly].style.pixelTop=Y;
	} else if(oper){
		var el = document.getElementById(ly);
 		el.style.pixelLeft=X;
		el.style.pixelTop=Y;
	} else if(ns5){
		var el = document.getElementById(ly);
 		el.style.left=X;
		el.style.top=Y;
	} else if(ns4){
		document.layers[ly].left=X;
		document.layers[ly].top=Y;
	}
}

function LShow(ly){
	if (ie4){ document.all[ly].style.visibility='visible';
	} else if(ns4){ document.layers[ly].visibility='show';
	} else if(oper || ns5){ document.getElementById(ly).style.visibility='visible';}
}

function LGetVis(ly){
	if(((ie4 || oper) && document.all[ly].style.visibility=='visible')||(ns4 && document.layers[ly].visibility=='show')){ return(1);
	} else { return(0); }
}

function LHide(ly){
	if(ie4){ document.all[ly].style.visibility='hidden';
	} else if(ns4){ document.layers[ly].visibility='hide'; alert(ly);
	} else if(oper|| ns5){ document.getElementById(ly).style.visibility='hidden';}
}

function LToggle(ly){
	if(ie4){ if(document.all[ly].style.visibility == 'hidden') {document.all[ly].style.visibility = 'visible';} else {document.all[ly].style.visibility = 'hidden';}
	} else if(ns4) {if(document.layers[ly].visibility == 'hide') {document.layers[ly].visibility = 'show';} else {document.layers[ly].visibility = 'hide';}} 
else if(oper|| ns5){if(document.getElementById(ly).style.visibility == 'hidden') {document.getElementById(ly).style.visibility = 'visible';} else {document.getElementById(ly).style.visibility = 'hidden';};}
}

var layertimer;
var lastmenues;
var active = 0;

function killMenus(strWen, strStatus){
	layertimer = setTimeout("showMenus('"+strWen+"', 'off')", 500);
	return false;
}

function showMenus(strWen, strStatus, strCoord) {
	if(strStatus == "on"){
		if(layertimer){ clearTimeout(layertimer) }
	}
	var tempWen = strWen.split(",");
	var strOut="";

	if(DOCloaded) {
		clearTimeout(active);
		if(lastmenues){
			tempLastmenues = lastmenues.split(",");
			for (i=0;i<tempLastmenues.length;i++) {LHide(tempLastmenues[i]);}
			lastmenues = null;
		}
		if(strStatus=="on"){
		    if(strCoord!=null && strCoord!=""){
		        tempCoord = strCoord.split("|")
		    }
			tempActualLayers=strWen.split(",")
			for (i=0; i < tempWen.length; i++){
    		    if(strCoord!=null && strCoord!=""){
                    T = tempCoord[i].split(",")
                    if (T[0]!="" && T[1]!=""){
    			        LMoveTo(tempActualLayers[i], T[0], T[1]);
    			    }
    		    }
              LShow(tempActualLayers[i])
            }
			lastmenues = strWen;
		}
	} else {
		active = setTimeout("showMenus('" + strWen + "','" + strStatus + "','" + strCoord + "')",2000);
	}
	return false;
}
