	var timeoutIDs = new Array();
	
	/* Открывает изображение в новом окне */ 
	function FullImageOpen(ID, Width, Height) {
		open("/picture.asp?ID="+ID, "_blank", "resizable=1,menubar=0,scrollbars=1,width="+Width+",height="+Height+""); //,left=100,top=60"
	}

        function openURL(URL){
            open(URL, "_self");
        }

	function changeStyle(styleObject, classStyleName)
	{
		styleObject.className = classStyleName;
		return true;
	}

        var selectedObjectID // для запоминания какой пункт менюшки для плана подсвечен...

	function changeStyleFloor(styleObject, classStyleName)
	{	
		if(styleObject.id != selectedObjectID){
		styleObject.className = classStyleName;}
		return true;
	}
	
	function showLayer(layerName)
	{
		changeObjectDisplaying(layerName, 'block');
	}

	function hideLayer(layerName)
	{	
		changeObjectDisplaying(layerName, 'none');
	}
	
	function hideSubLayer(layerName)
	{	//alert(layerName);
		changeObjectDisplaying('menu'+layerName, 'none');
		//alert('images/menu-line.gif');
		changePictureSrc('line'+layerName, '/images/menu-line.gif')
		//changeObjectVisibility('line'+layerName, 'hidden');		
	}

	function showSubLayer(layerName)
	{	//alert(layerName);
		changeObjectDisplaying('menu'+layerName, 'block');
		//alert('images/menu-line-full.gif');
		changePictureSrc('line'+layerName, '/images/menu-line-full.gif')
		//changeObjectVisibility('line'+layerName, 'visible');		
	}
	
	function MouseOverEvent(layerNum, layerCurNum)
	{	
		//alert('line'+layerNum+" "+getPictureXCoord('line'+layerNum));
	//	if (layerCurNum!=layerNum || layerCurNum=="undefined")
	//	{
		timeoutID = timeoutIDs[layerNum];
		clearTimeout(timeoutID);
		timeoutID = timeoutIDs[layerCurNum];
		clearTimeout(timeoutID);
		//alert('line'+layerNum+" "+getPictureXCoord('line'+layerNum));
		//setLayerCoords('menu'+layerNum, getPictureXCoord('line'+layerNum)-3);
		showSubLayer(layerNum);
		hideSubLayer(layerCurNum);
	//	}
	}
	
	function MouseOutEvent(layerNum, layerCurNum)
	{	
		if (layerCurNum!=layerNum || layerCurNum=="undefined")
		{
		timeoutID = setTimeout('hideSubLayer(\''+layerNum+'\')', 100);
		timeoutIDs[layerNum] = timeoutID;
		timeoutID = setTimeout('showSubLayer(\''+layerCurNum+'\')', 100);
		timeoutIDs[layerCurNum] = timeoutID;
		}
	}

	function MouseOverEventSub(layerNum, layerCurNum)
	{	
		if (layerCurNum!=layerNum)
		{
		timeoutID = timeoutIDs[layerNum];
		clearTimeout(timeoutID);
		timeoutID = timeoutIDs[layerCurNum];
		clearTimeout(timeoutID);
		}
	}
	
	function MouseOutEventSub(layerNum, layerCurNum)
	{	
		if (layerCurNum!=layerNum)
		{
		timeoutID = setTimeout('hideSubLayer(\''+layerNum+'\')', 100);
		timeoutIDs[layerNum] = timeoutID;
		timeoutID = setTimeout('showSubLayer(\''+layerCurNum+'\')', 100);
		timeoutIDs[layerCurNum] = timeoutID;
		}
	}

	function showPicture(mainPicID, picID)
	{		
			if(showPicture.arguments.length > 2 ){
				for(i=2; i<showPicture.arguments.length; i++){
					changeObjectVisibility(showPicture.arguments[i], 'hidden');
                                        }
			}
			//alert(getPictureYCoord(mainPicID)+" "+CoordsY[picID]+" "+mainPicID);
                        //alert(getPictureXCoord(mainPicID)+" "+CoordsX[picID]);
			setLayerCoords(picID, getPictureXCoord(mainPicID)+CoordsX[picID], getPictureYCoord(mainPicID)+CoordsY[picID]) ; 
			//showLayerVis(picID);
			changeObjectVisibility(picID, 'visible');
	}

	function hidePicture(mainPicID, picID)
	{		
			if( hidePicture.arguments.length > 2 ){
				for(i=2; i<hidePicture.arguments.length; i++){
					setLayerCoords(hidePicture.arguments[i], getPictureXCoord(mainPicID)+CoordsX[hidePicture.arguments[i]], getPictureYCoord(mainPicID)+CoordsY[hidePicture.arguments[i]]) ; 
					changeObjectVisibility(hidePicture.arguments[i], 'visible');}
			}
			//hideLayerVis(picID);
			changeObjectVisibility(picID, 'hidden');
	}

	function showLayerVis(picID)
	{	
		changeObjectVisibility(picID, 'visible');
		//alert('show');
	}
	
	function hideLayerVis(picID)
	{
		changeObjectVisibility(picID, 'hidden');
	}

	function showFloor(floorID)
	{
		for (i=0;i<floors.length ;i++ )
		{
			if(getObjDisplaying(floors[i])=='block'){hideLayer(floors[i]);}
		}
		showLayer(floorID);
		return false;
	}

//
// ************************
// layer utility routines *
// ************************

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changePictureSrc(pictureID, newSrcImg) {
    getStyleObject(pictureID).src = newSrcImg;
}

function getPictureXCoord(pictureID) {
   var styleObject = getStyleObject(pictureID);
    if(styleObject) {
		x = 0;
		obj = styleObject;
		while (obj.offsetParent != null) {
		  x += obj.offsetLeft;
		  obj = obj.offsetParent;
		}
		x += obj.offsetLeft;
		return x;
	} else {return 10;}

}

function getPictureYCoord(pictureID) {
        var styleObject = getStyleObject(pictureID);
        if(styleObject) {
                  // alert(styleObject.currentStyle.top);
                    y = 0;
                    obj = styleObject;
                    while (obj.offsetParent!=null) {
                      y += obj.offsetTop;
                      //alert(obj.offsetTop);
                      obj = obj.offsetParent;
                    }
                    y += obj.offsetTop;
                    return y;
         } else {return 10;}
}

function setLayerCoords(LayerName, x, y) {
        //alert(LayerName);
	if (y+"" != "undefined")
	{
		getStyleObject(LayerName).style.top = y;
		//alert(LayerName+" "+x+","+y);
	} 
        if(getStyleObject(LayerName)){
            getStyleObject(LayerName).style.left = x;
            //alert(LayerName);
        }
}


function changeInnerText(tdID, newInnerText) {
    getStyleObject(tdID).innerHTML = newInnerText;
}

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.style.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function changeObjectDisplaying(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.style.display = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectVisibility

function getObjVis(objectId){
	var styleObject = getStyleObject(objectId);
    if(styleObject) {
	return styleObject.style.visibility;
	}
}

function getObjDisplaying(objectId){
	var styleObject = getStyleObject(objectId);
	//alert(styleObject.style.display);
    if(styleObject) {
	return styleObject.style.display;
	}
	return "error";
}

function changeObjectClassStyle(objectId, classStyleName) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.className = classStyleName;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
} // changeObjectClassStyle

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId).style;
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject


