///// Stand 04.01.2008
//
var ForumPreview=false;
var ForumTopicnrNow;
var ForenThemenNrNow;
var ForumTitelNow;
var ForumSeiteNow;
var forumFirstTopicNrNow=0;
var ThreadStat=0;

function forentopicheader( ident, stats, titel, beschreibung, inner, themen, lastPostThema, lastPost, lastPostWann, moderator, lastPostTopicNr, lastPostStats){
// Foren Topic Objekte für den Header Bereich.
	this.ident=ident;			// Id innerhalb der DB.
	this.stats=stats;			// Status des Topics.
	this.titel=titel;			// Titel des Topics.
	this.beschreibung=beschreibung;		// Beschreibung des Topics.
	this.inner=inner; 			//Beträge, Anzahl der Beträge innerhalb des Topics.
	this.themen=themen;			// Anzahl der Threads innerhalb des Topics.
	this.lastPostThema=lastPostThema;	// Thema des Letzten Posts.
	this.lastPost=lastPost;			// Verfasser des letzten Posts.
	this.lastPostWann=lastPostWann;		// Zeitpunkt des Letzten Posts.
	this.lastPostTopicNr=lastPostTopicNr;	// TopicNr des Letzten Posts.
	this.lastPostStats=lastPostStats;	// Status des Letzten Post Threads ( Offen / Geschlossen ).
	this.moderator=moderator;		// Moderator des Topics.

	this.draw = function (from) {
	// Gibt die Darstellung des Header Topics in HTML form zurück
		out='	<tr>';
		out+='		<td class="mBoxTitel4" align="Center" style="border-top: 0px none;">';
		out+='			<img src="gfx/stats_'+this.stats+'.png">';
		out+='		</td>';
		out+='		<td class="mBoxTitel4" onclick="'+from+'.addForenPfad(\''+this.titel+'\',\''+this.ident+'\',\''+this.stats+'\');'+from+'.loadForenTopics('+this.ident+','+this.stats+');" style="cursor: pointer; border-top: 0px none; border-left: 0px none;">';
		out+='			<b>'+this.titel+'</b><br>';
		out+='			<small>'+this.beschreibung+'</small>';
		out+='		</td>';
		out+='		<td class="mBoxTitel4" align="center" style="border-top: 0px none; border-left: 0px none;">';
		out+='			'+this.inner;
		out+='		</td>';
		out+='		<td class="mBoxTitel4" align="center" style="border-top: 0px none; border-left: 0px none;">';
		out+='			'+this.themen;
		out+='		</td>';
		out+='		<td class="mBoxTitel4" onclick="ForumTitelNow=\''+this.lastPostThema+'\'; ThreadStat=\''+this.lastPostStats+'\'; ForumTopicnrNow=\''+this.lastPostTopicNr+'\';'+from+'.loadThread3(\''+this.lastPostThema+'\',\''+this.lastPostTopicNr+'\');" style="cursor: pointer; border-top: 0px none; border-left: 0px none;">';
		if(this.lastPostThema!=""){
			out+='			<b';
			out+='			>'+this.lastPostThema+'</b><br>';
			out+='			<small><b>'+forenDatum(this.lastPostWann)+'</b> von '+this.lastPost+'</small>';
		}
		else{
			out+=' &nbsp; ';
		}
		out+='		</td>';
		out+='		<td class="mBoxTitel4" align="center" style="border-top: 0px none; border-left: 0px none;">';
		out+='			'+this.moderator;
		out+='		</td>';
		out+='	</tr>';
		
		return out;
	}
}

function forenDatum(Timestamp){
	var AktuellZeit=new Date();
	Heute=fillStringToTwo(AktuellZeit.getDate())+'.'+fillStringToTwo((AktuellZeit.getMonth()+1))+'.'+fillStringToTwo(AktuellZeit.getFullYear());
	AktuellZeit.setTime(Timestamp*1000);
	tag=fillStringToTwo(AktuellZeit.getDate())+'.'+fillStringToTwo((AktuellZeit.getMonth()+1))+'.'+fillStringToTwo(AktuellZeit.getFullYear());
	if(Heute==tag){
		DatumOut='<small style="color: #bfb273">Heute</small>';
	}
	else{
		DatumOut=tag;
	}
	Zeit = fillStringToTwo(AktuellZeit.getHours())+':'+fillStringToTwo(AktuellZeit.getMinutes());

	return DatumOut + ' ' + Zeit;

//	return Timestamp;
}

function fillStringToTwo(zahl){
	zahl=""+zahl;
	if(zahl.length<2){
		zahl="0"+zahl;
	}
	return zahl;
}

