// Requestsvar catRequest = createRequest();var postRequest = createRequest();var replyRequest = createRequest();var topicRequest = createRequest();var editRequest = createRequest();function loadHelp() {	var url = 'connector.php?class=help&method=getHelp';
		id = 35;	
	pageRequest.open("GET", url, true);
	pageRequest.onreadystatechange = updatePage;
	pageRequest.send("null");}function getCategories() {	var url = "connector.php?class=help&method=get_categories";	catRequest.open("GET", url, true);	catRequest.onreadystatechange = updateCategories;	catRequest.send(null);}function updateCategories() {	if(CheckReadyState(catRequest))	{			var div = document.getElementById('categories');				div.innerHTML = catRequest.responseText;				}}var editId = 0;function showEditForm( _id ) {	editId = _id;		var url = "connector.php?class=help&method=getEditReplyForm&id=" + _id;	editRequest.open("GET", url, true);	editRequest.onreadystatechange = updateEditForm;	editRequest.send(null);}function updateEditForm(  ) {	if(CheckReadyState(editRequest))	{		var parent = document.getElementById('reply_' + editId);					parent.innerHTML = editRequest.responseText;				setTimeout("setTiny('reply_text_" + editId + "')", 200 );	}}function showEditQuestionForm( _id ) {	editId = _id;		var url = "connector.php?class=help&method=getEditQuestionForm&id=" + _id;	editRequest.open("GET", url, true);	editRequest.onreadystatechange = updateEditQuestionForm;	editRequest.send(null);}function updateEditQuestionForm() {	if(CheckReadyState(editRequest))	{		var parent = document.getElementById('question_' + editId);					parent.innerHTML = editRequest.responseText;				setTimeout("setTiny('question_text_" + editId + "')", 200 );	}}function clearQuestionForm() {	var parent = document.getElementById("questionForm");		parent.innerHTML = "";}function showSearchForm() {	var parent = document.getElementById("forumFormField");	var html = '<div id="searchForumForm" class="content">'				+ 	"<fieldset>"
				+	'<input type="textfield" class="textfield" id="search_string" onFocus="searchPost();" style="float: left; width: 450px;"/>'				+	"<input type='button' value='X' class='button' style='float: right;' onClick='clearSearch();'/>"				+ 	"</fieldset>"
				+	'</div>';	parent.innerHTML = html;}function clearSearch() {	document.getElementById("search_string").value = "";}function submitAddQuestion() {		if(document.getElementById("add_question_title").value != "") {		document.getElementById("add_question_text").value = tinyMCE.get("add_question_text").getContent();
		if( document.getElementById("add_question_text").value != "" ) {
			submitTiny("add_question_text","addQuestion");
		}else
			alert("No question written!");
	}else
		alert("Empty topic!");}function showQuestionForm() {	var parent = document.getElementById("forumFormField");		var html = "<div class='content'>"				+ 	"<fieldset>"				+	"<form id='addQuestion' method='POST' action='post.php'>"				+ 	"<label for='question_text'>Title:</label>"				+ 	"<input type='textfield' id='add_question_title' name='add_question_title' class='textfield'>"					+ 	"<label for='question_text' style='float: none;'>Question:</label>"				+ 	"<textarea id='add_question_text' name='add_question_text' class='textfield' style='height: 150px;'></textarea>"				+	"<br>"			 			  				+ 	"<input type='button' class='button' value='Cancel' onClick='showSearchForm()' />"				+ 	"<input type='button' class='button' value='OK' onClick='submitAddQuestion()'/>"				+	"<input type='hidden' name='_submit' value='addQuestion' />"				+	"</form>"				+	"</fieldset>"				+	"</div>";		parent.innerHTML = html;		setTimeout("setTiny('add_question_text')", 200 );}function showReplyForm(_id) {	var parent = document.getElementById('replyForm_' + _id);		var html = 	"<div class='content'>"				+ 	"<fieldset>"				+	"<form id='addReply' method='POST' action='post.php'>"				+ 	"<label for='reply_text_" + id + "' style='float: none;'>Answer:</label>"				+ 	"<textarea name='add_answer_text' id='reply_text_" + _id + "' class='textfield' style='height: 150px;'></textarea>"						+	"<br>"	 			  				+ 	"<input type='button' class='button' value='Cancel' onClick='clearAllReplyForms(" + _id + ");' />"				+ 	"<input type='button' class='button' value='OK' onClick='submitTiny(\"reply_text_" + _id + "\",\"addReply\")'/>"				+	"<input type='hidden' name='_submit' value='addAnswer' />"				+	"<input type='hidden' name='add_answer_post' value='" + _id + "' />"				+	"</form>"				+	"</fieldset>"				+	"</div>";		var newdiv = document.createElement("div");	newdiv.innerHTML = html;
	parent.appendChild(newdiv);		setTimeout("setTiny('reply_text_" + _id + "')", 200 );}var replyId = null;function getReplies(id) {	var url = "connector.php?class=help&method=get_replies&id=" + id;	replyRequest.open("GET", url, true);	replyId = id;	replyRequest.onreadystatechange = showReplies;		replyRequest.send(null);}function showReplies() {	if(CheckReadyState(replyRequest))	{		showReplyButton(replyId);				if(document.getElementById('replies_' + replyId))	{						var parent = document.getElementById('replies_' + replyId);									while( parent.firstChild ) {				parent.removeChild( parent.firstChild );			}						var _div = document.getElementsByTagName("div");						var container;						for(var i=0; i<_div.length*3; i++) {				if(_div[i]) {					if(_div[i].getAttribute("button") == "answer") {						var _divid = _div[i].getAttribute("post");						container = document.getElementById("replies_" + _divid);												if(container.firstChild != null && replyId != _divid)							container.removeChild( container.firstChild );					}					}			}									var newdiv = document.createElement("div");			var text = replyRequest.responseText;						newdiv.setAttribute("id","text_" + replyId)			newdiv.innerHTML = text;
			parent.appendChild(newdiv);						container = document.getElementById("text_" + replyId);						var _p = container.getElementsByTagName("p");						for(var i=0; i<_p.length; i++) {				if(_p[i].getAttribute("class") == null) {					_p[i].setAttribute("class","styckesindelning");				}			}		}		}}function clearAllReplyForms(_id) {	var _div = document.getElementsByTagName("div");												for(var i=0; i<_div.length; i++) {		if(_div[i]) {			if(_div[i].getAttribute("button") == "answerForm") {								var form = _div[i].getAttribute("id") 								if( document.getElementById( form ).firstChild )					document.getElementById( form ).removeChild( document.getElementById( form ).firstChild );							}													}	}		showReplyButton( _id );}function setCategory(cat) {			var url = "connector.php?class=help&method=get_posts&id=" + cat;	postRequest.open("GET", url, true);	postRequest.onreadystatechange = updatePosts;	postRequest.send(null);		var url = "connector.php?class=help&method=get_category&id=" + cat;	catRequest.open("GET", url, true);	catRequest.onreadystatechange = setCaption;	catRequest.send(null);	}function showReplyButton( _id ) {	var buttons = document.getElementsByTagName("p");		for(var i=0; i<buttons.length; i++) {			if(buttons[i].getAttribute("button") == "showReplyForm") {					if(buttons[i].getAttribute("post") == _id) {							buttons[i].style.visibility = "visible";						}else {							buttons[i].style.visibility = "hidden";							}				}	}}function setCaption() {	if(CheckReadyState(catRequest))	{						var div = document.getElementById('category');				div.innerHTML = catRequest.responseText;	}}var oldstring = "";function searchPost() {		string =  document.getElementById("search_string").value;		if(string != oldstring) {		oldstring = document.getElementById("search_string").value;		getPosts(string);	}		if( document.getElementById("search_string").focus )  {			setTimeout("searchPost()", 500 );	}}function searchFAQ() {		string =  document.getElementById("search_string").value;		if(string != oldstring) {		oldstring = document.getElementById("search_string").value;		getPosts(string,true);	}		if( document.getElementById("search_string").focus )  {			setTimeout("searchFAQ()", 500 );	}}function getPosts(string,archived) {		if(string) 		var url = "connector.php?class=help&method=get_search&id=" + string;	else		var url = "connector.php?class=help&method=get_posts&id=null";			if(archived)		url += "&archived=" + archived;			ajaxSendRequest(postRequest,url,updatePosts,null);		}function updatePosts() {	if(CheckReadyState(postRequest) && loaded != "")	{					var div = document.getElementById('posts');				div.innerHTML = postRequest.responseText;				if(onLoadReply != "" && loaded != "true") {			getReplies(onLoadReply);			loaded = "true";		}			prepareLinks();		showReplyButton(0);	}}
