var arrRoots=Array();
var crtRoot=0;
var lastRoot=0;
function doShow(_id, _img)
{
	for(i=0; i<arrRoots.length; i++)
	{
		if(arrRoots[i]==_id)// este root
		{
			if(crtRoot != arrRoots[i])
			{
				lastRoot= crtRoot;
				crtRoot	= arrRoots[i];
			}
			else
			{
				lastRoot= crtRoot;
			}
			break;
		}
		else
		{
			lastRoot= crtRoot;
		}
	}
	if(crtRoot != lastRoot)
	{
		arrSpan=document.getElementsByTagName('span');
		for(i=0; i<arrSpan.length; i++)
		{
			arrSpan[i].className = 'hide';
		}
		arrImg=document.getElementsByTagName('img');
		for(i=0; i<arrImg.length; i++)
		{
			if(arrImg[i].src.search('png')!=-1)
			{
				arrImg[i].src='http://www.oco.ro/images/b_plus.png';
			}
		}
	}
	if(document.getElementById(_id) != null)
	{
		if(document.getElementById(_id).className=='show')
		{
			document.getElementById(_id).className = 'hide';
			document.getElementById('i'+_img).src = 'http://www.oco.ro/images/b_plus.png';
		}
		else
		{
			document.getElementById(_id).className = 'show';
			document.getElementById('i'+_img).src = 'http://www.oco.ro/images/b_minus.png';
		}
	}
	arr_show = document.getElementsByTagName('span');
	arr_ids  = new Array();
	for(i=0; i<arr_show.length; i++)
	{
		if(arr_show[i].className=='show')
		{
			arr_ids.push(arr_show[i].id);
		}
	}
	str = arr_ids.toString();
	if(str.length>0)
	{
		eraseCookie('visible');
		setCookie('visible', str, 1);
	}
}


function setCookie(name,value,days)
{
	if(days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	setCookie(name,"",-1);
}


function show(obj)
{
	obj.style.display='';
}

window.onload = function()
{
	str = getCookie('visible');
	if(!str)
	{
		return;
	}
	arr = str.split(',');
	for(i=0; i<arr.length; i++)
	{
		idimg = 'i'+(arr[i]-1);
		if(document.getElementById(idimg))
		{
			document.getElementById(idimg).src='http://www.oco.ro/images/b_minus.png';
		}
		if(document.getElementById(arr[i]))
		{
			document.getElementById(arr[i]).className='show';
		}
	}
} 