function forenttopic (ident, stats, titel, antworten, autor, views, lastPost, lastPostWann) {
// Foren topic Objekte für den Topic Bereich
	this.ident=ident;			// Id innerhalb der DB.
	this.stats=stats;			// Status des Topics.
	this.titel=titel;			// Titel des Topics.
	this.antworten=antworten;		// Anzahl der Antworten des Topics.
	this.autor=autor;			// Autor, des Topics.
	this.views=views;			// Anzahl wie oft das Topic angesehen wurde
	this.lastPost=lastPost;			// Autor des Letzten Posts.
	this.lastPostWann=lastPostWann;		// Zeitpunkt des Letzten Posts.
	this.draw = function (who) {
	// Gibt die Darstellung des Topics in HTML form zurück.
		out=' 	<tr>';
		out+='		<td class="mBoxTitel4" align="Center" style="border-top: 0px none;">';
		out+='			<img src="gfx/stats_'+this.stats+'.png">';
		out+='		</td>';
		if(this.stats<2 || userart=="admin"){
			out+='		<td class="mBoxTitel4" style="cursor: pointer; border-top: 0px none; border-left: 0px none;" onClick="ForumTitelNow=\''+this.titel+'\'; ThreadStat=\''+this.stats+'\'; ForumTopicnrNow=\''+this.ident+'\';'+who+'.loadThread(\''+this.titel+'\',\''+this.ident+'\');">';
		}
		else{
			out+='		<td class="mBoxTitel4" style="cursor: pointer; border-top: 0px none; border-left: 0px none;" onClick="alert(\'\t\t Thread wurde Ausgeblendet !\t\t\t\t\');">';
		}
		out+='			'+this.titel;
		out+='		</td>';	
		out+='		<td class="mBoxTitel4" align="Center" style="border-top: 0px none; border-left: 0px none;">';
		out+='			'+this.antworten;
		out+='		</td>';		
		out+='		<td class="mBoxTitel4" align="Center" style="border-top: 0px none; border-left: 0px none;">';
		out+='			'+this.autor;
		out+='		</td>';
		out+='		<td class="mBoxTitel4" align="Center" style="border-top: 0px none; border-left: 0px none;">';
		out+='			'+this.views;
		out+='		</td>';
		out+='		<td class="mBoxTitel4" align="right" style="cursor: pointer; border-top: 0px none; border-left: 0px none;" onClick="ForumTitelNow=\''+this.titel+'\'; ThreadStat=\''+this.stats+'\'; ForumTopicnrNow=\''+this.ident+'\';'+who+'.loadThread3(\''+this.titel+'\',\''+this.ident+'\');">';
		if(this.lastPost!=" "){
			out+='			<small><b>'+forenDatum(this.lastPostWann)+'</b><br>';
			out+='	  		von '+this.lastPost+'</small>';
		}
		out+='		</td>';		
		out+='	</tr>';

		return out;
	}
}

function forenautor(name, art, avatar,counter){
// Autoren Objekt für das Einfügen in den Autoren Bereich der Threads.
		out='<b>'+name+'</b><br>';
		out+='<small>'+art+'</small>';
		out+='<center><img src="gfx/avatar/'+avatar+'" onClick="if(Login){ajaxpage(\'module/openOtherProfil.php\',\'LoginBoxChoicer\',\'=d&nick='+encodeURIComponent(name)+'\',\'\',true);}"></center><br>';
		out+='<small>beitr&auml;ge : '+counter+'</small>';
		return out;
}

