/**
* Javascriptfunktionen für eine Thread
*/
var thread;
function Thread() {

	this.url = server + "/forum/bookmarks.php?ajax=info";

	this.xslt = new Xslt();
	this.xPath = new XPath();
	this.cnt = -1;
	//this.xslt.init("Xsl/AJAX/manageThread.php");

	/**
	* Ergebniss des Ajax-Requests wird behandelt
	* Statische Funktion
	*/
	this.update = function() {
		if(thread.xmlHttpReq.readyState == 4) {
			if (thread.xmlHttpReq.responseXML && thread.xmlHttpReq.responseXML.documentElement && thread.xmlHttpReq.responseXML.documentElement.firstChild) {
				
				// Thread ist als bookmark gespeichert worden
				if (thread.xmlHttpReq.responseXML.documentElement.firstChild.nodeName == "bookmark") {
					// Ausblenden des Bookmark Popup
					if (document.getElementById("bookmark[viewgeneraldiscussion][0]")) {
						document.getElementById("bookmark[viewgeneraldiscussion][0]").style.display = "none";
					}
					if (document.getElementById("bookmark[viewwrongentry][0]")) {
						document.getElementById("bookmark[viewwrongentry][0]").style.display = "none";
					}
					if (document.getElementById("bookmark[viewunsolvedquery][0]")) {
						document.getElementById("bookmark[viewunsolvedquery][0]").style.display = "none";
					}
				}
				
				if (thread.xmlHttpReq.responseXML.documentElement.firstChild.nodeName == "count") {
					// Der Seitentitle wird angepasst
					var cnt = parseInt(thread.xmlHttpReq.responseXML.documentElement.firstChild.firstChild.data);
					if (!cnt || cnt <= 0) {
						cnt = 0;
					}
					
					// Falls es die Bookmarkseite ist wird diese erneut geladen
					if (thread.cnt >= 0 && (window.location.href.search(/manageThread/) != -1) && thread.cnt != cnt) {
						location.reload();
					}
					thread.cnt = cnt;
					
					// Seitentitle wird geupdatet
					if (cnt > 0) {
						if (cnt == 1) {
							document.title = "LEO Forum: " + cnt + " Faden mit neuen Antworten."; 
						}
						else {
							document.title = "LEO Forum: " + cnt + " Fäden mit neuen Antworten."; 
						}
					}
					else {
						document.title = "LEO Forum";
					}
				}
				
			}
		}
	}

	/**
	* Thread wird gebookmarkt
	*/
	this.createBookmark = function(event) {
		this.url = server + "/forum/manageThread.php?ajax=info";
		this.startPostRequest(postBackString(event, "bookmark"));
		this.url = server + "/forum/bookmarks.php?ajax=info";
	}
	
	/**
	* Thread wird gebookmarkt
	*/
	this.refresh = function() {
		var str = encodeURI("ajax=info&postBack=managethread&value[action]=count&value[object]=notificationlisting&lang=" + lang +"&lp=" +lp);
		this.startPostRequest(str);
	}
}
Thread.prototype = new Ajax();