

function liveforum()
{
  
  if(SupportsAjax()){
  	SimpleAJAXCall('/ajax/a_forum.php',liveforum_resp);
 }    
}

  



function liveforum_resp(in_text)
{
 

    
	var threads = in_text.parseJSON();
	
 
 
	var lastthreads = document.getElementById('lastthreads');
	var fading=false;
	var cur_update = true;

	for (var i = 0; i < threads.length; i++) {

	cur_update = true;
	    if ( document.getElementById(threads[i]['threadid']) ) {

		var removeobj = document.getElementById(threads[i]['threadid']);

		if ( removeobj.getAttribute("title") != threads[i]['lastpostid'] ) {
			cur_update = true;	
			removeobj.style.overflow = "hidden";
			removeobj.style.display = "block_live";
			removeobj.parentNode.removeChild(removeobj);

		} else {
			cur_update = false;
		}
	    }

	if ( cur_update ) {
		 if (threads[i]['title'].length > 29 ) {
		 threads[i]['title_long'] = threads[i]['title'].substr(0, 25)+"..";
		 } else { threads[i]['title_long'] = threads[i]['title']; }

		
		 if (threads[i]['forumtitle'].length > 16 ) {
		 threads[i]['forumtitle_long'] = threads[i]['forumtitle'].substr(0, 14)+"..";
		 } else { threads[i]['forumtitle_long'] = threads[i]['forumtitle']; }


		// Zeile erstellen  
		var newRow = document.createElement("tr");
		newRow.setAttribute("class","row_kalender");
		newRow.setAttribute("id",threads[i]['threadid']);
		newRow.setAttribute("title",threads[i]['lastpostid']);
		newRow.style.visibilty = "hidden";

		// Erste Spalte erstellen
		var newCol = document.createElement("td");
		newCol.setAttribute("align","right");
		newCol.setAttribute("nowrap","nowrap");
		newCol.style.paddingRight = "4px";

		// Text der Spalte

		var newSpan = document.createElement("span");
		newSpan.setAttribute("class","gensmall");
		var newText = document.createTextNode(threads[i]['lastpost']);
		newSpan.appendChild(newText);

		// Spalte in Zeile einfügen
		newCol.appendChild(newSpan);
		newRow.appendChild(newCol);

		// Zweite Spalte erstellen
		var newCol = document.createElement("td");
		var newSpan = document.createElement("span");
		newSpan.setAttribute("class","gensmall");
		var newA = document.createElement("a");
		newA.setAttribute("href","/forum/showthread.php?p="+threads[i]['lastpostid']+"#post"+threads[i]['lastpostid']);
		newA.setAttribute("class","dark");
		newA.innerHTML = threads[i]['title_long'];
		newSpan.appendChild(newA);

		if ( threads[i]['event_date'] != null )
		 {
		  var newInSpan = document.createElement("span");
		  newInSpan.innerHTML = "// "+threads[i]['event_date'];
		  newSpan.appendChild(newInSpan);
		 }



		// Spalte in Zeile einfügen
		newCol.appendChild(newSpan);
		newRow.appendChild(newCol);


		// Dritte Spalte erstellen
		var newCol = document.createElement("td");
		var newSpan = document.createElement("span");
		newSpan.setAttribute("class","gensmall");
		var newA = document.createElement("a");
		newA.setAttribute("href","/forum/member.php?find=lastposter&t="+threads[i]['threadid']);
		newA.setAttribute("class","dark");
		var newText = document.createTextNode(threads[i]['lastposter']);
		newA.appendChild(newText);
		newSpan.appendChild(newA);

		// Spalte in Zeile einfügen
		newCol.appendChild(newSpan);
		newRow.appendChild(newCol);

		if ( show_forum ) {
			// Vierte Spalte erstellen
			var newCol = document.createElement("td");
			var newSpan = document.createElement("span");
			newSpan.setAttribute("class","gensmall");
			var newA = document.createElement("a");
			newA.setAttribute("href","/forum/forumdisplay.php?f="+threads[i]['forumid']);
			newA.setAttribute("class","dark");
			newA.innerHTML = threads[i]['forumtitle_long'];
			newSpan.appendChild(newA);

			// Spalte in Zeile einfügen
			newCol.appendChild(newSpan);
			newRow.appendChild(newCol);
		}


		var lastthreads_head = document.getElementById('lastthreads_head');
		lastthreads_head.parentNode.insertBefore(newRow,lastthreads_head.nextSibling);

		var myFx = new Fx.Opacity(newRow, {duration: 300}).custom(0, 1);
		myFx.toggle();


		// var length = ( lastthreads.childNodes[1].childNodes.length - 2 );
		// if ( lastthreads.childNodes[1].childNodes[length] ) {
		//	lastthreads.removeChild(lastthreads.childNodes[1].childNodes[length]);
		// }
	  
	 }
	}
	 liveforum();
 
}

 liveforum();