function forentThread (ident, Signatur, autor, post, wann, lastEdit, buttonList, postNummer, art, avatar, counter, objektname) {
// Post Objekt.
	this.ident=ident;			// Id des Posts innehalb der Datenbank.
	this.autor=autor;			// Autorobjekt des Posts ( Verweis auf das Objekt forenautor welches auch die
						// ausgabe erzeugen soll.
	this.post=post;				// Inhalt des Posts.
	this.wann=wann;				// Zeitpunkt des Posts.
	this.lastEdit=lastEdit;			// Zeitpunkt des Letzten Edit'S des post.
	this.buttonList=buttonList;		// Art der ButtonLeiste.
						// 0 = Admin Modus Melden = Editieren Button.
						// 1 = User Modus Alle Buttons Normal
						// 2 = Poster Modus Zitieren = editieren.
						// 3 = Gast Modus Keine Buttons.

	this.postNummer=postNummer;		// Nummer des Posts.
	this.avatar=avatar;
	this.counter=counter;
	this.art=art;
	this.autor=autor;
	this.objektname=objektname;
	this.Signatur=Signatur;

	this.draw = function (who) {
		this.buttonList=1;
		if(userart=="gast"){
			this.buttonList=3;
		}
		if(this.autor==user){
			this.buttonList=2;
		}
		if(ThreadStat>0){
			this.buttonList=3;
		}
		if(userart=="admin") {
			this.buttonList=0;
		}
	// Gibt den Post in HTML Form zurück.
		out='<tr>';
		out+='	<td class="mBoxtitel4" style="font-size: 9px; vertical-align: top; border-bottom: 0px none;" valign="top" width="125px;">';
		out+='	'+forenautor(this.autor, this.art, this.avatar, this.counter);
		out+='	</td>';
		out+='	<td class="mBoxTitel4" style="font-size: 11px; vertical-align: top; border-bottom: 0px none;" colspan="6" valign="top">';
		out+=' 	<table cellpadding="0" cellspacing="0" height="100%" width="100%"><tr>';
		out+='	<td class="mBoxTitel3" style="border: 0px none;">'+ bbcode( this.post );
		if(this.wann != this.lastEdit){
			out+='	<br><br><hr>';
			out+='  <small>Letzte &Auml;nderung : ' + forenDatum(this.lastEdit) + '</small>';		
		}
		out+=' <br><br></td>';
		if(this.Signatur!="none"){
			out+='	</tr><tr>';
			out+='  <td class="mBoxTitel3" style="bottom: 0px; border: 0px none; vertical-align: top;"><hr><div class="mBoxTitel3" style="max-height: 80px; max-width: 310px; overflow: hidden; border: 0px;">' + bbcode(this.Signatur) + '</div></td>';		
		}
		out+=' 	</table>';
		out+='	</td>';
		out+='</tr>';
		out+='</table><table cellpadding="2" cellspacing="0" border="0" width="100%">';
		out+='<tr>';
		out+='	<td class="mBoxtitelD" style="font-size: 9px; width: 125px; border-top: 0px none;" align="right" width="125px">';
		out+='	'+ forenDatum(this.wann);
		out+='	</td>';
		if(this.buttonList<3) {out+='	<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer; width:50px;" align="center" width="50px" OnClick="'+who+'.drawPMFeld(\''+this.autor+'\');">PM</td>'; }
		if(this.buttonList==3) { out+='	<td class="mBoxTitelD" style="font-size: 9px; width: 50px;" align="center" width="50px;">&nbsp;</td>'; }
		if(this.buttonList==0) { out+='	<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer; width:50px;" align="center" width="50px" OnClick="'+who+'.drawEditFeld('+this.objektname+'.post,\''+this.ident+'\');">Edit</td>';  }
		if(this.buttonList>0 && this.buttonList<3) { out+='	<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer; width: 50px;" align="center" width="50px" onClick="alert(\'Coming Soon...\');">Melden</td>'; }
		if(this.buttonList==3) { out+='	<td class="mBoxTitelD" style="font-size: 9px;" align="center" width="50px">&nbsp;</td>'; }
		out+='	<td class="mBoxTitelD" style="font-size: 9px; border-top: 0px none;" align="left">';
		out+='  	&nbsp;';
		out+='	</td>';
		if(this.buttonList<3) { out+='	<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer; width: 50px;" align="center" width="50px" OnClick="'+who+'.drawAntwortFeld(\'\');">Antworten</td>'; }
		if(this.buttonList==3) { out+='	<td class="mBoxTitelD" style="font-size: 9px; width: 50px;" align="center" width="50px">&nbsp;</td>'; }		
		if(this.buttonList<2) { out+='	<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer; width: 50px;" align="center" width="50px"  OnClick="'+who+'.drawAntwortFeld(\'[quote='+this.autor+']\'+'+this.objektname+'.post+\'[/quote]\',\''+this.ident+'\');">Zitieren</td>'; }
		if(this.buttonList==2) { out+='	<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer; width: 50px;" align="center" width="50px" OnClick="'+who+'.drawEditFeld('+this.objektname+'.post,\''+this.ident+'\');">Edit</td>'; }
		if(this.buttonList==3) { out+='	<td class="mBoxTitelD" style="font-size: 9px; text-align: center; width50px;" align="center" width="50px">&nbsp;</td>'; }
		if(this.buttonList!=0) { out+='	<td class="mBoxTitelD" style="font-size: 9px; text-align: center; width: 50px;" align="center" width="50px"> '+formatNumber(this.postNummer,3)+'</td>'; }
		if(this.buttonList==0) { out+='	<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer; width: 50px;" align="center" width="50px" title="Post L&ouml;schen" onClick="if(confirm(\'Wollen Sie den Post wirklich L&ouml;schen ?\')){ajaxpage(\'module/delPost.php\',\''+who+'ForenLoading\',\'=d&postid='+this.ident+'\',\''+who+'.loadThread2(\\\''+ForumTitelNow+'\\\',ForumTopicnrNow,ForumSeiteNow);\');}"> '+formatNumber(this.postNummer,3)+'</td>'; }		
		out+='</tr></table><table cellpadding="2" cellspacing="0" border="0" width="100%">';
		return out;
	}
}

