function getNewHTTPObject() {
	var xmlhttp;

	/** Special IE only code ... */
	/*@cc_on
		@if (@_jscript_version >= 5)
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (E) {
					xmlhttp = false;
				}
			}
		@else
			xmlhttp = false;
	@end @*/

	/** Other browsers: */
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		}
		catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

function getPage(url,toReplace,loadText,errorText) {
	element = document.getElementById(toReplace);
	if(element !== null) {
		element.innerHTML = loadText;
		var httpRequest = getNewHTTPObject();
		httpRequest.onreadystatechange = function() {
			replaceText(toReplace);
		};
		httpRequest.open("GET", url);
		httpRequest.send(false);

		function replaceText(toReplace){
			if (httpRequest.readyState == 4) {
				if (httpRequest.status == 200) {
					element.innerHTML = httpRequest.responseText;
				} else {
					element.innerHTML = errorText+' ('+httpRequest.status+')';//theHttpRequest.statusText
				}
			}
		}
	} else return false;
}


function loadtabcontent(tab, contenturl, tabcontent, loadText, errorText) {
	if(tab.id=='activetab') return true;
	document.getElementById('activetab').id = '';
	tab.id='activetab';
	if(getPage(contenturl,tabcontent,loadText,errorText))
		return true;
	else
		return false;
}

function like(postid, token) {
	getPage('like.php?postid='+escape(postid)+'&token='+token,'postlike'+postid,document.getElementById('postlike'+postid).innerHTML,'Error');
}
function dislike(postid, token) {
	getPage('like.php?dislike=1&postid='+escape(postid)+'&token='+token,'postdislike'+postid,document.getElementById('postdislike'+postid).innerHTML,'Error');
}

function pmimportant(pmid, yn, token) {
	getPage('genajax.php?act=pmimportant&important='+escape(yn)+'&pmid='+escape(pmid)+'&token='+token,'markimportant',document.getElementById('markimportant').innerHTML,'Error');
}
function threadsub(tid, token, spanid) {
	getPage('../genajax.php?act=threadsub&tid='+escape(tid)+'&token='+token,spanid,document.getElementById(spanid).innerHTML,'Error');
}


