// name - имя cookie
// value - значение cookie
// [expires] - дата окончания действия cookie (по умолчанию - до конца сессии)
// [path] - путь, для которого cookie действительно (по умолчанию - документ, в котором значение было установлено)
// [domain] - домен, для которого cookie действительно (по умолчанию - домен, в котором значение было установлено)
// [secure] - логическое значение, показывающее требуется ли защищенная передача значения cookie



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" : "");
               document.cookie = curCookie;

}

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))
}

function set_menu()
{
	var input = document.getElementsByTagName("div");
	for (var i = 0; i < input.length; i++)
	{
		var name = input[i].getAttribute("id");
		if(getCookie(name)==1)
		{
			input[i].style.display='';
		}
	}
}

function show_sub(id)
{
	var el=document.getElementById(id).style;
	if(el.display=='none')
	{
		el.display='';
		setCookie(id,'1',null,'/');
	}
	else
	{
		el.display='none';
		setCookie(id,'0',null,'/');
	}
}