function forum ( ident ){
	this.set=true;
	this.ident=ident;
	this.forenId=0;
	this.topicnr=0;
	this.ForenPfad=new Array();
	this.topicForen=new Array();
	this.topicThemen=new Array();
	this.topicThread=new Array();

	this.delSavedThread=function (ident){
		while(this.topicThread.length>0){
			this.topicThread.pop();
		}
		return true;
	}
	this.delSavedtopicForen=function (ident){
		while(this.topicForen.length>0){
			this.topicForen.pop();
		}
		return true;
	}
	this.delSavedtopicThemen=function (ident){
		while(this.topicThemen.length>0){
			this.topicThemen.pop();
		}
		return true;
	}
	
	this.addForenPfad=function(newPfad, topicnr, stats){
//		alert(newPfad+', '+topicnr);
		newpfadinner='<b onclick="'+this.ident+'.setForenPfad('+(this.ForenPfad.length+1)+');'+this.ident+'.loadForenTopics('+topicnr+','+stats+');" style="cursor: pointer;">'+newPfad+'</b>';
		this.ForenPfad.push(newpfadinner);
	}
	this.setForenPfad=function(At){
		while(this.ForenPfad.length>At){
			this.ForenPfad.pop();
		}
		
	}
	this.drawForenPfad=function(){
		if(this.ForenPfad.length>0){

		return " > " + this.ForenPfad.join(" > ");
		}
		return '';
	}

	this.readForenThread = function ( ident ) {
		Trenner=document.getElementById('ForenId').value.substr(0,1);		
		ForenIdList=document.getElementById('ForenId').value.split(Trenner);
		ForenAutorList=document.getElementById('ForenAutor').value.split(Trenner);
		ForenPostList=document.getElementById('ForenPost').value.split(Trenner);
		ForenSignaturList=document.getElementById('ForenSignatur').value.split(Trenner);
		ForenWannList=document.getElementById('ForenWann').value.split(Trenner);
		ForenLastEditList=document.getElementById('ForenLastEdit').value.split(Trenner);
		ForenButtonListList=document.getElementById('ForenButtonList').value.split(Trenner);
		ForenPostNummerList=document.getElementById('ForenPostNummer').value.split(Trenner);
		ForenArtList=document.getElementById('ForenArt').value.split(Trenner);
		ForenAvatarList=document.getElementById('ForenAvatar').value.split(Trenner);
		ForenCounterList=document.getElementById('ForenCounter').value.split(Trenner);
		for(i=1; i<ForenIdList.length;i++){
			this.topicThread[i-1]=new forentThread(ForenIdList[i],ForenSignaturList[i], ForenAutorList[i], ForenPostList[i], ForenWannList[i], ForenLastEditList[i], ForenButtonListList[i], ForenPostNummerList[i], ForenArtList[i], ForenAvatarList[i], ForenCounterList[i], 'Forum.topicThread['+(i-1)+']');
		}

	}

	this.readForenThemen = function ( ident ) {
		Trenner=document.getElementById('ForenId').value.substr(0,1);
		ForenIdList=document.getElementById('ForenId').value.split(Trenner);
		ForenStatsList=document.getElementById('ForenStats').value.split(Trenner);
		ForenAntsList=document.getElementById('ForentAnts').value.split(Trenner);		
		ForenTitelList=document.getElementById('ForenTitel').value.split(Trenner);
		ForenAutorList=document.getElementById('ForenAutor').value.split(Trenner);
		ForenViewsList=document.getElementById('ForenViews').value.split(Trenner);
		ForenLastPostList=document.getElementById('ForenLastPost').value.split(Trenner);
		ForenLastPostWannList=document.getElementById('ForenLastPostWann').value.split(Trenner);
		for(i=1; i<ForenIdList.length;i++){
			this.topicThemen[i-1]=new forenttopic (ForenIdList[i], ForenStatsList[i], ForenTitelList[i], ForenAntsList[i], ForenAutorList[i], ForenViewsList[i], ForenLastPostList[i], ForenLastPostWannList[i]);
		}
	}

	this.readForenTopics = function ( ident ) {
		Trenner=document.getElementById('ForenId').value.substr(0,1);
		ForenIdList=document.getElementById('ForenId').value.split(Trenner);
		ForenStatsList=document.getElementById('ForenStats').value.split(Trenner);
		ForenTitelList=document.getElementById('ForenTitel').value.split(Trenner);
		ForenBeschreibungList=document.getElementById('ForenBeschreibung').value.split(Trenner);
		ForenModeratorList=document.getElementById('ForenModerator').value.split(Trenner);
		ForenInnerList=document.getElementById('ForenInner').value.split(Trenner);
		ForenThemenList=document.getElementById('ForenThemen').value.split(Trenner);
		ForenlastPostThemaList=document.getElementById('ForenLastPostThema').value.split(Trenner);
		ForenLastPostList=document.getElementById('ForenLastPost').value.split(Trenner);
		ForenLastPostWannList=document.getElementById('ForenLastPostWann').value.split(Trenner);
		ForenLastPostTopicNr=document.getElementById('ForenLastPosttopicnr').value.split(Trenner);
		ForenLastPostStats=document.getElementById('ForenLPStats').value.split(Trenner);		
		for(i=1; i<ForenIdList.length;i++){
			this.topicForen[i-1]=new forentopicheader( ForenIdList[i], ForenStatsList[i], ForenTitelList[i], ForenBeschreibungList[i], ForenInnerList[i], ForenThemenList[i], ForenlastPostThemaList[i], ForenLastPostList[i], ForenLastPostWannList[i], ForenModeratorList[i], ForenLastPostTopicNr[i], ForenLastPostStats[i]);
		}
	}

	this.drawForenThread = function ( Titel, ident ){
		out='<table cellpadding="2" cellspacing="0" border="0" width="100%">';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 13px; border-bottom: 0px none;">';
		out+='			'+Titel;
		out+='		</td>';
		if(userart=="admin"){
			if(ThreadStat==0){
				out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer; width: 50px;" align="center" width="50px" onClick="if(confirm(\'Wollen Sie den Thread wirklich Schlie&szlig;en ?\')){ajaxpage(\'module/CloseThread.php\',\''+this.ident+'ForenLoading\',\'=d&threadid=\'+ForumTopicnrNow,\''+this.ident+'.loadForenTopics(ForenThemenNrNow);\');}">';
				out+='			Schlie&szlig;en';
			}
			if(ThreadStat==1){
				out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer; width: 50px;" align="center" width="50px" onClick="if(confirm(\'Wollen Sie den Thread wirklich &Ouml;ffnen ?\')){ajaxpage(\'module/OpenThread.php\',\''+this.ident+'ForenLoading\',\'=d&threadid=\'+ForumTopicnrNow,\''+this.ident+'.loadForenTopics(ForenThemenNrNow);\');}">';
				out+='			&Ouml;ffnen';
			}
		}
		else {
			out+='<td class="mBoxTitel" style="border-bottom: 0px none;">&nbsp;';
		}
		out+='		</td>';
		out+='	</tr>'
		out+='</table><table cellpadding="2" cellspacing="0" border="0" width="100%">';
		out+='	<tr>';
		out+='		<td class="mBoxTitelD" style="font-size: 9px; width: 125px;">';
		out+='			Autor';
		out+='		</td>';
		out+='		<td class="mBoxTitelD" style="font-size: 9px;" align="center" colspan="5">';
		out+='			Beitrag';
		out+='		</td>';
		out+='		<td class="mBoxTitelD" style="font-size: 9px; text-align: center; width: 50px;" align="center" width="50px">';
		out+='			Post';
		out+='		</td>';
		out+='	</tr>';
		out+='</table><table cellpadding="2" cellspacing="0" border="0" width="100%">';
		for(i=0;i<this.topicThread.length; i++){
			out+=this.topicThread[i].draw(this.ident);
		}
			out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px; width: 125px;border-bottom: 0px none;" align="center">';
		out+='			&nbsp;';
		out+='		</td>';
		if(userart=="admin"){
			out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer;" align="center" width="50px" onClick="if(confirm(\'Wollen Sie den Thread Wirklich L&ouml;schen ?\')){ajaxpage(\'module/delThread.php\',\''+this.ident+'ForenLoading\',\'=d&threadid=\'+ForumTopicnrNow,\''+this.ident+'.loadForenTopics(ForenThemenNrNow);\');}">';
			out+='			L&ouml;schen';
		}
		else{
			out+='<td class="mBoxTitel" style="border-bottom: 0px none; border-right: 0px none;">&nbsp;';
		}
		out+='		</td>';
		out+='		<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none; border-right: 0px none;" align="center" colspan="2">';
		out+='			&nbsp;';
		out+='		</td>';
		if(userart=="admin"){
			out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: Pointer;" align="center" width="50px" onClick="alert(\'Coming Soon...\');">';
			out+='			Verschieben';
		}
		else{
			out+='<td class="mBoxTitel" style="border-bottom: 0px none; border-left: 0px none; border-right: 0px none;">&nbsp;';
		}
		out+='		</td>';
		if(userart=="admin"){
			if(ThreadStat<2){
				out+='		<td class="mBoxTitel6" style="font-style: 9px; cursor: pointer;" align="center" width="50px" onClick="if(confirm(\'Wollen Sie den Thread wirklich Ausblenden ?\')){ ajaxpage(\'module/UnDisplayThread.php\',\''+this.ident+'ForenLoading\',\'=d&threadid=\'+ForumTopicnrNow,\''+this.ident+'.loadForenTopics(ForenThemenNrNow);\'); }">';
				out+='			Ausblenden';
			}
			else{
				out+='		<td class="mBoxTitel6" style="font-style: 9px; cursor: pointer;" align="center" width="50px" onClick="if(confirm(\'Wollen Sie den Thread wirklich Einblenden ?\')){ ajaxpage(\'module/DisplayThread.php\',\''+this.ident+'ForenLoading\',\'=d&threadid=\'+ForumTopicnrNow,\''+this.ident+'.loadForenTopics(ForenThemenNrNow);\'); }">';
				out+='			Einblenden';				
			}
		}
		else{
			out+='<td class="mBoxTitel" style="border-bottom: 0px none; border-left: 0px none; border-right: 0px none;">&nbsp;';
		}
		out+='		</td>';
		if(userart=="admin"){
			if(ThreadStat!=1){
				out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer;" align="center" width="50px" onClick="if(confirm(\'Wollen Sie den Thread wirklich Schlie&szlig;en ?\')){ajaxpage(\'module/CloseThread.php\',\''+this.ident+'ForenLoading\',\'=d&threadid=\'+ForumTopicnrNow,\''+this.ident+'.loadForenTopics(ForenThemenNrNow);\');}">';
				out+='			Schlie&szlig;en';
			}
			if(ThreadStat==1){
				out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer;" align="center" width="50px" onClick="if(confirm(\'Wollen Sie den Thread wirklich &Ouml;ffnen ?\')){ajaxpage(\'module/OpenThread.php\',\''+this.ident+'ForenLoading\',\'=d&threadid=\'+ForumTopicnrNow,\''+this.ident+'.loadForenTopics(ForenThemenNrNow);\');}">';
				out+='			&Ouml;ffnen';
			}			
		}
		else{
			out+='<td class="mBoxTitel" style="border-bottom: 0px none; border-left: 0px none;">&nbsp;';
		}
		out+='		</td>';
		out+='	</tr>';
		out+='</table><table cellpadding="2" cellspacing="0" width="100%"><tr><td class="mBoxTitelD">&nbsp;</tD>';
		Zahl=(document.getElementById("ForenSeitenZahl").value);
		ForumSeiteNow=document.getElementById("ForenSeiteZahl").value;
		for(j=0;j<Zahl;j++){
			if(document.getElementById("ForenSeiteZahl").value!=j){
				out+='<td class="mBoxTitel6" width="20px" style="cursor: pointer;" align="center" ';
				out+=' onClick="'+this.ident+'.loadThread2(ForumTitelNow,ForumTopicnrNow,'+j+');"';
				out+='> '+(j+1)+' </td>';
			}
			else {			
				out+='<td class="mBoxTitel4" width="20px" align="center"> '+(j+1)+' </td>';
			}
		}
		out+='</tr></tD></table>';
		out+='<div id="'+this.ident+'ForenThreadContainerAnt">&nbsp;</div>';
		document.getElementById(this.ident+'ForenThreadContainer').innerHTML=out;
	}
	this.drawEditFeld = function (Zitat, postid) {
		ForumPreview=false;
		Zitat=Zitat.replace(/([\\"]{1})/gim,'&Prime;');
		out='<table cellpadding="2" cellspacing="0" border="0" width="100%">';
		out+='	<tr>';
		out+='		<td class="mBoxTitel4" colspan="2">';
		out+='			<textarea class="mBoxTitel3" id="AntwortTextArea">'+Zitat+'</textarea>';
		out+='		</td>';
		out+='	</tr>';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px; cursor: pointer;" >';
		out+='		</td>';
		out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer;" align="center" onClick="ajaxpage(\'module/SaveEditPost.php\',\''+this.ident+'ForenLoading\',\'=d&postid='+encodeURIComponent(postid)+'&post=\' + encodeURIComponent(document.getElementById(\'AntwortTextArea\').value),\''+this.ident+'.loadThread2(\\\''+ForumTitelNow+'\\\',ForumTopicnrNow,ForumSeiteNow);\');" width="50px">';
		out+='			&Auml;ndern';
		out+='		</td>';
		out+='	</tr>'
		out+='</table><table cellpadding="2" cellspacing="0" width="100%"><tR><td class="" id="'+this.ident+'ForenPreviewDIV">&nbsp;</td></tr></table>';
		document.getElementById(this.ident+'ForenThreadContainerAnt').innerHTML=out;
		document.getElementById(this.ident+'ForenThreadContainerAnt').scrollIntoView(true);
		document.getElementById('AntwortTextArea').focus();
		drawEditorIconTable("AntwortTextArea");
	}
	this.drawAntwortFeld = function (Zitat,topicnr) {
		ForumPreview=false;
		out='<table cellpadding="2" cellspacing="0" border="0" width="100%">';
		out+='	<tr>';
		out+='		<td class="mBoxTitel4" colspan="2">';
		out+='			<textarea class="mBoxTitel3" id="AntwortTextArea">'+Zitat+'</textarea>';
		out+='		</td>';
		out+='	</tr>';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px; cursor: pointer;" >&nbsp;';
		out+='		</td>';
		out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer;" align="center" onClick="ajaxpage(\'module/SavePost.php\',\''+this.ident+'ForenLoading\',\'=d&topicnr='+ForumTopicnrNow+'&uid='+uid+'&post=\'+encodeURIComponent(document.getElementById(\'AntwortTextArea\').value),\''+this.ident+'.loadThread2(\\\''+ForumTitelNow+'\\\',ForumTopicnrNow,ForumSeiteNow);\');" width="50px">';
		out+='			Antworten';
		out+='		</td>';
		out+='	</tr>'
		out+='</table><table cellpadding="2" cellspacing="0" width="100%"><tR><td class="" id="'+this.ident+'ForenPreviewDIV">&nbsp;</td></tr></table>';
		document.getElementById(this.ident+'ForenThreadContainerAnt').innerHTML=out;
		document.getElementById(this.ident+'ForenThreadContainerAnt').scrollIntoView(true);
		document.getElementById('AntwortTextArea').focus();
		drawEditorIconTable('AntwortTextArea');
	}	
	this.drawPreviewBox= function (ident){
		if(!ForumPreview){
			document.getElementById(this.ident+"ForenPreviewDIV").innerHTML='&nbsp;';
			document.getElementById(this.ident+"ForenPreviewDIV").className='';
		}
		else{
			document.getElementById(this.ident+"ForenPreviewDIV").innerHTML=bbcode(document.getElementById("AntwortTextArea").value);
			document.getElementById(this.ident+"ForenPreviewDIV").className='mBoxTitel4';			
		}
	}
	this.drawPMFeld = function ( An ) {
//			alert(1);
//			alert(An);
		out='<table cellpadding="2" cellspacing="0" border"0" width="100%" style="border: 0px none; margin-top: 10px;">';
		out+=' 	<tr>';
		out+='		<td class="mBoxTitel" colspan="4" style="font-size: 9px;">';
		out+='			Nachricht an &prime;<span style="font-size: 13px;">'+ An +'</span>&prime; Schreiben';
		out+='		</td>';
		out+='	</tr>';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" width="125px">';
		out+='			Betreff';
		out+='		</td>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" colspan="3">';
		out+='			<input type="text" class="mBoxTitel3" id="PMBetreff" style="width: 100%;">';
		out+='		</td>';
		out+='	</tr>';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" width="125px" valign="top">';
		out+='			Inhalt';
		out+='		</td>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" colspan="3">';
		out+='			<textarea class="mBoxTitel3" id="PMInhalt"></textarea>';
		out+='		</td>';		
		out+='	</tr>';
		out+='	<tr>';
		out+='		<td class="mBoxTitel"> &nbsp;';
		out+='		</td>';
		out+='		<td class="mBoxTitel"> &nbsp;';
		out+='		</td>';
		out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer;" align="center" width="50px" onClick="ajaxpage(\'module/sendmessage.php\',\''+this.ident+'ForenLoading\',\'=d&von=\'+uid+\'&zu=\'+encodeURIComponent(\''+An+'\')+\'&betreff=\'+encodeURIComponent(document.getElementById(\'PMBetreff\').value)+\'&Inhalt=\'+encodeURIComponent(document.getElementById(\'PMInhalt\').value),\'document.getElementById(\\\''+this.ident+'ForenThreadContainerAnt\\\').innerHTML=\\\'&nbsp;\\\';\');">';
		out+='			Abschicken';
		out+='		</td>';
		out+='		<td class="mBoxTitel6" style="font-size: 9px; cursor: pointer;" align="center" width="50px" onClick="document.getElementById(\''+this.ident+'ForenThreadContainerAnt\').innerHTML=\'&nbsp;\';">';
		out+='			Abbrechen';
		out+='		</td>';		
		out+='	</tr>'
		out+='</table>';
		
		document.getElementById(this.ident+'ForenThreadContainerAnt').innerHTML=out;
		document.getElementById('PMBetreff').focus();
		drawEditorIconTable('PMInhalt');

	}
	this.drawForenTopics = function ( ident ){
		out='<table cellpadding="2" cellspacing="0" border="0" width="100%">'; 	
		out+='<tr>'; 
		out+='	<td class="mBoxTitel" style="font-size: 13px;" colspan="6" id="">';	
		out+='		<b onclick="'+this.ident+'.setForenPfad(0);'+this.ident+'.loadForenTopics();" style="cursor:pointer;">Forum</b>' + this.drawForenPfad();
		out+='	</td>';	
		out+='</tr>';
		out+='<tr>';
		out+='	<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none;" width="27px">';
		out+='		&nbsp;';
		out+='	</td>';
		out+='	<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;" align="Center">';
		out+='		Foren&uuml;bersicht';
		out+='	</td>';
		out+='	<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;" align="Center" width="50px">';
		out+='		Beitr&auml;ge';
		out+='	</td>';
		out+='	<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;" align="Center" width="50px">';
		out+='		Themen';
		out+='	</td>';
		out+='	<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;" align="Center">';
		out+='		Letzter Beitrag';
		out+='	</td>';
		out+='	<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;" align="Center" width="75px">';
		out+='		Moderator';
		out+='	</td>';
		out+='</tr>';
		for(i=0;i<this.topicForen.length; i++){
			out+=this.topicForen[i].draw(this.ident);
		}
		if(userart=="admin"){
			out+='<tr>';
			out+='	<td class="mBoxTitelD" colspan="5" style="border-top: 0px none;">';
			out+='		&nbsp;';
			out+='	</td>';
			out+='	<td class="mBoxTitel6" align="center" style="cursor: pointer;" onClick="'+this.ident+'.drawNewTopic();">';
			out+='		New Topic';
			out+='	</td>';
			out+='</tr>';
		}
		out+='</table>';
		if(userart=="admin"){
			out+='<div id="'+this.ident+'NewTopicContainer">&nbsp;</div>';
		}
		document.getElementById(this.ident+"ForenThreadContainer").innerHTML='&nbsp;';		
		return out;
	}

	this.drawNewTopic = function (){
		out='';
		out+='<table width="100%" cellpadding="2" cellspacing="0" border"0">';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" width="125px">';
		out+='			Titel';
		out+='		</td>';
		out+='		<td class="mBoxTitel" colspan="2">';
		out+='			<input type="text" class="mBoxTitel3" width="100%" id="nTtitel">';
		out+='		</td>';
		out+='	</tr>';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" width="125px">';
		out+='			Beschreibung';
		out+='		</td>';
		out+='		<td class="mBoxTitel" colspan="2">';
		out+='			<input type="text" class="mBoxTitel3" width="100%" id="nTdescription">';
		out+='		</td>';
		out+='	</tr>';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" width="125px">';
		out+='			Position';
		out+='		</td>';
		out+='		<td class="mBoxTitel" colspan="2">';
		out+='			<input type="text" class="mBoxTitel3" width="100%" id="nTposition">';
		out+='		</td>';
		out+='	</tr>';		
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" width="125px">';
		out+='			Titel';
		out+='		</td>';
		out+='		<td class="mBoxTitel"> '+forumFirstTopicNrNow;
		out+='		</td>';
		out+='		<td class="mBoxTitel6" width="50" align="center" style="cursor: pointer;" onClick="ajaxpage(\'module/SaveNewTopic.php\',\''+this.ident+'ForenLoading\',encodeURI(\'=d&topicnr=\'+forumFirstTopicNrNow+\'&uid=\'+uid+\'&titel=\'+document.getElementById(\'nTtitel\').value+\'&description=\'+document.getElementById(\'nTdescription\').value+\'&position=\'+document.getElementById(\'nTposition\').value));"> Erstellen ';
		out+='		</td>';		
		out+='	</tr>';
		out+='</table>';
		document.getElementById(this.ident+'NewTopicContainer').innerHTML=out;
	}

	this.drawForenThemen=function ( stats ){
		out="";
		if(this.topicThemen.length>0){
			out='<table cellpadding="2" cellspacing="0" border"0" width="100%" style="border: 0px none;">';
			out+='  <tr>';
			out+='		<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; width: 27px;" width="27px">';
			out+='			&nbsp;';
			out+='		</td>';
			out+='		<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;">';
			out+='			Themen';
			out+='		</td>';
			out+='		<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;" align="center" width="50px">';
			out+='			Antworten';
			out+='		</td>';
			out+='		<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;" align="center" width="75px">';
			out+='			Autor';
			out+='		</td>';
			out+='		<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;" align="center" width="50px">';
			out+='			Treffer';
			out+='		</td>';
			out+='		<td class="mBoxTitel" style="font-size: 9px; border-bottom: 0px none; border-left: 0px none;" align="center">';
			out+='			Letzter Beitrag';
			out+='		</td>';
			out+='	</tr>';
			for(i=0;i<this.topicThemen.length; i++){
				out+=this.topicThemen[i].draw(this.ident);
			}
			if((stats!=3 && stats!=1 ) || userart=="admin"){
				out+='	<tr>';
				out+='		<td class="mBoxTitelD" colspan="5" style="border-top: 0px none;">';
				out+='			&nbsp;';
				out+='		</td>';
				out+='		<td class="mBoxTitel6" align="center" style="cursor:pointer;" onClick="'+this.ident+'.drawMakeThread(ForumTopicnrNow);">';
				out+='			Neuer Thread';
				out+='		</td>';
				out+='	</tr>';
			}
			out+='</table>';
			out+='<div id="'+this.ident+'ForenMakeThreadContainer">&nbsp;</div>';			
		}
		else{
			if(stats!=3 && stats!=1){			
				out='<table cellpadding="2" cellspacing="0" border"0" width="100%" style="border: 0px none;">';
				out+='  <tr>';
				out+='		<td class="mBoxTitel4">';
				out+='			&nbsp;';
				out+='		</td>';
				out+='		<td class="mBoxTitel6" align="center" width="75px" style="cursor:pointer;" onClick="'+this.ident+'.drawMakeThread(ForumTopicnrNow);">';
				out+='			Neuer Thread';
				out+='		</td>';
				out+='	</tr>';
				out+='</table>';
				out+='<div id="'+this.ident+'ForenMakeThreadContainer">&nbsp;</div>';			
			}
		}		
		return out;
	}
	
	this.drawMakeThread = function (){
	out='<table cellpadding="2" cellspacing="0" border="0" width="100%">';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" width="125px">';
		out+='			Titel';
		out+='		</td>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" align="center" colspan="2">';
		out+='			<input class="mBoxTitel3" style="width: 100%;" id="newThreadTitel">';
		out+='		</td>';
		out+='	</tr>';
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" valign="top" id="PostStats">';
		out+='			Post<br><br>&nbsp;&nbsp;Zeichen : 0';
		out+='		</td>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" align="center" colspan="2">';
		out+='			<textarea class="mBoxTitel3" id="newThreadInhalt"></textarea>';
		out+='		</td>';
		out+='	</tr>';		
		out+='	<tr>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" align="center">';
		out+='			&nbsp;';
		out+='		</td>';
		out+='		<td class="mBoxTitel" style="font-size: 9px;" align="center">';
		out+='			&nbsp;';
		out+='		</td>';				
		out+='		<td class="mBoxTitel" style="font-size: 9px; cursor: pointer;" align="center" width="50px" ';
		out+='	onClick="ajaxpage(\'module/newThread.php\',\''+this.ident+'ForenLoading\',\'=d&uid=\'+uid+\'&topicnr=\'+ForenThemenNrNow+\'&titel=\'+encodeURIComponent(document.getElementById(\'newThreadTitel\').value)+\'&Inhalt=\'+encodeURIComponent(document.getElementById(\'newThreadInhalt\').value),\'document.getElementById(\\\''+this.ident+'ForenMakeThreadContainer\\\').innerHTML=\\\'\\\'; '+this.ident+'.loadForenTopics(forumFirstTopicNrNow);\');">';
		out+='			Erstellen';
		out+='		</td>';
		out+='	</tr>';
		document.getElementById(this.ident+"ForenMakeThreadContainer").innerHTML=out;
		drawEditorIconTable("newThreadInhalt");
	}

	this.loadThread = function (titel,topicnr, ident){
		this.delSavedThread();
		ajaxpage('module/forum_read_thread.php',this.ident+'ForenLoading','=d&LP=false&topicnr='+topicnr, this.ident+'.readForenThread(); '+this.ident+'.drawForenThread(\''+titel+'\');');
	}
	this.loadThread2 = function (titel,topicnr,Seite, ident){
		this.delSavedThread();
		ajaxpage('module/forum_read_thread.php',this.ident+'ForenLoading','=d&LP=false&topicnr='+topicnr+'&Seite='+Seite, this.ident+'.readForenThread(); '+this.ident+'.drawForenThread(\''+titel+'\');');
	}	
	this.loadThread3 = function (titel,topicnr, ident){
		this.delSavedThread();
		ajaxpage('module/forum_read_thread.php',this.ident+'ForenLoading','=d&LP=true&topicnr='+topicnr, this.ident+'.readForenThread(); '+this.ident+'.drawForenThread(\''+titel+'\');');
	}	

	this.loadForenThemen=function (topicnr, stats, ident){
			this.delSavedtopicThemen();
			ForenThemenNrNow=topicnr;
			ajaxpage('module/forum_read_themen.php', this.ident+'ForenLoading','=d&topicnr='+topicnr, this.ident+'.readForenThemen(); document.getElementById("'+this.ident+'ForenContainer").innerHTML+='+this.ident+'.drawForenThemen('+stats+');');
	}

	this.loadForenTopics=function (topicnr, stats, ident){
		if(!topicnr){
			forumFirstTopicNrNow=0;
			ajaxpage('module/forum_read_topics.php',this.ident+'ForenLoading','=d',this.ident+'.readForenTopics(); document.getElementById("'+this.ident+'ForenContainer").innerHTML='+this.ident+'.drawForenTopics();');
		}
		else {
			if(this.delSavedtopicForen()){
				forumFirstTopicNrNow=topicnr;
				ajaxpage('module/forum_read_topics.php',this.ident+'ForenLoading','=d&topicnr='+topicnr,this.ident+'.readForenTopics(); document.getElementById("'+this.ident+'ForenContainer").innerHTML='+this.ident+'.drawForenTopics(); '+this.ident+'.loadForenThemen('+topicnr+','+stats+')');
			}
		}
	}
	this.drawContainer=function (ident){
		return '<div id="'+this.ident+'ForenContainer">&nbsp;</div><div id="'+this.ident+'ForenThreadContainer">&nbsp;</div><div id="'+this.ident+'ForenLoading">&nbsp;</div>';
	}
}

var Forum=new forum('Forum');



