
var arrX = new Array();
var arrY = new Array();
var rootCoords = {x: 0,y: 0};

var mcount = 0;

var currentY = 0;


function kutulu() 
	{
	
	rootCoords = getPageCoords(document.getElementById('layRoot')); 
	rootCoords.y += 6;
	
	for( i=0; i<6; i++)	
		{ 
		arrX[i] = rootCoords.x + (250*i); 
		if( i==1) arrX[i] -= 50;
		if( i>0 ) arrX[i] -= 30;
		} 
	
	currentY = rootCoords.y;
	
	}


function Item()
	{
	this.name_it = '';
	this.name_en = '';
	this.html_it = '';
	this.html_en = '';
	this.id = 0;
	this.level = 0;
	this.reqreg = 0;
	}

function roth(n)
	{
	theBody = document.getElementsByTagName('body')[0];
	allDivs = document.getElementsByTagName('div');
	l = allDivs.length;

	arr2kill = new Array();
	i2k = 0;

		
		
		for(i=0;i<l;i++)
			{
			
			if( allDivs[i].id != 'layRoot' )
			
			if( parseInt(allDivs[i].style.left) > arrX[n] )
				{
				arr2kill[i2k++] = allDivs[i].id;
				}
			}
		
		
		
		for(i=0;i<i2k;i++)
			{
			
			theBody.removeChild(document.getElementById(arr2kill[i]));
			mcount = n+1;
			}
		
	
	}

function stdes(d)
	{
	document.getElementById('layDesc').innerHTML = unescape(d);
	}

function highthis(o)
	{
	arr0 = document.getElementsByTagName('A');
	
	for(q=0;q<arr0.length;q++)
		{
		thzcrd = getPageCoords(o);
		thtcrd = getPageCoords(arr0[q]);
		if(thzcrd.x == thtcrd.x)
			arr0[q].style.color = '#404040';
		}
	
	o.style.color = '#61a5d4';
	}

function yig(ai)
	{
	newDiv = document.createElement('div');
	newDiv.id = 'lay' + mcount;
	newDiv.style.left = arrX[mcount]+'px';
	newDiv.style.width = '300px';
	newDiv.style.height = '400px';
	newDiv.style.position = 'absolute';
	newDiv.style.marginLeft = '8px';
//	newDiv.style.top = rootCoords.y;
	newDiv.style.top = currentY+'px';
	
	var content = '';
	
	if( mcount < 1) 
		content += '<table  width="300" cellpadding="1">';
	else
		content += '<table style="border: 1px solid #e0e0e0; background-color: #ffffff;" width="300"  cellpadding="1">';
	
	for(i=0;i<ai.length;i++)
		{
		if( ai[i].level < 3 )
			{
			// CONTROLLARE SE IL NODO RICHIEDE UTENTE REGISTRATO
			if( ai[i].reqreg )
				{
				if(usrlogged)
					{
					content += '<tr><td>&nbsp;<a href="javascript:;;" class="lnkMnu" onclick="highthis(this); currentY=' + (parseInt(newDiv.style.top) + (i*20)) + '; stdes(\''+ escape(ai[i].html_it) + '\'); roth(' + mcount + '); worg(' + ai[i].id + ')">' + ai[i].name_it + '</a></td></tr>';
					}
				else
					{
					content += '<tr><td>&nbsp;<span class="lnkMnuOff">' + ai[i].name_it + '</span></td></tr>';
					}
				}
			else
				{
				content += '<tr><td>&nbsp;<a href="javascript:;;" class="lnkMnu" ' + (mcount < 1 ? ' style="font-size: 10pt;" ' : ' ') + 'onclick="highthis(this); currentY=' + (parseInt(newDiv.style.top) + (i*20)) + '; stdes(\''+ escape(ai[i].html_it) + '\'); roth(' + mcount + '); worg(' + ai[i].id + ')">' + ai[i].name_it + '</a></td></tr>';
				}
			}
		else
			{
			// CONTROLLARE SE IL NODO RICHIEDE UTENTE REGISTRATO
			if( ai[i].reqreg)
				{
				if(usrlogged)
					{
					content += '<tr><td>&nbsp;<a href="prodotto.php?node=' + ai[i].id + '" class="lnkMnu">' + ai[i].name_it + '</a></td></tr>';
					}
				else
					{
					content += '<tr><td>&nbsp;<span class="lnkMnuOff">' + ai[i].name_it + '</span></td></tr>';
					}
				}
			else
				{
				content += '<tr><td>&nbsp;<a href="prodotto.php?node=' + ai[i].id + '" class="lnkMnu">' + ai[i].name_it + '</a></td></tr>';
				}
			
			}
		}
	
	content += '</table>';
	newDiv.innerHTML = content;	
	theBody = document.getElementsByTagName('body')[0];
	theBody.appendChild(newDiv);
	mcount++;
	}
