var pos=-1;
var links=new Array;


function addLink(node)
{
	// Link zur Liste hinzufügen
	pos=pos+1
	links[pos]=node
	links=links.slice(0,pos+1) 
	goToLink(node)
	//alert("PathB:" + node['path'])
	//alert("addLink:" +node['extension'])
	//debug ("addedLink");
}

function go(deltaPos)
{
	
	
	pos=pos+deltaPos;
	
	if (pos<0)
	{
		pos=0;
	}
	
	if (pos>(links.length-1))
	{
		pos=links.length-1
	}
	
	
	openBranchCore(links[pos]['id'],0 , "")
	goToLink(links[pos])
}

function einblenden(breite)
{
	parent.document.getElementById("sidebar").cols="5,*,5," + breite;
	if (breite < 200)
	{
		setTimeout("einblenden("+(breite+10)+")",25);
	}
}

function ausblenden(breite)
{
	parent.document.getElementById("sidebar").cols="5,*,5," + breite;
	if (breite > 0)
	{
		setTimeout("ausblenden("+(breite-10)+")",25);
	}
}

function goToLink(historyElement)
{
	//parent.contentmain.document.clear;
	//debug("goToLink: " + historyElement['topic'])
	//alert("Path:" + historyElement['path'])
	parent.contenttopic.location="/constant/contenttopic.php?text=" + historyElement['topic']

	if (admin || (historyElement['access'] == 0) || (historyElement['access'] == 3))
	{
		extension="";
		
		if(historyElement['extension'])
		{
			//alert("ext: " + historyElement['extension'] + "\n loc: " + parent.contentmain.location);
			extension="?" +	historyElement['extension']	;	
		}
		
		switch (historyElement['php']) 
		{
		case 0:
			parent.contentmain.location="/"+historyElement['path']+"/contentmain.htm";
			break;
		case 1:
			parent.contentmain.location="/"+historyElement['path']+"/contentmain.php" + extension;
			break;
		case 2:
			parent.contentmain.location="/"+historyElement['path']+"/contentmain.php" + extension;
			break;
		}
				
		
	}else{
		
		// Baustellen anzeigen
		switch (historyElement['access']) 
		{
		  case 1:
			parent.contentmain.location="/constant/umbau.htm";
			break;
		  case 2:
			parent.contentmain.location="/constant/baustelle.htm";
			break;
		}
	}
	
	if(admin && parent.adminbar)
	{
		parent.treezustand.location="/constant/treezustand.php";
		parent.adminbar.location="/constant/adminbar.php?id=" + historyElement['id'] + "&path=" + historyElement['path'] + "&access=" + historyElement['access'] + "&php=" + historyElement['php'] + "&pathname=" + historyElement['pathname'];	
	}
	
	if (historyElement['id'] == 0)
	{
		parent.change.location="/constant/change.php";
		parent.newsmain.location="/constant/newsmain.php";
		if (links[pos-1]['id']!=0)
		{
			einblenden(0);
		}
	}
	else
	{
		if (links[pos-1]['id']==0)
		{
			ausblenden(200);
		}
	}
}

function debug(header)
{
	var msg="Header: " +header +"\n Pos:" + pos +"\n";
	for (var i = 0; i <= links.length-1; i++)
	{
  		lnk=links[i]
		
		msg+="\n \n Nr:" + i + " \n link:" + lnk['path'] + "\n Titel:" + lnk['topic'];
	}
	
	alert(msg)	
}


