function getIdProperty( id, property )
{
    if (isNav6)
    {
		var styleObject = document.getElementById( id );
		if (styleObject != null)
        {
			styleObject = styleObject.style;

			if (styleObject) //styleObject[property]
            {
                return styleObject[ property ];
            }
        }
        styleObject = getStyleBySelector( "#" + id );
        return (styleObject != null) ? styleObject[property] : null;
    }
    else if (isNav4)
    {
        return document[id][property];
    }
    else
    {
        var obj = document.getElementById( id );
		return (obj != null) ? document.all[id].style[property] : null;
	}
}

function setIdProperty( id, property, value )
{
    if (isNav6)
    {
        var styleObject = document.getElementById( id );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            styleObject[ property ] = value;
		}
    }
    else if (isNav4)
    {
        document[id][property] = value;
    }
    else if (isIE4)
    {
         document.all[id].style[property] = value;
    }
}

function showMenu( name, divNum )
{
	var getProperty = getIdProperty( "s_" + divNum, "display");
	if (getProperty != null)
	{
		if (getProperty != "block" )
		{
			setIdProperty("s_" + divNum, "display", "block");
			setCookie("menu_name_" + name,"s_" + divNum);
		}
		else
		{
			setIdProperty("s_" + divNum, "display", "none");
			deleteCookie("menu_name_" + name);
		}
	}
}

function showAllMenus( name, divNum )
{
	var getProperty = getIdProperty( "s_" + divNum, "display");
	if (getProperty != null)
	{
		if (getProperty != "block" )
		{
			setIdProperty("s_" + divNum, "display", "block");
		}else{
			setIdProperty("s_" + divNum, "display", "none");
		}
	}
}


// name - cookie name
// value - cookie value
// [expires] - Date object (by default cookie expires at the end of browser session)
// [path]
// [domain]
// [secure]
function setCookie(name, value, expires, path, domain, secure)
{
	var curCookie = name + "=" + escape(value) +
                ((expires) ? "; expires=" + expires.toGMTString() : "") +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                ((secure) ? "; secure" : "")

	if ( (name + "=" + escape(value)).length <= 4000)
		document.cookie = curCookie
}

// name - cookie name
function getCookie(name)
{
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1)
                return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

// name - cookie name
// [path]
// [domain]
function deleteCookie(name, path, domain)
{
	if (getCookie(name))
	{
		document.cookie = name+"="+
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT"
	}
}
function getStyleBySelector( selector )
{
    if (!isNav6)
    {
        return null;
    }
    var sheetList = document.styleSheets;
    var ruleList;
    var i, j;
    for (i=sheetList.length-1; i >= 0; i--)
    {
        ruleList = sheetList[i].cssRules;
        for (j=0; j<ruleList.length; j++)
        {
            if (ruleList[j].type == CSSRule.STYLE_RULE &&
                ruleList[j].selectorText == selector)
            {
                return ruleList[j].style;
            }   
        }
    }
    return null;
}

setBrowser();
