SubMenu = {
	id: null,
	idHandler: null,
	cookiePrefix: 'submenu',
	construct: function(id)
	{
		this.id = id;
		this.idHandler = document.getElementById(id);
	},
	setSubMenu: function ()
	{
		var isShowed = this.isSubMenuShowed();
		this.showSubMenu(!isShowed);
	},
	showSubMenu: function (value)
	{
		this.idHandler.style.display = ((value === true) ? 'block' : 'none');
		this.setCookie(value);
	},
	isSubMenuShowed: function ()
	{
		return (this.idHandler.style.display == 'block' || this.idHandler.style.display == '');
	},
	setCookie: function ()
	{
		document.cookie = this.cookiePrefix + this.id + '=' + (this.isSubMenuShowed() === true ? 1 : 0);
	},
	getCookie: function ()
	{
		var ret = null;
		var findVar = this.cookiePrefix + this.id + '=';
		var myCookie = ' ' + document.cookie + ';';
		var startCookie = myCookie.indexOf(findVar);
		var endCookie;
		if (startCookie != -1)
		{
			startCookie += findVar.length;
			endCookie = myCookie.indexOf(';', startCookie);
			ret = myCookie.substring(startCookie, endCookie);
		}
		return ret;
	},
	startSubMenu: function (id)
	{
		this.construct(id);
		var isShowed = this.getCookie(this.id);
		if(isShowed !== null)
		{
			if(parseInt(isShowed) === 1)
			{
				this.showSubMenu(true);
			}
			else
			{
				this.showSubMenu(false);
			}
		}
		this.idHandler.parentNode.firstChild.onclick = function () {
			 SubMenu.setSubMenu();
		}
	}
}
 
function fSubMenu(id)
{
	SubMenu.startSubMenu(id);
}
