﻿
var openedMenu=null;
var isDOM = document.getElementById ? true : false ;
var isIE = document.all ? true: false ;
var isNN4 = document.layers ? true: false;

if (!document.getElementById) {
	_getElementById = document.getElementById;
	document.getElementById = function(sId) {
		if ( isDOM ) {
			var objj=_getElementById(sId);
			return objj;
		}
		else 
			if ( isIE ) {
			return document.all[sId];
			} 
			else
				if ( isNN4 ) {
					return document.layers[sId];
				} 
				else 
				{
					return _getElementById(sId);
				}
	};	
}	

function annulEvent(e)
{
    try 
    {
        e.stopPropagation();
    }
    catch (ex)
    {
        window.event.cancelBubble=true;
    }
}

function clearSubMenus()
{
    if (openedMenu!=null)
        document.getElementById(openedMenu).style.display='none';
}

function menuShow(name,e)
{
    if (!document.body.onmousemove)
    {
        document.body.onmousemove=clearSubMenus;
    }
    clearSubMenus();
   
    //document.getElementById('subMenu'+name).style.left=FindPosCatalogX(document.getElementById('cat'+name))+document.getElementById('cat'+name).clientWidth+'px'
    //document.getElementById('subMenu'+name).style.top=FindPosCatalogY(document.getElementById('cat'+name))+'px'
    document.getElementById('subMenu'+name).style.display='block';
    openedMenu='subMenu'+name;
}

function FindPosCatalogX(obj)
{
    var posX = 0, posY = 0;
    
    do
    {
        posX += obj.offsetLeft;
        posY += obj.offsetTop;
        obj = obj.offsetParent;
    }
    while( obj != null );

    
    return posX;
}

function FindPosCatalogY(obj)
{
    var posX = 0, posY = 0;
    
    do
    {
        posX += obj.offsetLeft;
        posY += obj.offsetTop;
        obj = obj.offsetParent;
    }
    while( obj != null );

    
    return posY;
}
