byz_ecm_menu_status = new Array();

function byz_ecm_showhide(theid)
{
	if (document.getElementById)
	{
		var switch_id = document.getElementById(theid);
		var img_id = document.getElementById(theid+'_cursor');
		if(byz_ecm_menu_status[theid] != 'byz_ecm_cu_show')
		{
			switch_id.className = 'byz_ecm_cu_show';
			byz_ecm_menu_status[theid] = 'byz_ecm_cu_show';
			//set image cursor
			img_id.setAttribute('src',byz_ecm_image_minus);
			//set cookie
			byz_ecm_set_cookie(theid,'byz_ecm_cu_hide');
		}
		else
		{
			switch_id.className = 'byz_ecm_cu_hide';
			byz_ecm_menu_status[theid] = 'byz_ecm_cu_hide';
			//set image cursor
			img_id.setAttribute('src',byz_ecm_image_plus);
			//set cookie
			byz_ecm_set_cookie(theid,'byz_ecm_cu_show');
		}
	}
}

function byz_ecm_showhideall()
{
	var menuState;
	var img_id;
	var z;
	for (z=0; z<byz_ecm_max_categories; z++)
	{
		if (document.getElementById('byz_ecm_cu_mymenu'+z))
		{
			menuState = byz_ecm_get_cookie ('byz_ecm_cu_mymenu'+z);
			if (menuState != null)
			{
				byz_ecm_menu_status['byz_ecm_cu_mymenu'+z]=menuState;
				byz_ecm_showhide('byz_ecm_cu_mymenu'+z);
				//set image cursor
				img_id = document.getElementById('byz_ecm_cu_mymenu'+z+'_cursor');
				if(menuState=='byz_ecm_cu_hide')
				{
					img_id.setAttribute('src',byz_ecm_image_minus);
				}
				else
				{
					img_id.setAttribute('src',byz_ecm_image_plus);
				}
			}
		}
	}
}

function byz_ecm_get_cookie ( cookie_name )
{
	var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
	if ( results )
		return ( unescape ( results[1] ) );
	else
		return null;
}

function byz_ecm_set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
	var cookie_string = name + "=" + escape ( value );
	if ( exp_y )
	{
		var expires = new Date ( exp_y, exp_m, exp_d );
		cookie_string += "; expires=" + expires.toGMTString();
	}
	if ( path )
		cookie_string += "; path=" + escape ( path );
	if ( domain )
		cookie_string += "; domain=" + escape ( domain );
	if ( secure )
		cookie_string += "; secure";
	document.cookie = cookie_string;
}